manubulon-snmp
manubulon-snmp copied to clipboard
Error with check_snmp_process.pl
Hi,
I have an error with check_snmp_process.pl define in icinga2 manubulon plugin, I can't specify warning or critical with negative values like -1,20
ie :
I want to check the number of process for smtp, and this number can be 0
so I run this check :
/usr/lib/nagios/plugins/check_snmp_process.pl -C public -H toto -2 -n smtp -c -1,100 -w -1,20
No process matching smtp found : YOU told me it was : OK
But icinga run it like :
/usr/lib/nagios/plugins/check_snmp_process.pl -C public -H toto -2 -n smtp -c -1,100 -w -1,20
Unknown option: 1
Unknown option: ,
Unknown option: 1
Unknown option: 0
Unknown option: 0
Unknown option: 1
Unknown option: ,
Unknown option: 0
Use of uninitialized value $num in pattern match (m//) at /usr/lib/nagios/plugins/check_snmp_process.pl line 89.
Numerical values for warning and critical
Usage: /usr/lib/nagios/plugins/check_snmp_process.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd) [-p <port>] -n <name> [-w <min_proc>[,<max_proc>] -c <min_proc>[,max_proc] ] [-m<warn Mb>,<crit Mb> -a -u<warn %>,<crit%> -d<delta> ] [-t <timeout>] [-o <octet_length>] [-f -A -F ] [-r] [-V] [-g]
The problem is the space betwen -c or -w and value, must be -c-1,100 not -c(space)-1,100
Do you know how can I remove this useless space for this two args ?
I'm using the latest version of plugins
Thanks
👍
Hm, the sytax for negative values is somewhat broken ... problem is when adding a white space, that the leading dash gets interpreted as argment by the getops parser. Unfortunately the plugin guidelines do not specify such edge case ... have an idea? https://www.monitoring-plugins.org/doc/guidelines.html#THRESHOLDFORMAT
Can you add an argument to ignore if no process are founds ? ( -p for positive number of process, -i for ignore <1 process, .... )
Thanks
Hm, seems to be a more common getopt problem and should be treated as such.
A good read: https://docstore.mik.ua/orelly/perl/prog/ch07_035.htm
I'm on my ipad now, but I think :s
instead of =s
could be the culprit.
https://github.com/dnsmichi/manubulon-snmp/blob/master/plugins/check_snmp_process.pl#L259 vs https://github.com/lausser/check_mysql_health/blob/master/plugins-scripts/check_mysql_health.pl#L308
Might also be worthwhile to rewrite getopt like in the mysql_health code.
Hi dnsmichi, confirming that changing the getopt style from :s to =s (for the two options I needed, warn and crit) allows for negative low threshold to be passed in:
I'm happy to submit a patch for this, but it's really just trivial changes to lines 249 and 250:
$ diff /usr/lib/nagios/plugins/check_snmp_process.pl /usr/lib/nagios/plugins/check_snmp_process.pl-orig 249,250c249,250 < 'c=s' => $o_crit, 'critical=s' => $o_crit, < 'w=s' => $o_warn, 'warn=s' => $o_warn,
'c:s' => \$o_crit, 'critical:s' => \$o_crit, 'w:s' => \$o_warn, 'warn:s' => \$o_warn,