Customizing the notification messages

Tips and tricks
Post Reply
gol
Webbplatsadministratör
Posts: 80
Joined: Sun 01 Jun 2014, 19:38

Customizing the notification messages

Post by gol » Sat 10 Oct 2015, 20:58

Each notification service has a lua script you can use to customize the subject and message before it is sent to the recipient.
The location of the lua scripts is /usr/lib/lua/spc-gateway and the names are email-custom.lua, nma-custom.lua and prowl-custom.lua. The scripts are only available via ssh and scp.

Example - If you would like to customize the Alarm Activate and Deactivate messages to get following notifications:
13:10 Alarm is activated by John
17:43 Alarm is deactivated by John

You can modify the lua code according to:

Code: Select all

if #arg ~= 5 then
   return "","";  -- Wrong number of input parameters
end
 
local timestamp = arg[1];
local etype     = arg[2];
local sia       = arg[3];
local edescr    = arg[4];
local eattr     = arg[5];
 
local timestr = os.date("%Y-%m-%d %H:%M:%S", timestamp);
local stime   = os.date("%H:%M", timestamp);
 
local subject = "My SPC Gateway Event";
local message = "Following event has occured: \n " .. timestr .. " - " .. etype .. "[" .. sia .. "], " .. edescr .. ", " .. eattr;
 
if sia == 'CL' then
    message = stime .. " Alarm is activated by " .. edescr;
end
if sia == 'OP' then
    message = stime .. "Alarm is deactivated by " .. edescr;
end
 
return subject, message; 

Post Reply