Centreon SNMP Interfaces command

icinga2

(Ben Hartwich) #1

Hi,

I´m using the centreon snmp plugin suite and have included them into icinga2. I´m struggling with the interface command, which doesn´t show me traffic values at icinga. When I execute the command directly I can see the traffic values.

This is the command, which works:

perl centreon_plugins.pl --plugin=os::linux::snmp::plugin --mode=interfaces --hostname=xy.de --snmp-version=2c --snmp-community=test123 --add-traffic

This is my icinga2 integration:

object CheckCommand "centreon-snmp-interfaces" {
   import "plugin-check-command"

   command = [ "/home/nagios/centreon-plugins/centreon_plugins.pl"]
   arguments = {
        "--plugin" = "os::linux::snmp::plugin"
        "--mode" = "interfaces"
        "--hostname" = "$address$"
	"--name" = "$snmp_interface$"
        "--snmp-version" = "2c"
        "--snmp-community" = "$snmp_community$"
//        "--warning" = "$snmp_warn$"
//        "--critical" = "$snmp_crit$"
        "--range-perfdata" = "1"
	 "--add-traffic" = { 
		description = "Add Traffic"
		}
	}
}

Have I integrated the command wrongly?

Regards,


#2

Executing perl centreon_plugins is different from /home/.../centreon_plugins.pl because the first call uses the perl binary in the PATH environment variable whereas the second uses the binary included in the first line of the Perl script (which is most probably NOT present in your system). So locating the perl binary on your machine and replacing the first line with it should resolve your problem.


(Ben Hartwich) #3

Thanks, can you please give an example?


#4

which perl should should the location of the perl binary. Assuming it shows /usr/perl5/bin/perl the first line of the plugin should be #!/usr/perl5/bin/perl. Afterwards I’d expect a reasonable output.


(Ben Hartwich) #5

which perl gives:
/usr/bin/perl
The first line of centreon_plugins.pl is:
#!/usr/bin/perl

The plugin command has now:

object CheckCommand "centreon-snmp-interfaces" {
   import "plugin-check-command"

   command = [ "/usr/bin/perl", "/home/nagios/centreon-plugins/centreon_plugins.pl"]
   arguments = {
        "--plugin" = "os::linux::snmp::plugin"
        "--mode" = "interfaces"
        "--hostname" = "$address$"
	"--name" = "$snmp_interface$"
        "--snmp-version" = "2c"
        "--snmp-community" = "$snmp_community$"
//        "--warning" = "$snmp_warn$"
//        "--critical" = "$snmp_crit$"
        "--range-perfdata" = "1"
	 "--add-traffic" = { 
		description = "Add Traffic"
		}
	}
}

But it doesn´t work. Is add-traffic correct at my command? I don´t know, what´s the best way to include a parameter without any value.


#6

I’m unsure but skip_key seems to be a solution:

"add_option" = {
   value = "--add-traffic"
   skip_key = true
}

(Ben Hartwich) #7

Thanks, I´ve inserted this code snippet, but it doesn´t work.
I´ve found the following in my icingalog file:

warning/InfluxdbWriter: Ignoring invalid perfdata value: traffic_in_enp0s31f6=13049.90b/s;;;0;1000000000

How can I debug further?


(Ben Hartwich) #8

I´ve found the problem. I also need to add --nagvis-perfdata to the command, because of this problem: https://github.com/centreon/centreon-plugins/issues/984

The fully working icinga command is:

object CheckCommand "centreon-snmp-interfaces" {
   import "plugin-check-command"

   command = [ "/usr/bin/perl", "/home/nagios/centreon-plugins/centreon_plugins.pl"]
   arguments = {
        "--plugin" = "os::linux::snmp::plugin"
        "--mode" = "interfaces"
        "--hostname" = "$address$"
	"--name" = "$snmp_interface$"
        "--snmp-version" = "2c"
        "--snmp-community" = "$snmp_community$"
//        "--warning" = "$snmp_warn$"
//        "--critical" = "$snmp_crit$"
        "--range-perfdata" = "1"
	 "add_option" = {
   		value = "--add-traffic"
   	 	skip_key = true
		}
	 "add_option2" = {
   		value = "--nagvis-perfdata"
   	 	skip_key = true
		}
	}
}

#9

“b/s” is an invalid UOM.

Edit: when the first line of he plugins points to the correct location you should be able to omit the specification in command [ ... ].