shinken-monitoring / pack-linux-snmp

Configuration pack for Linux hosts
4 stars 16 forks source link

Isolate returned value from units when asking for Memory oids #17

Closed pedrojimenez closed 8 years ago

pedrojimenez commented 8 years ago

I have encountered perl type conversion warnings when trying to compare or operate with the memory values returned from the script.

perl check_snmp_mem.pl -w 80 -c 95 -- -v 2c -c public 10.20.30.40
Argument "1032648 kB" isn't numeric in numeric eq (==) at check_snmp_mem.pl line 122.
el valor es:1032648 kBArgument "110904 kB" isn't numeric in subtraction (-) at check_snmp_mem.pl line 131.
Argument "4392 kB" isn't numeric in subtraction (-) at check_snmp_mem.pl line 133.
Argument "184128 kB" isn't numeric in subtraction (-) at check_snmp_mem.pl line 133.
MEMORY OK: 71.00 % used; Free => 110904 kB Kb, Total => 1032648 kB Kb, Cached => 184128 kB Kb, Buffered => 4392 kB Kb|ram_free=110904 kB ram_total=1032648 kB ram_cached=184128 kB ram_buffered=4392 kB

The problem is targeted in the units "kB" returned from the host, it must operate only with the numeric values instead of the full string.

It was finishing the arithmetic operations but the RRD generated was not correct, cause all the warning output. I have test it omitting the warnings, but i think the correct way is capturing the real numbers.

no warnings 'numeric';
claneys commented 8 years ago

Fixed by pull request #15 :)

Thanks