Check_snmp_int.pl help

I’m trying yet another approach :pleading_face: to try and get something usable.

I’ve now moved over to check_snmp_int.pl however I’m trying to get the -down command line argument to work. It seems to be missing from the command when imported into Director.

object CheckCommand "snmp-interface" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_snmp_int.pl" ]
    timeout = 1m
    arguments += {
        "--64bits" = {
            description = "Use 64 bits counters instead of the standard counters when checking bandwidth & performance data for interface >= 1Gbps"
            set_if = "$snmp_interface_64bit$"
        }
        "--label" = {
            description = "Add label before speed in output : in=, out=, errors-out=, etc..."
            value = "$snmp_interface_label$"
        }
        "-2" = {
            description = "Use snmp v2c"
            set_if = "$snmp_v2$"
        }
        "-A" = {
            set_if = "$snmp_interface_ifalias$"
        }
        "-B" = {
            description = "Make the warning and critical levels in K|M|G Bits/s instead of K|M|G Bytes/s"
            set_if = "$snmp_interface_kbits$"
        }
        "-C" = {
            description = "Community name for the host's SNMP agent (implies v1 protocol)"
            set_if = "$snmp_nocrypt$"
            value = "$snmp_community$"
        }
        "-H" = {
            description = "Name or IP address of host to check"
            value = "$snmp_address$"
        }
        "-L" = {
            description = "<authproto>,<privproto> - <Authentication protocol (md5|sha : default md5)>,<Priv protocole (des|aes : default des)>"
            set_if = "$snmp_v3_use_authprotocol$"
            value = "$snmp_authprotocol$"
        }
        "-M" = {
            description = "Make the warning and critical levels in Mbps"
            set_if = "$snmp_interface_megabytes$"
        }
        "-N" = {
            set_if = "$snmp_interface_ifname$"
        }
        "-W" = {
            description = "Include 'weathermap' data for NagVis in performance data"
            set_if = "$snmp_interface_weathermap$"
        }
        "-X" = {
            description = "Priv password for snmpv3 (AuthPriv protocol)"
            set_if = "$snmp_v3_use_privpass$"
            value = "$snmp_privpass$"
        }
        "-Y" = {
            description = "Output performance data in bits/s or Bytes/s"
            set_if = "$snmp_interface_bits_bytes$"
        }
        "-c" = "$snmp_crit$"
        "-d" = {
            description = "Make an average of <delta> seconds (default 300=5min)"
            value = "$snmp_interface_delta$"
        }
        "-e" = {
            description = "Add error & discard to Perfparse output"
            set_if = "$snmp_interface_errors$"
        }
        "-f" = {
            description = "Perfparse compatible output (no output when interface is down)"
            set_if = "$snmp_perf$"
        }
        "-i" = {
            description = "Make critical when up"
            set_if = "$snmp_interface_inverse$"
        }
        "-k" = {
            description = "Check the input/ouput bandwidth of the interface"
            set_if = "$snmp_interface_perf$"
        }
        "-l" = {
            description = "Login and auth password for snmpv3 authentication"
            set_if = "$snmp_v3$"
            value = "$snmp_login$"
        }
        "-n" = {
            description = "Name in description OID (eth0, ppp0 ...). This is treated as a regexp : -n eth will match eth0,eth1,..."
            value = "$snmp_interface$"
        }
        "-p" = {
            description = "SNMP port (Default 161)"
            value = "$snmp_port$"
        }
        "-r" = {
            description = "Do not use regexp to match NAME in description OID"
            set_if = "$snmp_interface_noregexp$"
        }
        "-t" = {
            description = "Timeout for SNMP in seconds (Default: 5)"
            value = "$snmp_timeout$"
        }
        "-u" = {
            description = "Make the warning and critical levels in % of reported interface speed"
            set_if = "$snmp_interface_warncrit_percent$"
        }
        "-w" = "$snmp_warn$"
        "-x" = {
            description = "Priv password"
            set_if = "$snmp_v3$"
            value = "$snmp_password$"
        }
        "-y" = {
            description = "Output performance data in % of max speed"
            set_if = "$snmp_interface_percent$"
        }
    }
    vars.check_address = {
        arguments = [  ]
        deprecated = false
        name = "<anonymous>"
        side_effect_free = false
        type = "Function"
    }
    vars.check_ipv4 = false
    vars.check_ipv6 = false
    vars.snmp_address = "$check_address$"
    vars.snmp_authprotocol = "md5,des"
    vars.snmp_community = "public"
    vars.snmp_crit = "0,600"
    vars.snmp_interface = "eth0"
    vars.snmp_interface_64bit = false
    vars.snmp_interface_bits_bytes = true
    vars.snmp_interface_delta = 300
    vars.snmp_interface_errors = true
    vars.snmp_interface_ifalias = false
    vars.snmp_interface_ifname = false
    vars.snmp_interface_kbits = true
    vars.snmp_interface_megabytes = true
    vars.snmp_interface_noregexp = false
    vars.snmp_interface_percent = false
    vars.snmp_interface_perf = true
    vars.snmp_interface_warncrit_percent = false
    vars.snmp_login = "snmpuser"
    vars.snmp_nocrypt = true
    vars.snmp_perf = true
    vars.snmp_timeout = "5"
    vars.snmp_v2 = false
    vars.snmp_v3 = false
    vars.snmp_v3_use_authprotocol = false
    vars.snmp_v3_use_privpass = false
    vars.snmp_warn = "300,400"
}

I’m trying to add the option, as I don’t want to flag down interfaces as critical.

I can’t seem to find a way of simply adding the flag to the existing imported command. So I’ve tried to clone the command. To the most part this has worked, however the resulting service refuses to recognize the target host, even though it’s there.

object CheckCommand "snmp-interface_v3" {
    import "plugin-check-command"
    command = [ PluginDir + "/check_snmp_int.pl" ]
    timeout = 1m
    arguments += {
        "--64bits" = {
            description = "Use 64 bits counters instead of the standard counters when checking bandwidth & performance data for interface >= 1Gbps"
            set_if = "$snmp_interface_64bit$"
        }
        "--down" = {
            set_if = "$interfaces_down_is_ok$"
        }
        "--label" = {
            description = "Add label before speed in output : in=, out=, errors-out=, etc..."
            value = "$snmp_interface_label$"
        }
        "-2" = {
            description = "Use snmp v2c"
            set_if = "$snmp_v2$"
        }
        "-A" = {
            set_if = "$snmp_interface_ifalias$"
        }
        "-B" = {
            description = "Make the warning and critical levels in K|M|G Bits/s instead of K|M|G Bytes/s"
            set_if = "$snmp_interface_kbits$"
        }
        "-C" = {
            description = "Community name for the host's SNMP agent (implies v1 protocol)"
            set_if = "$snmp_nocrypt$"
            value = "$snmp_community$"
        }
        "-H" = {
            description = "Name or IP address of host to check"
            value = "$snmp_address$"
        }
        "-L" = {
            description = "<authproto>,<privproto> - <Authentication protocol (md5|sha : default md5)>,<Priv protocole (des|aes : default des)>"
            set_if = "$snmp_v3_use_authprotocol$"
            value = "$snmp_authprotocol$"
        }
        "-M" = {
            description = "Make the warning and critical levels in Mbps"
            set_if = "$snmp_interface_megabytes$"
        }
        "-N" = {
            set_if = "$snmp_interface_ifname$"
        }
        "-W" = {
            description = "Include 'weathermap' data for NagVis in performance data"
            set_if = "$snmp_interface_weathermap$"
        }
        "-X" = {
            description = "Priv password for snmpv3 (AuthPriv protocol)"
            set_if = "$snmp_v3_use_privpass$"
            value = "$snmp_privpass$"
        }
        "-Y" = {
            description = "Output performance data in bits/s or Bytes/s"
            set_if = "$snmp_interface_bits_bytes$"
        }
        "-c" = "$snmp_crit$"
        "-d" = {
            description = "Make an average of <delta> seconds (default 300=5min)"
            value = "$snmp_interface_delta$"
        }
        "-e" = {
            description = "Add error & discard to Perfparse output"
            set_if = "$snmp_interface_errors$"
        }
        "-f" = {
            description = "Perfparse compatible output (no output when interface is down)"
            set_if = "$snmp_perf$"
        }
        "-i" = {
            description = "Make critical when up"
            set_if = "$snmp_interface_inverse$"
        }
        "-k" = {
            description = "Check the input/ouput bandwidth of the interface"
            set_if = "$snmp_interface_perf$"
        }
        "-l" = {
            description = "Login and auth password for snmpv3 authentication"
            set_if = "$snmp_v3$"
            value = "$snmp_login$"
        }
        "-n" = {
            description = "Name in description OID (eth0, ppp0 ...). This is treated as a regexp : -n eth will match eth0,eth1,..."
            value = "$snmp_interface$"
        }
        "-p" = {
            description = "SNMP port (Default 161)"
            value = "$snmp_port$"
        }
        "-r" = {
            description = "Do not use regexp to match NAME in description OID"
            set_if = "$snmp_interface_noregexp$"
        }
        "-t" = {
            description = "Timeout for SNMP in seconds (Default: 5)"
            value = "$snmp_timeout$"
        }
        "-u" = {
            description = "Make the warning and critical levels in % of reported interface speed"
            set_if = "$snmp_interface_warncrit_percent$"
        }
        "-w" = "$snmp_warn$"
        "-x" = {
            description = "Priv password"
            set_if = "$snmp_v3$"
            value = "$snmp_password$"
        }
        "-y" = {
            description = "Output performance data in % of max speed"
            set_if = "$snmp_interface_percent$"
        }
    }
    vars.check_address = {
        arguments = [  ]
        deprecated = false
        name = "<anonymous>"
        side_effect_free = false
        type = "Function"
    }
    vars.check_ipv4 = false
    vars.check_ipv6 = false
    vars.snmp_address = "$check_address$"
    vars.snmp_authprotocol = "md5,des"
    vars.snmp_community = "public"
    vars.snmp_crit = "0,600"
    vars.snmp_interface = "eth0"
    vars.snmp_interface_64bit = false
    vars.snmp_interface_bits_bytes = true
    vars.snmp_interface_delta = 300
    vars.snmp_interface_errors = true
    vars.snmp_interface_ifalias = false
    vars.snmp_interface_ifname = false
    vars.snmp_interface_kbits = true
    vars.snmp_interface_megabytes = true
    vars.snmp_interface_noregexp = false
    vars.snmp_interface_percent = false
    vars.snmp_interface_perf = true
    vars.snmp_interface_warncrit_percent = false
    vars.snmp_login = "snmpuser"
    vars.snmp_nocrypt = true
    vars.snmp_perf = true
    vars.snmp_timeout = "5"
    vars.snmp_v2 = false
    vars.snmp_v3 = false
    vars.snmp_v3_use_authprotocol = false
    vars.snmp_v3_use_privpass = false
    vars.snmp_warn = "300,400"
}

Could someone offer advice on how to add —down to the already imported command or what’s happening with my duplicated service?
thanks

What do you mean by that? What output does the check generate when executed?
How does the command line look like?

To the cloning: I would create a new command and simply import the existing snmp-int command, then add the --down parameter to the arguments tab and then create the datafield for the down parameter, set it to Boolean. After this add the parameter to the fields tab of the command (or the service template).Done.

Thanks, I’ve eventually spotted the error this morning.

The issue I was seeing was the -H was not added to command line, which of course caused an error as there was no target. An argument value was set via vars.snmp_address

If you look in the first code block above you’ll see I used vars.snmp_address = "$check_address$" I copied this from the import thinking it would work. This morning I’ve replaced it with vars.snmp_address = "$host.address$" in the command template. This seems to have resolved the issue. I’m not sure if $check_address$ is valid or not??? As mentioned I copied it. Either way the command is running. The additional --down flag has been added without issue too.

Unfortunately the results aren’t great at present, i’m getting one of two responses;

2/C6:UP No usable data on file (201 rows) :(1 UP): UNKNOWN
or
Cannot get interface speed using highperf mib : UNKNOWN

:roll_eyes:

As an example.

Running this via the command line,
/usr/lib/nagios/plugins/check_snmp_int.pl --down -B -C public -M -Y -c 0,600 -d 30 -e -f -k -n 2/C21 -r -t 5 -w 300,400 -H 192.168.0.101
produces

2/C21:UP (0.0Mbps/0.3Mbps):1 UP: OK | '2/C21_in_bps'=9928;300000000;;0;100000000 '2/C21_out_bps'=298782;400000000;600000000;0;100000000 '2/C21_in_error'=24c '2/C21_in_discard'=0c '2/C21_out_error'=0c '2/C21_out_discard'=602316148c

In the Icinga2 I’m provided with;
2/C20:UP No usable data on file (201 rows) :(1 UP): UNKNOWN

My Icinga driven command is

'/usr/lib/nagios/plugins/check_snmp_int.pl' '-B' '-C' 'public' '-H' '192.168.0.101' '-M' '-Y' '-c' '0,600' '-d' '30' '-e' '-f' '-k' '-n' '2/C20' '-r' '-t' '5' '-w' '300,400'

As far as I can see they look the same…
Confusing, does that mean the output from the check isn’t usable in Icinga2?

Ta

repeatedly requesting the check via the UI does eventually resolve the issue. I’m assuming this is problem is related to some form of delta between two readings.

Hmm the issue comes and goes intermittently… not sure what is going on.
Does anyone have any ideas.
ta

tweaking the check interval and delta has certainly improved the stability. I’m checking every 30s with a delta of 60s. This seems to have all be eradicated the No usable data on file error.

The script builds a cache and calculates a delta of the last checks.
So you mostly will not see the current interface usage, but more like a trend/development of the usage.

From http://nagios.manubulon.com/snmp_int.html

-d : delta time
You can put the delta time as an option : the “delta” is the prefered time between two values that the script will use to calculate the average Kbytes/s or error/min. The delta time should (not must) be bigger than the check interval.
Here is an example : Check interval of 2 minutes and delta of 4min

T0 : value 1 : can’t calculate usage
T0+2 : value 2 : can’t calculate usage
T0+4 : value 3 : usage=(value3-value1)/((T0+4)-T0)
T0+6 : value 4 : usage=(value4-value2)/((T0+6)-T0+2)
(Yes I know TO+4-T0=4, it’s just to explain…)

The script will allow 10% less of the delta and 300% more than delta as a correct interval.
For example, with a delta of 5 minutes, the acceptable interval will be between 4’30" and 15 minutes.

Thanks, i saw that in the docs. I’m gradually reduces my check schedule and delta, 30s was a little heavy on the CPU. If i use the default timing values, say 5mins, Grafana lacks any real detail. What do people typical use?

Just need to work out Cannot get interface speed using highperf mib : UNKNOWN why certain interfaces are producing that.

Have you tried searching the web for this error already? :wink:

Check interval for my checks is usually 5min, some are 1min, some xhours.
If you change the check interval, you will need to adapt the delta accordingly.

I’ve gone with 60s checks and 4m delta. Will see how we go.

I have googled the other message, and the results suggest it has something to do with 64bit counters on those interfaces. 64bit counters aren’t enabled by default, so it seems about right,

I’ve experimented on the command too, and it certainly resolves the issue, eg

/usr/lib/nagios/plugins/check_snmp_int.pl --down -B -C public -H 192.168.0.101 -M -Y -c 0,600 -d 240 -e -f -k -n 1/A6 -r -t 5 -w 300,400 --64bits -2
1/A6:UP No usable data on file (2 rows) :(1 UP): UNKNOWN | '1/A6_in_error'=0c '1/A6_in_discard'=18395c '1/A6_out_error'=0c '1/A6_out_discard'=0c

The thing I’m not to sure about is enabling 64bit counters on my existing interfaces which do currently work. Is that going to impact the 32bit counters and their respective deltas, I don’t want to essentially misinterpret the data. Any recommendation or advise would be appreciated, I’m unsure which way to go at present. I guess I could duplicate the host and with just the 64bit counters but that seems a little inefficient.

I tested adding the --64bits flag which solved the issue, however the 32bit counters were impacted as I thought, their data was incorrectly represented, it jumped to Tbps, rather than the 500 kbps.

Then just set the flag on those checks, that require it. Either create two separate service apply rules, or use the variable override function of the Director to change those check, that need the flag set.

thanks, not sure its that easy.

I’m using an array to declare my interfaces on the check then passing the var $config$ in. I’m not aware of a way to control the behaviour of the command based on the explicit value within $config$ at run time.
If I’m wrong please correct me.

At the moment I’m just experimenting, as I’d really like to maintain one universal check, I’m considering whether the temp/delta didn’t like the change in figures.

If not two checks might be needed. Though if I’ve missed something please let me know.

Ah, okay.
In that case, using an “apply for”, this is not possible. At least I haven’t found out how.
I created a issue on github for that, maybe there will be a fix/feature for that in the future.

If the problem is “host specific”, meaning, one host has only “32bit interfaces”, the other only “64bit interfaces”, you could add a host variable e.g. interface_64bit, make it boolean, and than have to apply for rules, that use the same interface array, but assign the checks based on that host variable.

1 Like

Thanks, I’ve think i’ve solved it.

I dumped all the /tmp/tmp_Icinga_int* files and the data in Grafana, logic being to ensure the delta wasn’t impacted by the change between 32 and 64 bit counters. After restarting the data seems to be within appropriate ranges. The 10G ports which were 64bit are in the expected range while the 1G ports which were 32bit are also in the correct range.

There was probably quicker route, which didn’t result in dropping data, but given my system isn’t live it wasn’t a problem.

I also learn’t how to manage data in Influx, which was on my to do list :smile:
Just need to deploy the solution to the satellites and remote switches… fingers crossed.