I moved to the command line to try in manualy and even tried perl debugger to catch the problem.
root@monitor:/usr/lib/nagios/plugins# ./check_iftraffic.pl -H 192.168.30.100 -i ens192 -b 100 -u m
It runs for few seconds and output nothing.
Last output from perl debug:
main::(./check_iftraffic.pl:104): if ($snmp_version =~ /[12]/) {
DB<1> n
main::(./check_iftraffic.pl:105): ($session, $error) = Net::SNMP->session(
main::(./check_iftraffic.pl:106): -hostname => $host_address,
main::(./check_iftraffic.pl:107): -community => $COMMUNITY,
main::(./check_iftraffic.pl:108): -port => $port,
main::(./check_iftraffic.pl:109): -version => $snmp_version
main::(./check_iftraffic.pl:110): );
DB<1> n
main::(./check_iftraffic.pl:112): if (!defined($session)) {
DB<1> n
main::(./check_iftraffic.pl:126): $iface_number = fetch_ifdescr($session, $iface_descr);
DB<1> n
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> q
So its terminating in fetching iface_number from iface_descr which equals to “ens192” according to:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:01:03:be brd ff:ff:ff:ff:ff:ff
inet 192.168.30.100/24 brd 192.168.30.255 scope global ens192
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fe01:3be/64 scope link
valid_lft forever preferred_lft forever
This tool uses SNMP to query interface statistics, but your test command did not contain any SNMP community string (parameter -C).
Is SNMP stack running on target host?
I never tried that on linux, but i would say, that there is something with your snmpd configuration. No idea here, but don’t think it has anything to do with the check. Try that check against some switch, i’am pretty sure it will work there.
root@monitor:/usr/lib/nagios/plugins# ./check_iftraffic64.pl -H 192.168.30.100 -C whateverforthistest -i ens192 -b 100 -u m
CRITICAL: Could not match ens192
For any other combination of Host IP or “lo” instead of “ens192” does not make output at all
Why is there this check plugin while its not working and even not providing information how to make it working? You have to be senior sysadmin to do this? Why?
How would you do this working? Its just this check-plugin chcecking the same server where its running.
if snmpwalk is not giving the correct results, as it looks in your snmpwalk test, the check_plugin can’t get the information you want. It expect the oids for the interfaces and it looks like they are not there.
For sure it was the most weird combination.
lo for localhost (127.0.0.1)
ens192 with IP 192.168.30.100
and guess what the check is working with combination of
-H 192.168.30.100 -i lo
I checked with snmpwalk the ODI you mentioned.
Little bit struggling with writting to the /tmp/traffic as long I get the point about dynamic name inside of the folder and not only file “traffic”.
Created separated folder with owner nagios to be able to create files here.