[Nagiosplug-devel] TR: TR: Check_snmp Problem
Thomas Guyot-Sionnest
dermoth at aei.ca
Thu Nov 26 23:11:13 CET 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bruno Grondin wrote:
> Hi thomas,
>
> How can I add the option "-Oq" into the
> check_snmp.c source for the snmpget commandline ?
If you use nagios_plugins 1.4.13 or older it's very easy, just find any
argument in plugins/check_snmp.c and add it there. You can even add it
to config.h after the defines for PATH_TO_SNMPGET and PATH_TO_SNMPGETNEXT.
For v1.4.14 and up it's more tricky because we use a command argument
array and there appear to be some parameters that assume a fixed size.
The easiest way is to squeeze some arguments to make room for it... ex:
Remove:
- - command_line[7] = "-v";
- - command_line[8] = strdup (proto);
And replace with:
+ command_line[7] = malloc(strlen(proto)+3);
+ strcpy(command_line[7], "-v");
+ strcpy(command_line[7]+2, proto);
+ command_line[8] = strdup ("-Oq");
This replace "-v {proto}" with "-v{proto}", which is still valid (for
example with version 2c: "-v 2c" becomes "-v2c"), leaving the position 8
for your "-Oq" argument.
Note that the debug output (-v) needs to be modified as well, so you
won't see any difference in what check_snmp say it will execute unless
you also modify the line starting with:
asprintf(&cl_hidden_auth, [...]
Which is about 10 lines below what I have shown above. This is just
cosmetic.
- --
Thomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAksO/QEACgkQ6dZ+Kt5BchYgoQCeJRVUTqBYqgrA9u0OikPxROFu
PfYAn20/FcX9D9gtdgfuJ0s1NX9VKefp
=0te+
-----END PGP SIGNATURE-----
More information about the Devel
mailing list