Error when monitor network traffic with check_eth

Hi,
I’m a new member of the community, I have a problem with the check_eth script when it runs as a command via SSH.
I created a service on Master Icinga and in the path /usr/lib/nagios/plugins on Host I copied the script check_eth.

If run via terminal on Master the command

/usr/lib/nagios/plugins/check_by_ssh -H 10.1.1.60 -C “/usr/lib/nagios/plugins/check_eth -i ens18 -w 1024K Bps -c 2048K Bps” -l nagios

I receive correctly

RX Bytes: 825MB, TX Bytes: 906MB; RX Speed: 39KBps, TX Speed: 42KBps; OK bandwidth utilization | rx=39815;1048576;2097152 tx=43196;1048576;2097152

If when the command start with icinga the result is

Usage: /usr/lib/nagios/plugins/check_eth -i -w -c [-p -b ]
-i, --interface STRING
Network interface name (example: eth0)
-w, --warning STRING
Warning interface speed level (K/M/G Bps, k/m/g bps)
If using with -p value should be in percentage (1-100)
-c, --critilcal STRING
Critical interface speed level (K/M/G Bps, k/m/g bps)
If using with -p value should be in percentage (1-100)
-p
Calculate warning and critical levels in percentage based on interface bandwidth
-b, --bandwidth STRING
Interface bandwidth value (K/M/G Bps, k/m/g bps)

The service created is:

apply Service “SSH_Net” {
import “by_ssh”
vars.check_command = “Network-Linux”
vars.by_ssh_command = “/usr/lib/nagios/plugins/check_eth”
vars.by_ssh_arguments = {
“-i” = {
value = “ens18”,
order = 0
}
“-w” = {
value = “1M Bps”,
order = 1
}
“-c” = {
value = “2M Bps”,
order = 2
}
}
}

Your problem is probably quoting and how arguments are interpreted by the check_eth plugin.

In your first example arguments are like this, every split line is a single argument.

/usr/lib/nagios/plugins/check_eth -i ens18 -w 1024K Bps -c 2048K Bps
                                  __ _____ __ _____ ___ __ _____ ___

So in your manual example only 1024K is used for -w.

Now your Icinga 2 example uses ssh_arguments, where the value is 1M Bps. This will result in the following command being executed via SSH. Note the quotes making sure that the whitespace is part of the argument value, and not a new argument.

/usr/lib/nagios/plugins/check_eth -i 'ens18' -w '1M Bps' -c '2M Bps'

Note: You can also specify the command line fully to by_ssh_command without arguments.

2 Likes

In fact the problem is the quotation marks, when via terminal console i use the same command passed by Icinga

/usr/lib/nagios/plugins/check_by_ssh -C ‘’/usr/lib/nagios/plugins/check_eth’ ‘-i’ ‘ens18’ ‘-w’ ‘1024K Bps’ ‘-c’ ‘2048K Bps’’ -H 10.1.1.60 -l nagios

the result is the error again

To solve it I had to do as you suggested and I wrote the command line fully to by_ssh_command without arguments.

Thanks so much