diff --git a/analyzers/stablekeys/README.md b/analyzers/stablekeys/README.md index 9e7bf85..0ba34db 100644 --- a/analyzers/stablekeys/README.md +++ b/analyzers/stablekeys/README.md @@ -57,6 +57,7 @@ UPDATES ======= ```` +1.0.2 Jun 21 2023 Changed default guid to flowgen 1.0.1 Jun 14 2023 Initial release ```` diff --git a/analyzers/stablekeys/pkg.yaml b/analyzers/stablekeys/pkg.yaml index 277b416..526ac6e 100644 --- a/analyzers/stablekeys/pkg.yaml +++ b/analyzers/stablekeys/pkg.yaml @@ -1,6 +1,6 @@ name: Stable Keys -version: 1.0.1 +version: 1.0.2 author: trisul diff --git a/analyzers/stablekeys/stablekeys.lua b/analyzers/stablekeys/stablekeys.lua index 5dabc90..27ff34a 100644 --- a/analyzers/stablekeys/stablekeys.lua +++ b/analyzers/stablekeys/stablekeys.lua @@ -11,13 +11,12 @@ require 'mkconfig' function ip_readable(key) - - local ret,_, b1, b2, b3, b4 = string.find( key, "(%x+).(%x+).(%x+).(%x+)") - if ret then - return string.format( "%d.%d.%d.%d", tonumber(b1,16), tonumber(b2,16),tonumber(b3,16), tonumber(b4,16)) - else - return key - end + local ret,_, b1, b2, b3, b4 = string.find( key, "(%x+).(%x+).(%x+).(%x+)") + if ret then + return string.format( "%d.%d.%d.%d", tonumber(b1,16), tonumber(b2,16),tonumber(b3,16), tonumber(b4,16)) + else + return key + end end TrisulPlugin = { @@ -35,21 +34,21 @@ TrisulPlugin = { -- WHEN CALLED : your LUA script is loaded into Trisul onload = function() - -- override by trisulnsm_stablekeys.lua + -- override by trisulnsm_stablekeys.lua -- in probe config directory /usr/local/var/lib/trisul-probe/dX/pX/contextX/config - -- + -- T.active_config = make_config( T.env.get_config("App>DBRoot").."/config/trisulnsm_stablekeys.lua", { -- By default FlowGens - CounterGUID ="{7FAB8F84-C580-424B-2BA4-B2546D2DB15A}", + CounterGUID ="{2314BB8E-2BCC-4B86-8AA2-677E5554C0FE}", -- number of stable intervals NumStableIntervals =1, }) - T.keys_prev_interval = { } + T.keys_prev_interval = { } end, -- WHEN CALLED : your LUA script is unloaded / detached from Trisul @@ -61,50 +60,49 @@ TrisulPlugin = { -- cg_monitor = { - counter_guid = function() - if not T.active_config then - TrisulPlugin.onload() - end - return T.active_config.CounterGUID - end, + counter_guid = function() + if not T.active_config then + TrisulPlugin.onload() + end + return T.active_config.CounterGUID + end, -- WHEN CALLED: when a FLUSH operation starts -- by default called every "stream snapshot interval" of 60 seconds onbeginflush = function(engine, timestamp) - T.keys_this_interval = { } + T.keys_this_interval = { } end, + -- WHEN CALLED: before an item is flushed to the Hub node onflush = function(engine, timestamp,key, metrics) - - if key == "SYS:GROUP_TOTALS" then return; end - - T.keys_this_interval[key]=true - + if key == "SYS:GROUP_TOTALS" then return; end + T.keys_this_interval[key]=true end, + -- WHEN CALLED: end of flush onendflush = function(engine) - for k,v in pairs(T.keys_this_interval) do - if not T.keys_prev_interval[k] then + for k,v in pairs(T.keys_prev_interval) do + if not T.keys_this_interval[k] then - local readable = ip_readable(k) + local readable = ip_readable(k) - -- alert - engine:add_alert( "{B5F1DECB-51D5-4395-B71B-6FA730B772D9}", - nil, - "STABLEKEYS" , - 1, - "No activity on expected key "..readable.."Potentially stopped") - print("STABLEKEYS ALERT: No activity on expected key "..readable.." Potentially stopped") + -- alert + engine:add_alert( "{B5F1DECB-51D5-4395-B71B-6FA730B772D9}", + nil, + "STABLEKEYS" , + 1, + "No activity on expected key "..readable.."Potentially stopped") + T.logwarning("STABLEKEYS ALERT: No activity on expected key "..readable.." Potentially stopped") - end - end + end + end - T.keys_prev_interval = T.keys_this_interval - + T.keys_prev_interval = T.keys_this_interval + end, },