Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optstring for getopts faulty #3

Open
Rocket78 opened this issue Apr 16, 2020 · 2 comments
Open

Optstring for getopts faulty #3

Rocket78 opened this issue Apr 16, 2020 · 2 comments

Comments

@Rocket78
Copy link

Hi, I had an issue because the calibwarn parameter wasn't properly recognized - as we have a leapyear and my calibration now is 366 days old which resulted in a warning. Anyways, there is a hyphen in your optstring after "T" which results in every option after "t" (lowercase) being omitted.

@bytewriter
Copy link
Owner

The hypen in the optstring allows getopts in the script to process long options, like "--calibwarn". The hypen in the getopts string, in this case, is treated just like any other letter. In getopts processing, it is handled a little differently, but I dealt with that in the script. A simple test that options after the hypen are recognized would be /usr/lib64/nagios/plugins/check_common_ups -V

Are you using this in Icinga? Have you tried calling the script manually with the appropriate options for the offending ups?

@Rocket78
Copy link
Author

With original optstring ("bBC:d:hH:i:I:l:L:r:R:t:T-:u:vVw:W:xXy:Y:zZ"):

./check_common_ups -H 192.168.116.254 -I 242 -d c -t 30 -T 35 -y 366
WARNING: host: usv1: APC Smart-UPS SRT 8000: WARN: calibration overdue: 366 > 365 days;| Temp=23;30;50;0 Line_Voltage=236;242;;106 Load=27;70;80;0 RunTime=32;10;8;0 Diagnostic=1;15;20;0 Calibration=366;365;400;0

Without the hyphen in the optstring ("bBC:d:hH:i:I:l:L:r:R:t:T:u:vVw:W:xXy:Y:zZ"):

./check_common_ups -H 192.168.116.254 -I 242 -d c -t 30 -T 35 -y 366
OK: host: usv1: APC Smart-UPS SRT 8000: OK;| Temp=23;30;35;0 Line_Voltage=235;242;;106 Load=27;70;80;0 RunTime=32;10;8;0 Diagnostic=1;15;20;0 Calibration=366;366;400;0

As you can see in the performance data output -T and -y are not parsed. And yes, I use icinga2. Otherwise nice and helpful script you built ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants