@@ -23,8 +23,8 @@ import lib.txt # pylint: disable=C0413
2323from lib .globals import (STATE_CRIT , STATE_OK , # pylint: disable=C0413
2424 STATE_UNKNOWN , STATE_WARN )
2525
26- __author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
27- __version__ = '2025062901 '
26+ __author__ = 'Linuxfabrik GmbH, Zurich/Switzerland; Claudio Kuenzler '
27+ __version__ = '2025092401 '
2828
2929DESCRIPTION = """Returns information and statistics about a Valkey server. Alerts on memory
3030 consumption, memory fragmentation, hit rates and more."""
@@ -67,6 +67,12 @@ def parse_args():
6767 default = DEFAULT_CRIT ,
6868 )
6969
70+ parser .add_argument (
71+ '--cacert' ,
72+ help = 'CA Certificate file to verify with.' ,
73+ dest = 'CACERT' ,
74+ )
75+
7076 parser .add_argument (
7177 '-H' , '--hostname' ,
7278 help = 'Valkey server hostname. Default: %(default)s' ,
@@ -153,6 +159,20 @@ def parse_args():
153159 default = False ,
154160 )
155161
162+ parser .add_argument (
163+ '-u' , '--user' ,
164+ help = 'Username to use when connecting to the valkey server.' ,
165+ dest = 'USER' ,
166+ )
167+
168+ parser .add_argument (
169+ '--verbose' ,
170+ help = 'Verbose mode helps you debug stuff.' ,
171+ dest = 'VERBOSE' ,
172+ action = 'store_true' ,
173+ default = False ,
174+ )
175+
156176 parser .add_argument (
157177 '-w' , '--warning' ,
158178 help = 'Set the WARN threshold as a percentage. Default: >= %(default)s' ,
@@ -178,11 +198,17 @@ def main():
178198 base_cmd = 'valkey-cli -h {} -p {} ' .format (args .HOSTNAME , args .PORT )
179199 else :
180200 base_cmd = 'valkey-cli -s {} ' .format (args .SOCKET )
181- if args .PASSWORD :
201+ if args .PASSWORD and not args . USER :
182202 base_cmd += '-a {} ' .format (args .PASSWORD )
183203 base_cmd += '--no-auth-warning '
204+ if args .PASSWORD and args .USER :
205+ base_cmd += '--user {} ' .format (args .USER )
206+ base_cmd += '--pass {} ' .format (args .PASSWORD )
207+ base_cmd += '--no-auth-warning '
184208 if args .TLS :
185- base_cmd += '--tls --cacert /etc/pki/tls/certs/rootCA.pem '
209+ base_cmd += '--tls '
210+ if args .CACERT :
211+ base_cmd += '--cacert {} ' .format (args .CACERT )
186212
187213 # fetch data using `valkey-cli info default`
188214 if args .TEST is None :
@@ -198,6 +224,9 @@ def main():
198224 if not stdout .startswith ('# Server' ):
199225 lib .base .oao (stdout , STATE_WARN )
200226
227+ # Debug output
228+ if args .VERBOSE :
229+ print (stdout )
201230 # parse the output
202231 lines = stdout .splitlines ()
203232 result = {}
@@ -230,11 +259,12 @@ def main():
230259
231260 # analyze result, get the state and build the message
232261
233- # Valkey v8.0.3 (based on Redis v7.2.4), standalone mode on 127.0.0.1:6379,
262+ # Valkey v8.0.3 (based on Redis v7.2.4), standalone mode on 127.0.0.1:6379,
234263 msg += 'Valkey v{}' .format (result ['valkey_version' ])
235264 if 'redis_version' in result :
236265 msg += ' (based on Redis v{})' .format (result ['redis_version' ])
237- msg += ', {} mode ' .format (result ['server_mode' ])
266+ if 'server_mode' in result :
267+ msg += ', {} mode ' .format (result ['server_mode' ])
238268 if not args .SOCKET :
239269 msg += 'on {}:{}, ' .format (
240270 args .HOSTNAME ,
0 commit comments