lausser / check_nwc_health

nwc = network component. This plugin checks lots of aspects of routers, switches, wlan controllers, firewalls,.....
http://labs.consol.de/nagios/check_nwc_health
GNU General Public License v2.0
146 stars 88 forks source link

fix PSU sensors on Fortigate FortiOS 7.0 #310 #311

Closed dcec closed 1 year ago

dcec commented 1 year ago

Fix PSU sensors on Fortigate FortiOS 7.0 #310

  1. default sensor class only if fgHwSensorEntValue is in numeric.
  2. add pars for new psu name, ex. PSU [2]
lausser commented 1 year ago
if ( $self->{fgHwSensorEntValue} =~ /^[0-9,.E]+$/ && $self->{fgHwSensorEntValue} == -1) {
    # empty, this case is handled in the default sensor class

Do you have an example for a fgHwSensorEntValue which both matches ^[0-9,.E]+$ AND equals -1? Or at least one matching the regexp? Like this, the empty case will never be reached.

The PSU is good, thanks for that. As fgHwSensorEntValue can contain valuable information (it is a string and might show more values than ON or LOST), can you improve the Powersupply class as well?

  if ($self->{fgHwSensorEntAlarmStatus} eq "true") {
    $self->annotate_info($self->{fgHwSensorEntValue}) if defined $self->{fgHwSensorEntValue};
    $self->add_critical();
  }
dcec commented 1 year ago

You are right, on regexp i have to add the "-" like: if ( $self->{fgHwSensorEntValue} =~ /^[0-9,.E-]+$/ && $self->{fgHwSensorEntValue} == -1) {

The fgHwSensorEntValue contain ON or LOST, no other data:

info: checking sensors [POWERSUPPLY_1] fgHwSensorEntAlarmStatus: false fgHwSensorEntIndex: 1 fgHwSensorEntName: PSU [1] fgHwSensorEntValue: ON info: PSU [1] alarm status is false

[POWERSUPPLY_2] fgHwSensorEntAlarmStatus: true fgHwSensorEntIndex: 2 fgHwSensorEntName: PSU [2] fgHwSensorEntValue: LOST info: PSU [2] alarm status is true

dcec commented 1 year ago

have sense to replace if ( $self->{fgHwSensorEntValue} == -1) { with: if ( $self->{fgHwSensorEntValue} =~ /^-1$/) {

dcec commented 1 year ago

Working fine also on FGT 40F with FortiOS 7.2