Skip to content

Commit 16a021f

Browse files
authored
Added sanity checks to the Redis reads/writes exceeded alert (#9906)
1 parent 6c9f3ed commit 16a021f

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

scripts/lua/modules/check_definitions/system/redis_reads_writes_exceeded.lua

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
--
2-
-- (C) 2019-24 - ntop.org
2+
-- (C) 2019-25 - ntop.org
33
--
44

55
local alert_consts = require("alert_consts")
66
local alerts_api = require("alerts_api")
77
local alert_categories = require "alert_categories"
88

99
local script = {
10-
-- Script category
11-
category = alert_categories.internals,
12-
severity = alert_consts.get_printable_severities().warning,
10+
-- Script category
11+
category = alert_categories.internals,
12+
severity = alert_consts.get_printable_severities().warning,
1313

14-
hooks = {},
14+
hooks = {},
1515

16-
gui = {
17-
i18n_title = "alerts_dashboard.redis_reads_writes_exceeded",
18-
i18n_description = "alerts_dashboard.redis_reads_writes_exceeded_descr",
19-
}
16+
gui = {
17+
i18n_title = "alerts_dashboard.redis_reads_writes_exceeded",
18+
i18n_description = "alerts_dashboard.redis_reads_writes_exceeded_descr",
19+
}
2020
}
2121

2222
-- #################################################################
@@ -40,6 +40,18 @@ local function check_redis_reads_writes_exceeded(params)
4040
schema = 'redis:reads_writes_v2'
4141
}
4242
local ts = ts_utils.timeseries_query(options)
43+
-- Sanity checks
44+
if not ts
45+
or not ts.series
46+
or not ts.series[1]
47+
or not ts.series[2]
48+
or not ts.series[1].statistics
49+
or not ts.series[2].statistics
50+
or ts.series[1].statistics.average == nil
51+
or ts.series[2].statistics.average == nil
52+
then
53+
return
54+
end
4355
-- Check if the day target is nan
4456
if not ts or not (ts.series[1].data[7] == ts.series[1].data[7]) then
4557
return

0 commit comments

Comments
 (0)