Skip to content

Commit 3dc5d73

Browse files
committed
refactor(redis-status, valkey-status): modernize code and unify both plugins again after PR #954
1 parent 5052c87 commit 3dc5d73

File tree

7 files changed

+1328
-350
lines changed

7 files changed

+1328
-350
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
77

88
## [Unreleased]
99

10+
### Added ("feat")
11+
12+
* valkey-status: support user and password credentials, fix tls connection [PR #954](https://github.com/Linuxfabrik/monitoring-plugins/pull/954), thanks to [Claudio Kuenzler](https://github.com/Napsty)
13+
14+
1015
### Fixed ("fix")
1116

1217
Grafana:
@@ -18,6 +23,11 @@ Monitoring Plugins:
1823
* about-me: Error in perfdata if using `--dmidecode` and there is no HW information
1924

2025

26+
### Changed ("refactor", "chore" etc.)
27+
28+
* redis-status, valkey-status: modernize code and unify both plugins again after [PR #954](https://github.com/Linuxfabrik/monitoring-plugins/pull/954)
29+
30+
2131

2232
## [v2.2.1] - 2025-09-22
2333

check-plugins/redis-status/README.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Returns information and statistics about a Redis server. Alerts on memory consum
66

77
Hints:
88

9-
* Tested on Redis 3.0, 3.2, 6.0, 6.2 and 7.0.
9+
* Tested on Redis 3.0+.
1010
* "I'm here to keep you safe, Sam. I want to help you." comes from the character GERTY in the movie "Moon" (2009).
1111

1212

@@ -24,11 +24,12 @@ Hints:
2424
## Help
2525

2626
```text
27-
usage: redis-status [-h] [-V] [--always-ok] [-c CRIT] [-H HOSTNAME]
28-
[--ignore-maxmemory0] [--ignore-overcommit]
27+
usage: redis-status [-h] [-V] [--always-ok] [--cacert CACERT] [-c CRIT]
28+
[-H HOSTNAME] [--ignore-maxmemory0] [--ignore-overcommit]
2929
[--ignore-somaxconn] [--ignore-sync-partial-err]
3030
[--ignore-thp] [-p PASSWORD] [--port PORT]
31-
[--socket SOCKET] [--test TEST] [--tls] [-w WARN]
31+
[--socket SOCKET] [--test TEST] [--tls]
32+
[--username USERNAME] [--verbose] [-w WARN]
3233
3334
Returns information and statistics about a Redis server. Alerts on memory
3435
consumption, memory fragmentation, hit rates and more.
@@ -37,8 +38,10 @@ options:
3738
-h, --help show this help message and exit
3839
-V, --version show program's version number and exit
3940
--always-ok Always returns OK.
40-
-c, --critical CRIT Set the CRIT threshold as a percentage. Default: >=
41-
None
41+
--cacert CACERT CA Certificate file to verify with. Needs `--tls`.
42+
Default: /etc/pki/tls/certs/rootCA.pem
43+
-c, --critical CRIT Set the CRIT memory usage threshold as a percentage.
44+
Default: >= None
4245
-H, --hostname HOSTNAME
4346
Redis server hostname. Default: 127.0.0.1
4447
--ignore-maxmemory0 Don't warn about redis' maxmemory=0. Default: False
@@ -60,22 +63,45 @@ options:
6063
--test TEST For unit tests. Needs "path-to-stdout-file,path-to-
6164
stderr-file,expected-retc".
6265
--tls Establish a secure TLS connection to Redis.
63-
-w, --warning WARN Set the WARN threshold as a percentage. Default: >= 90
66+
--username USERNAME Username to use when connecting to the Redis server.
67+
--verbose Makes this plugin verbose during the operation. Useful
68+
for debugging and seeing what's going on under the
69+
hood. Default: False
70+
-w, --warning WARN Set the WARN memory usage threshold as a percentage.
71+
Default: >= 90
6472
```
6573

6674

6775
## Usage Examples
6876

6977
```bash
70-
./redis-status --ignore-maxmemory0 --ignore-overcommit --ignore-somaxconn --ignore-sync-partial-err --ignore-thp
78+
./redis-status \
79+
--ignore-maxmemory0 \
80+
--ignore-overcommit \
81+
--ignore-somaxconn \
82+
--ignore-sync-partial-err \
83+
--ignore-thp \
84+
--username=linus \
85+
--password=linuxfabrik
7186
```
7287

7388
Output:
7489

7590
```text
76-
Redis v5.0.3, standalone mode on 127.0.0.1:6379, /etc/redis.conf, up 4m 25s, 100.9% memory usage [WARNING] (9.6MiB/9.5MiB, 9.6MiB peak, 19.6MiB RSS), maxmemory-policy=noeviction, 3 DBs (db0 db3 db4) with 10 keys, 0.0 evicted keys, 0.0 expired keys, hit rate 100.0% (3.0M hits, 0.0 misses), vm.overcommit_memory is not set to 1, kernel transparent_hugepage is not set to "madvise" or "never", net.core.somaxconn (128) is lower than net.ipv4.tcp_max_syn_backlog (256). Sam, I detected a few issues in this Redis instance memory implants:
77-
78-
* High total RSS: This instance has a memory fragmentation and RSS overhead greater than 1.4 (this means that the Resident Set Size of the Redis process is much larger than the sum of the logical allocations Redis performed). This problem is usually due either to a large peak memory (check if there is a peak memory entry above in the report) or may result from a workload that causes the allocator to fragment memory a lot. If the problem is a large peak memory, then there is no issue. Otherwise, make sure you are using the Jemalloc allocator and not the default libc malloc. Note: The currently used allocator is "jemalloc-5.1.0".
91+
Redis v5.0.3, standalone mode on 127.0.0.1:6379, /etc/redis.conf, up 4m 25s, 100.9% memory usage
92+
[WARNING] (9.6MiB/9.5MiB, 9.6MiB peak, 19.6MiB RSS), maxmemory-policy=noeviction, 3 DBs
93+
(db0 db3 db4) with 10 keys, 0.0 evicted keys, 0.0 expired keys, hit rate 100.0%
94+
(3.0M hits, 0.0 misses), vm.overcommit_memory is not set to 1, kernel transparent_hugepage is not
95+
set to "madvise" or "never", net.core.somaxconn (128) is lower than net.ipv4.tcp_max_syn_backlog
96+
(256). Sam, I detected a few issues in this Redis instance memory implants:
97+
98+
* High total RSS: This instance has a memory fragmentation and RSS overhead greater than 1.4
99+
(this means that the Resident Set Size of the Redis process is much larger than the sum of the
100+
logical allocations Redis performed). This problem is usually due either to a large peak
101+
memory (check if there is a peak memory entry above in the report) or may result from a workload
102+
that causes the allocator to fragment memory a lot. If the problem is a large peak memory, then
103+
there is no issue. Otherwise, make sure you are using the Jemalloc allocator and not the default
104+
libc malloc. Note: The currently used allocator is "jemalloc-5.1.0".
79105
80106
I'm here to keep you safe, Sam. I want to help you.
81107
```

check-plugins/redis-status/icingaweb2-module-director/redis-status.json

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"--always-ok": {
66
"set_if": "$redis_status_always_ok$"
77
},
8+
"--cacert": {
9+
"value": "$redis_status_cacert$"
10+
},
811
"--critical": {
912
"value": "$redis_status_critical$"
1013
},
@@ -38,6 +41,12 @@
3841
"--tls": {
3942
"set_if": "$redis_status_tls$"
4043
},
44+
"--username": {
45+
"value": "$redis_status_username$"
46+
},
47+
"--verbose": {
48+
"set_if": "$redis_status_verbose$"
49+
},
4150
"--warning": {
4251
"value": "$redis_status_warning$"
4352
}
@@ -109,6 +118,21 @@
109118
"datafield_id": 13,
110119
"is_required": "n",
111120
"var_filter": null
121+
},
122+
{
123+
"datafield_id": 14,
124+
"is_required": "n",
125+
"var_filter": null
126+
},
127+
{
128+
"datafield_id": 15,
129+
"is_required": "n",
130+
"var_filter": null
131+
},
132+
{
133+
"datafield_id": 16,
134+
"is_required": "n",
135+
"var_filter": null
112136
}
113137
],
114138
"imports": [],
@@ -164,6 +188,7 @@
164188
"vars": {
165189
"criticality": "C",
166190
"redis_status_always_ok": false,
191+
"redis_status_cacert": "/etc/pki/tls/certs/rootCA.pem",
167192
"redis_status_hostname": "127.0.0.1",
168193
"redis_status_ignore_maxmemory0": false,
169194
"redis_status_ignore_overcommit": false,
@@ -172,6 +197,7 @@
172197
"redis_status_ignore_thp": false,
173198
"redis_status_port": "6379",
174199
"redis_status_tls": false,
200+
"redis_status_verbose": false,
175201
"redis_status_warning": 90
176202
},
177203
"volatile": null,
@@ -190,17 +216,28 @@
190216
"uuid": "79d5910d-c4bf-4281-85ef-4f34e8f04614"
191217
},
192218
"2": {
219+
"varname": "redis_status_cacert",
220+
"caption": "Redis Status: Cacert",
221+
"description": "CA Certificate file to verify with. Needs `--tls`.",
222+
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
223+
"format": null,
224+
"settings": {
225+
"visibility": "visible"
226+
},
227+
"uuid": "16720bf0-7d82-4588-8055-57b0ee443234"
228+
},
229+
"3": {
193230
"varname": "redis_status_critical",
194231
"caption": "Redis Status: Critical",
195-
"description": "Set the CRIT threshold as a percentage.",
232+
"description": "Set the CRIT memory usage threshold as a percentage.",
196233
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
197234
"format": null,
198235
"settings": {
199236
"visibility": "visible"
200237
},
201238
"uuid": "35c762a1-c673-4a3e-bf30-68770d52b14d"
202239
},
203-
"3": {
240+
"4": {
204241
"varname": "redis_status_hostname",
205242
"caption": "Redis Status: Hostname",
206243
"description": "Redis server hostname.",
@@ -211,7 +248,7 @@
211248
},
212249
"uuid": "f29df302-80f1-4c0b-b835-396fe1f06b10"
213250
},
214-
"4": {
251+
"5": {
215252
"varname": "redis_status_ignore_maxmemory0",
216253
"caption": "Redis Status: Ignore Maxmemory0?",
217254
"description": "Don't warn about redis' maxmemory=0.",
@@ -220,7 +257,7 @@
220257
"settings": {},
221258
"uuid": "53a21ea5-e1e4-4eac-8fd8-96baeab59f94"
222259
},
223-
"5": {
260+
"6": {
224261
"varname": "redis_status_ignore_overcommit",
225262
"caption": "Redis Status: Ignore Overcommit?",
226263
"description": "Don't warn about vm.overcommit_memory<>1.",
@@ -229,7 +266,7 @@
229266
"settings": {},
230267
"uuid": "16bca65f-dc6d-4655-a11e-f783cb3fe427"
231268
},
232-
"6": {
269+
"7": {
233270
"varname": "redis_status_ignore_somaxconn",
234271
"caption": "Redis Status: Ignore Somaxconn?",
235272
"description": "Don't warn about net.core.somaxconn < net.ipv4.tcp_max_syn_backlog.",
@@ -238,7 +275,7 @@
238275
"settings": {},
239276
"uuid": "b36373f6-40b3-46a6-b074-ade8326cdc82"
240277
},
241-
"7": {
278+
"8": {
242279
"varname": "redis_status_ignore_sync_partial_err",
243280
"caption": "Redis Status: Ignore Sync Partial Err?",
244281
"description": "Don't warn about partial sync errors (because if you have an asynchronous replication, a small number of \"denied partial resync requests\" might be normal).",
@@ -247,7 +284,7 @@
247284
"settings": {},
248285
"uuid": "6b089856-43d7-4008-94d8-478fbacc7730"
249286
},
250-
"8": {
287+
"9": {
251288
"varname": "redis_status_ignore_thp",
252289
"caption": "Redis Status: Ignore Thp?",
253290
"description": "Don't warn about transparent huge page setting.",
@@ -256,7 +293,7 @@
256293
"settings": {},
257294
"uuid": "c7300af7-f285-4012-a160-2647a5a58a2b"
258295
},
259-
"9": {
296+
"10": {
260297
"varname": "redis_status_password",
261298
"caption": "Redis Status: Password",
262299
"description": "Password to use when connecting to the redis server.",
@@ -267,7 +304,7 @@
267304
},
268305
"uuid": "eabaadd8-f4c3-4313-afee-cfea175f93aa"
269306
},
270-
"10": {
307+
"11": {
271308
"varname": "redis_status_port",
272309
"caption": "Redis Status: Port",
273310
"description": "Redis server port.",
@@ -278,7 +315,7 @@
278315
},
279316
"uuid": "15c740aa-0173-4b4f-b139-b1595d8052c8"
280317
},
281-
"11": {
318+
"12": {
282319
"varname": "redis_status_socket",
283320
"caption": "Redis Status: Socket",
284321
"description": "Redis server socket (overrides hostname and port).",
@@ -289,7 +326,7 @@
289326
},
290327
"uuid": "bf84ac19-1b7a-406f-9699-08a66b0bd733"
291328
},
292-
"12": {
329+
"13": {
293330
"varname": "redis_status_tls",
294331
"caption": "Redis Status: Tls?",
295332
"description": "Establish a secure TLS connection to Redis.",
@@ -298,10 +335,30 @@
298335
"settings": {},
299336
"uuid": "5390b14b-2ee3-4ad5-a1f0-dc8d94e1a5db"
300337
},
301-
"13": {
338+
"14": {
339+
"varname": "redis_status_username",
340+
"caption": "Redis Status: Username",
341+
"description": "Username to use when connecting to the Redis server.",
342+
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
343+
"format": null,
344+
"settings": {
345+
"visibility": "visible"
346+
},
347+
"uuid": "00b3c2c2-db14-46da-a0fe-27ac0b3d77ba"
348+
},
349+
"15": {
350+
"varname": "redis_status_verbose",
351+
"caption": "Redis Status: Verbose?",
352+
"description": "Makes this plugin verbose during the operation. Useful for debugging and seeing what's going on under the hood.",
353+
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeBoolean",
354+
"format": null,
355+
"settings": {},
356+
"uuid": "b810b444-d17e-4609-b579-0717285f17d1"
357+
},
358+
"16": {
302359
"varname": "redis_status_warning",
303360
"caption": "Redis Status: Warning",
304-
"description": "Set the WARN threshold as a percentage.",
361+
"description": "Set the WARN memory usage threshold as a percentage.",
305362
"datatype": "Icinga\\Module\\Director\\DataType\\DataTypeString",
306363
"format": null,
307364
"settings": {

0 commit comments

Comments
 (0)