"tweak" values of check_snmp


#1

Now and then somebody asks how the retrieved value can be modified (last time a temperature)) and we had to propose a wrapper script as check_snmp (AFAIK) doesn’t have such a functionality.

Attached you’ll find a changed version having an additional argument.

 -M, --multiplier=FLOAT
    Multiplies current value, 0 < n < 1 works as divider, defaults to 1

Please have a try and report if there are errors.

check_snmp.c.tgz (11.3 KB)

GitHub PR #1542


(Axel577) #2

Hi!
I’ve just tested the plugin:


#3

Please show the complete plugin call.


(Axel577) #4

icinga log:

manual try:


#5

I’d have expected something like

/usr/src/monitoring-plugins-2.2/plugins/check_snmp -H <IP-address> -o .1.3.6.1.2.1.25.2.2.0 -u "KB" -w 4194304 -c 4500000 -M 0.01
SNMP OK - 402376 KB | iso.3.6.1.2.1.25.2.2.0=402376;4194304;4500000

(Axel577) #6

original plugin:
/usr/lib/nagios/plugins# ./check_snmp -H <IP-address> -C administrator -P 2c -o .1.3.6.1.4.1.21317.1.3.2.2.2.1.100.1.2.1
SNMP OK - 21700 | iso.3.6.1.4.1.21317.1.3.2.2.2.1.100.1.2.1=21700

new plugin:
/usr/lib/nagios/plugins# ./check_snmp_new -H <IP-address> -C administrator -P 2c -o .1.3.6.1.4.1.21317.1.3.2.2.2.1.100.1.2.1
./check_snmp_new: Zeile 1: /bin: Ist ein Verzeichnis
./check_snmp_new: Zeile 2: check_apt: Befehl nicht gefunden
./check_snmp_new: Zeile 3: check_apt: Befehl nicht gefunden
./check_snmp_new: Zeile 4: check_apt: Befehl nicht gefunden
./check_snmp_new: Zeile 5: check_apt: Befehl nicht gefunden
./check_snmp_new: Zeile 6: Syntaxfehler beim unerwarteten Wort »(«
./check_snmp_new: Zeile 6: * Copyright (c) 1999-2007 Monitoring Plugins Development Team'


(Michael Friedrich) #7

How about a PR on GitHub? :slight_smile:


#8

Yea, sure, if someone can confirm that my version is running ;-).


(Axel577) #9

Did I do a mistake ?


(Michael Friedrich) #10

PRs also work in a way that code can be tested and reviewed. I won’t download the tar.gz and compile it there, I do git clones, fetches and checkouts.


#11

Well, I can’t say but the output seems odd…


#12

I’ll try do create a PR…

done:
PR #1542


(Axel577) #13

That means that this change will be implemented in the next icinga version?


#14

If the plugin developers find the patch useful, it might be included in the next plugin release. Depending on the Icinga2 release date it might point to the plugin package containing the changed version of check_snmp.
Edit
To rephrase it: The plugins are in a different package than the Icinga2 core.

You’re free to download the source code from the monitoring-plugins repository (once the patch is accepted), compile it and copy check_snmp to your plugins folder.

./check_snmp_new -H <IP-address> -C administrator -P 2c -o .1.3.6.1.4.1.21317.1.3.2.2.2.1.100.1.2.1
./check_snmp_new: Zeile 1: /bin: Ist ein Verzeichnis
./check_snmp_new: Zeile 2: check_apt: Befehl nicht gefunden
./check_snmp_new: Zeile 3: check_apt: Befehl nicht gefunden
./check_snmp_new: Zeile 4: check_apt: Befehl nicht gefunden
./check_snmp_new: Zeile 5: check_apt: Befehl nicht gefunden
./check_snmp_new: Zeile 6: Syntaxfehler beim unerwarteten Wort »(«
./check_snmp_new: Zeile 6: * Copyright (c) 1999-2007 Monitoring Plugins Development Team'

I still have no idea how you managed to get this output. I wonder how you tried to compile the source code.


(Axel577) #15

Hi, the patch isn’t committed yet, is it?


#16

It isn’t reviewed yet but you are free to download it from the repository…