Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2.03k stars 579 forks source link

Quotes added on perfdata when multiple interfaces polled #7022

Closed pgranado closed 5 years ago

pgranado commented 5 years ago

Expected Behavior

The output format must be the same with perfdata for single or multiple interface (without quotes on the second interface)

Current Behavior

We are using check_snmp_int.pl to poll interfaces on our devices and forward perfdata to an InfluxDB. If we poll only one interface we don't see any problems on output but when we ask to poll multiple interfaces (for example 2 interfaces) we see that quotes are added on the second interface only for in_octets. The output of check_snmp_int.pl is correct but the parsing for perfdata is not correctly done. Here an example: /lib64/nagios/plugins/check_snmp_int.pl -H x.x.x.x -C comm -2 -f -n "eth0|eth1" --perfcheck --perfparse --intspeed --error --mega -w 700,700 -c 900,900
eth0:UP (0.0MBps/0.0MBps), eth1:UP (512.5MBps/0.0MBps):2 UP: OK | 'eth0_in_octet'=29916609c 'eth0_out_octet'=72601193c 'eth0_in_error'=0c 'eth0_in_discard'=0c 'eth0_out_error'=0c 'eth0_out_discard'=0c 'eth0_speed_bps'=1000000000 'eth1_in_octet'=1210083194c 'eth1_out_octet'=429473467c 'eth1_in_error'=0c 'eth1_in_discard'=0c 'eth1_out_error'=0c 'eth1_out_discard'=0c 'eth1_speed_bps'=1000000000

Perfdata: eth0_in_octet=29916609c eth0_out_octet=72601193c eth0_in_error=0c eth0_in_discard=0c eth0_out_error=0c eth0_out_discard=0c ' 'eth1_in_octet''=1210083194c eth1_out_octet=429473467c eth1_in_error=0c eth1_in_discard=0c eth1_out_error=0c eth1_out_discard=0c

We see single quotes only on term eth1_in_octet. The same with multiple interfaces, always term "_in_octet" is affected.

Possible Solution

I'm trying to find it out.. but may be someone else is faster.

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

Your Environment

Al2Klimov commented 5 years ago

Tried to reproduce with the same output:

object CheckCommand "pdq" {
    command = [ "CENSORED/pdq.sh" ]
}

object Host "pdq" {
    check_command = "pdq"
}
#!/bin/bash

exec cat <<EOF
eth0:UP (0.0MBps/0.0MBps), eth1:UP (512.5MBps/0.0MBps):2 UP: OK | 'eth0_in_octet'=29916609c 'eth0_out_octet'=72601193c 'eth0_in_error'=0c 'eth0_in_discard'=0c 'eth0_out_error'=0c 'eth0_out_discard'=0c 'eth0_speed_bps'=1000000000 'eth1_in_octet'=1210083194c 'eth1_out_octet'=429473467c 'eth1_in_error'=0c 'eth1_in_discard'=0c 'eth1_out_error'=0c 'eth1_out_discard'=0c 'eth1_speed_bps'=1000000000
EOF

Works for me:

Bildschirmfoto 2019-03-19 um 09 05 53

pgranado commented 5 years ago

Hi, I tried your example and it works. If I use the check_snmp_int.pl output (copy&paste) it works. I don't see any special chars when I execute it manually. Let me do further tests and I will update this. Thanks.

pgranado commented 5 years ago

Hi, I found the culprit -> check_snmp_int.pl (v1.24) -> line 561 It adds a space between 'eth0_speed_bps'=1000000000 'eth1_in_octet'=1210083194c -> Result = two spaces between them. Icinga parses this as for example -> metric=\ 'eth1_in_octet' I will correct check_snmp_int.pl for perfdata. It's nothing to do with Icinga, sorry for this. I didn't saw directly the additional space.

dnsmichi commented 5 years ago

Maybe it is already fixed in https://github.com/dnsmichi/manubulon-snmp/blob/master/plugins/check_snmp_int.pl

pgranado commented 5 years ago

Not fixed with release 2.1.0 but it matches -> https://github.com/dnsmichi/manubulon-snmp/issues/32

dnsmichi commented 5 years ago

Ah, interesting. When you patch it, please send a PR over there :)