@@ -29,7 +29,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2929 STATE_UNKNOWN , STATE_WARN )
3030
3131__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
32- __version__ = '2025071001 '
32+ __version__ = '2025091001 '
3333
3434DESCRIPTION = """This check plugin counts the number of state changes per service within a
3535 given lookback interval. This makes it possible to detect fast flapping services.
@@ -187,10 +187,14 @@ def main():
187187 except SystemExit :
188188 sys .exit (STATE_UNKNOWN )
189189
190- if not args .USERNAME or not args .PASSWORD or not args .URL :
191- lib .base .cu ('`--url`, `--username` and `--password` are required parameters. You can '
192- 'also provide a password file for IcingaWeb to read "url", "user" or '
193- '"password" from.' )
190+ have_creds = args .USERNAME and args .PASSWORD and args .URL
191+ have_pwfile = args .PWFILE
192+ if not (have_creds or have_pwfile ):
193+ lib .base .cu (
194+ 'The three parameters `--url`, `--username` and `--password` are required. ' \
195+ 'Alternatively, you can provide a password file for IcingaWeb to read ' \
196+ 'the "url", "user" or "password" from, using `--pwfile`.'
197+ )
194198
195199 # if given, read password INI-file, but cmdline takes precedence
196200 config = configparser .ConfigParser ()
@@ -209,6 +213,13 @@ def main():
209213 print (e )
210214 sys .exit (STATE_UNKNOWN )
211215
216+ have_creds = args .USERNAME and args .PASSWORD and args .URL
217+ if not have_creds :
218+ lib .base .cu (
219+ 'Either the username, password or URL is not specified' + \
220+ f' in `{ args .PWFILE } `.' if args .PWFILE else '.'
221+ )
222+
212223 # init some vars
213224 msg = ''
214225 state = STATE_OK
0 commit comments