check_snmp convert unit & performance data label

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
kz_skies
Posts: 2
Joined: Mon Jan 14, 2013 3:47 am

check_snmp convert unit & performance data label

Post by kz_skies »

Hello, greetings from Indonesia :)

I have some question:
1) How to convert check_snmp results unit? For example if I want to check free memory on my switch, the check_snmp keeps getting me bytes unit. How can I convert it into MB?
2) How to modifying performance data label? For example, the performance data of PING: "Packet Losts :" ... %.
How can I modify it into like this: "Packet Losts Percentage: " ... %


Thank you very much for your help!
:D
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: check_snmp convert unit & performance data label

Post by sreinhardt »

1) Check_snmp is only returning the data that your device is sending it. It does not by default modify anything. You would have a couple options regarding how you can change this. Alter the C code for check_snmp and reconfigure so that it divides by 1024 by default. You could also modify the check_mrtgtraf C file for along the same regards, but that would only change the graphing files. My final thought would be to potentially modify the C files that create cgi scripts. However this may not be possible depending on how those cgi's are taking data in, and regarding the other changes, all could cause issues for other ports or services if you do not want the same value there.

2)Again, you would need to modify the C files that are built into cgi files. After modification be sure to compile and replace the existing ones.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_snmp convert unit & performance data label

Post by abrist »

To expand on sreinhardt's points, if you do change the metric in the check_snmp c file, any check that uses this plugin will have incorrect data (as far it is represented on the perf graphs) for all perf data that was written before the check_snmp code change. Just FYI.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
kz_skies
Posts: 2
Joined: Mon Jan 14, 2013 3:47 am

Re: check_snmp convert unit & performance data label

Post by kz_skies »

Thank you abrist, sreinhardt ! :D

Now the question is, where is the location of check_snmp C file?
Because i only find check_snmp in a binary form (located at /usr/local/nagios/libexec), and obviously i can't edit a binary file :)
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_snmp convert unit & performance data label

Post by abrist »

The source for the standard plugins can be downloaded here. You will find the check_snmp.c file in the tarball.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked