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

Error with check_snmp_process.pl #24

Open
darkounet opened this issue Feb 3, 2017 · 6 comments
Open

Error with check_snmp_process.pl #24

darkounet opened this issue Feb 3, 2017 · 6 comments

Comments

@darkounet
Copy link

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

@bahamut45
Copy link

👍

@dnsmichi
Copy link
Collaborator

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

@darkounet
Copy link
Author

Can you add an argument to ignore if no process are founds ? ( -p for positive number of process, -i for ignore <1 process, .... )

Thanks

@dnsmichi
Copy link
Collaborator

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

@dnsmichi
Copy link
Collaborator

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.

@dnsmichi dnsmichi added the bug label Aug 10, 2017
@PhilipYarra
Copy link

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:

image

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,

PhilipYarra added a commit to PhilipYarra/manubulon-snmp that referenced this issue Feb 21, 2018
… options with spaces between option and value

This allows check_snmp_process.pl -w -1,40 -c -1,50 to work as expected. This should address bug SteScho#24 SteScho#24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants