Page 1 of 1

check_snmp. Multiply or divide the obtained value

PostPosted: Tue Jan 11, 2022 3:15 pm
by kchiche18
Good afternoon.
I need to multiply by 0.1 a value obtained with the check_snmp plugin. I have seen that there exists in the source code of Github https://github.com/nagios-plugins/nagios-plugins/blob/master/plugins/check_snmp.c, a parameter:

#define L_MULTIPLIER CHAR_MAX+6

I need to send to "check_snmp" a parameter (for example, -M 0.1) to multiply/divide the value recibied.
How can I do it?

I think to patch "check_snmp" something like this below, comment the constant and substituing by 'M' parameters.
Thanks.

@@ -68,1 +68,1 @@
-#define L_MULTIPLIER CHAR_MAX+6
+/*#define L_MULTIPLIER CHAR_MAX+6*/
@@ -775,1 +775,1 @@
- {"multiplier", required_argument, 0, L_MULTIPLIER},
+ {"multiplier", required_argument, 0, 'M'},
@@ -1015,1 +1015,1 @@
- case L_MULTIPLIER:
+ case 'M':
@@ -1365,1 +1365,1 @@
- printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [--strict]\n");
+ printf ("[-a authproto] [-A authpasswd] [-x privproto] [-X privpasswd] [-M multiplier] [--strict]\n");