centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 273 forks source link

Critical and warning bug while using OID json option apps/protocols/snmp/plugin #4775

Closed kadrika closed 8 months ago

kadrika commented 8 months ago

Hi,

I think I have run into a bug using apps/protocols/snmp/plugin. If I check the OID value with --config-json option and add --warning or --critical the result will always be OK.

bash-5.1$ /usr/lib/centreon/plugins//centreon_generic_snmp.pl --plugin=apps/protocols/snmp/plugin --hostname=x.x.x.x --snmp-community=abc --snmp-version=2c --mode=numeric-value --critical=100 --config-json='[ { "oid": "1.3.6.1.4.1.12356.101.12.2.3.1.2.1","perfdata_name": "SSLVPN users", "format": "Currently connected SSLVPN users %s"} ]' OK: Currently connected SSLVPN users 102 | 'SSLVPN users'=102;;;;

bash-5.1$ /usr/lib/centreon/plugins//centreon_generic_snmp.pl --plugin=apps/protocols/snmp/plugin --hostname=x.x.x.x --snmp-community=abc --snmp-version=2c --mode=numeric-value --warning=50 --config-json='[ { "oid": "1.3.6.1.4.1.12356.101.12.2.3.1.2.1","perfdata_name": "SSLVPN users", "format": "Currently connected SSLVPN users %s"} ]' OK: Currently connected SSLVPN users 81 | 'SSLVPN users'=81;;;;

If I remove the json part, the --warning and --critical work nicely. bash-5.1$ /usr/lib/centreon/plugins//centreon_generic_snmp.pl --plugin=apps/protocols/snmp/plugin --hostname=x.x.x.x --snmp-community=abc --snmp-version=2c --mode=numeric-value --oid=1.3.6.1.4.1.12356.101.12.2.3.1.2.1 --critical=100 CRITICAL: current value is 106 | 'value'=106;;0:100;;

Or am I doing something wrong and the --critical and --warning should somehow be combined inside the json config?

kadrika commented 8 months ago

I was my mistake, managed to get it working when using json. Just needed to add "critical": 100 inside json config.

omercier commented 8 months ago

Hi @kadrika, I confirm, you must set the thresholds in the json code, BUT you can define constants this way: In JSON config:

"critical": "%(constants.critical)"

In the command-line:

--constant=’critical=100’

This way you may use the same collection with various values for your thresholds.