I've a situation where there is need to pre-process some alarms through lua
So, there are 2 servers send same alarms from logmon several times a week since they handle the same application.
Now I would like to suppress alarms from 1 server if there is a match on probe, subsystem and message.
Need some suggestions and if someone has such an implementation can guide too.Other alternative are also welcome
Something like this should work if i understood your need
local prid = "logmon"local subsys = "1.1"local match = string.matchlocal pattern = ".*Failed\sto\sget.*"local aoAlarm = alarm.get()if aoAlarm.prid == prid and aoAlarm.sid == subsys and match(aoAlarm.message, pattern) then action.close(aoAlarm.nimid)end
Put this script on AO. And it should "close" any alarm that come and match these three conditions. You can test this script by executing the script yourself (just give a "nimid" in the alarm.get() ).
If you want to dump complete hash use this
local function tdump(t) local search = pairs; local sf = string.format; local sr = string.rep; local perf_type = type; local ts = tostring; local function dmp(t, l, k) if perf_type(t) == "table" then print(sf("%s%s:", sr(" ", l*2), ts(k))); for k, v in search(t) do dmp(v, l+1, k); end else print(sf("%s%s:%s", sr(" ", l*2), ts(k), ts(t))); end end dmp(t, 1, "root");end
And use it to dump the aoAlarm hash: