Skip to content

Commit

Permalink
Changes default GUID and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
trisulnsm committed Jun 21, 2023
1 parent ada00a1 commit 4034499
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 38 deletions.
1 change: 1 addition & 0 deletions analyzers/stablekeys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ UPDATES
=======

````
1.0.2 Jun 21 2023 Changed default guid to flowgen
1.0.1 Jun 14 2023 Initial release
````

Expand Down
2 changes: 1 addition & 1 deletion analyzers/stablekeys/pkg.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Stable Keys

version: 1.0.1
version: 1.0.2

author: trisul

Expand Down
72 changes: 35 additions & 37 deletions analyzers/stablekeys/stablekeys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand All @@ -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,

},
Expand Down

0 comments on commit 4034499

Please sign in to comment.