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
311 stars 274 forks source link

Fix 3com snmp fan/psu check #5201

Closed octvcdrc closed 2 months ago

octvcdrc commented 2 months ago

Description

On 3com network devices, a fan or psu is reported as "active" when working properly, and "deactive" when failed. The threshold regex for the "OK" status is configured too vaguely: a "deactive" status was considered "active" / "OK" as the string "active" is contained in "deactive". This fix ensures that the "OK" status starts (and ends) with "active".

Type of change

How this pull request can be tested ?

Before this patch, a "deactive" fan is considered "OK" (Debug output is redacted for brevity) :

# perl /usr/lib/centreon/plugins/centreon_3com_debug.pl --mode=hardware --hostname=x --snmp-version='3' --authprotocol=sha --privprotocol=aes --snmp-username=x --authpassphrase=x --privpassphrase=x --component=fan --snmp-timeout=20 --debug
`OK: All 12 components are ok [12/12 fans]. | 'count_fan'=12;;;;
.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.1.65536 = 65536
.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.1.196611 = 196611
.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2.65536 = 1
.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2.196611 = 2
Checking fans
Fan '65536' status is 'active' [instance: 65536]
Fan '196611' status is 'deactive' [instance: 196611]

After patching, the failed fan is correctly reported as failed (Debug output is redacted for brevity) :

perl /usr/lib/centreon/plugins/centreon_3com.pl --mode=hardware --hostname=x --snmp-version='3' --authprotocol=sha --privprotocol=aes --snmp-username=x --authpassphrase=x --privpassphrase=x --component=fan --snmp-timeout=20 --debug
CRITICAL: Fan '196611' status is deactive | 'count_fan'=12;;;;
.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.1.65536 = 65536
.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.1.196611 = 196611
.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2.65536 = 1
.1.3.6.1.4.1.43.45.1.2.23.1.9.1.1.1.2.196611 = 2
Checking fans
Fan '65536' status is 'active' [instance: 65536]
Fan '196611' status is 'deactive' [instance: 196611]

Checklist

omercier commented 2 months ago

Thanks a lot for your contribution @octvcdrc!