check_snmp remove leading 'SNMP' from alert

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
snapon_admin
Posts: 952
Joined: Mon Jun 10, 2013 10:39 am
Location: Kenosha, WI
Contact:

check_snmp remove leading 'SNMP' from alert

Post by snapon_admin »

This may seem minor, but is there an easy way to remove the leading SNMP from check_snmp alerts. Currently an alert will look like this:

Code: Select all

SNMP OK - CPU Load 36 %
I'd like to remove the SNMP part of that as it's unnecessary for us so that it just says:

Code: Select all

OK - CPU Load 36 %
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check_snmp remove leading 'SNMP' from alert

Post by mcapra »

I think you'd have to change this line, then recompile the plugin:
https://github.com/nagios-plugins/nagio ... nmp.c#L225

Code: Select all

[root@nagios ~]# /usr/local/nagios/libexec/check_snmp -H 127.0.0.1 -P 2c -C 209ijvfwer0df92jd -o 1.3.6.1.2.1.25.3.3.1
SNMP OK - No Such Object available on this agent at this OID |
Then after changing the line and recompiling:

Code: Select all

# check_snmp.c #L225
label = strdup ("");

...

[root@nagios ~]# /usr/local/nagios/libexec/check_snmp -H 127.0.0.1 -P 2c -C 209ijvfwer0df92jd -o 1.3.6.1.2.1.25.3.3.1
 OK - No Such Object available on this agent at this OID |
Those changes *might* not persist through regular updates to Nagios XI, though. You could also write a wrapper script to sed
or awk away the "SNMP", though it'd be a bit more work and you need to be mindful of preserving the Unix exit code when doing that.
Former Nagios employee
https://www.mcapra.com/
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_snmp remove leading 'SNMP' from alert

Post by tgriep »

Thanks @mcapra for the help.
@snapon_admin, it you have any other questions, let us know.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked