Skip to content

Commit

Permalink
fix fortigate sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
lausser committed Dec 4, 2018
1 parent cee3925 commit 701a44b
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 6 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* 2018-12-04 7.4.1.1
fix undefs for Huawei with older Mibs
fix fortigate sensors
* 2018-12-04 7.4.1
detect more Huawei devices
* 2018-12-03 7.4
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_REVISION ($Revision: 1.150 $)
AC_PREREQ(2.58)
AC_INIT(check_nwc_health,7.4.1)
AC_INIT(check_nwc_health,7.4.1.1)
AM_INIT_AUTOMAKE([1.9 tar-pax])
AM_MAINTAINER_MODE([disable])
AC_CANONICAL_HOST
Expand Down
108 changes: 105 additions & 3 deletions plugins-scripts/Classes/Fortigate/Component/SensorSubsystem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,121 @@ package Classes::Fortigate::Component::SensorSubsystem::Sensor;
our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
use strict;

sub finish {
my ($self) = @_;
$self->{fgHwSensorEntAlarmStatus} ||= "false";
$self->{fgHwSensorEntValue} = -1 if ! defined $self->{fgHwSensorEntValue};
if ($self->{fgHwSensorEntValue} == -1) {
# empty, this case is handled in the default sensor class
} elsif ($self->{fgHwSensorEntName} =~ /Fan/) {
bless $self, "Classes::Fortigate::Component::SensorSubsystem::Fan";
} elsif ($self->{fgHwSensorEntName} =~ /PS.*Status/) {
bless $self, "Classes::Fortigate::Component::SensorSubsystem::Powersupply";
} elsif ($self->{fgHwSensorEntName} =~ /(LM75)|(Temp)|(^(TD|TR)\d+)|(DTS\d+)/) {
# thermal diode/resistor, dingsbums thermal sensor
bless $self, "Classes::Fortigate::Component::SensorSubsystem::Temperature";
} elsif ($self->{fgHwSensorEntName} =~ /(VOUT)|(VIN)|(VCC)|(P\d+V\d+)|(_\d+V\d+_)|(DDR)|(VCORE)/) {
# VPP_DDR, VTT_DDR sind irgendwelche voltage regulatory devices
bless $self, "Classes::Fortigate::Component::SensorSubsystem::Voltage";
} else {
$self->{UNKNOWN} = 1;
}
}

sub check {
my ($self) = @_;
if ($self->{fgHwSensorEntValue} == -1) {
$self->add_info(sprintf '%s is not installed',
$self->{fgHwSensorEntName});
return;
}
$self->add_info(sprintf 'sensor %s alarm status is %s',
$self->{fgHwSensorEntName},
$self->{fgHwSensorEntValueStatus});
if ($self->{fgHwSensorEntValueStatus} && $self->{fgHwSensorEntValueStatus} eq "true") {
$self->{fgHwSensorEntAlarmStatus});
if ($self->{fgHwSensorEntAlarmStatus} && $self->{fgHwSensorEntAlarmStatus} eq "true") {
$self->add_critical();
}
if ($self->{fgHwSensorEntValue}) {
$self->add_perfdata(
label => sprintf('sensor_%s', $self->{fgHwSensorEntName}),
value => $self->{swSensorValue},
value => $self->{fgHwSensorEntValue},
);
}
}

package Classes::Fortigate::Component::SensorSubsystem::Fan;
our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
use strict;

sub check {
my ($self) = @_;
$self->add_info(sprintf '%s%s alarm status is %s',
$self->{fgHwSensorEntName} =~ /Fan/i ? "" : "Fan ",
$self->{fgHwSensorEntName},
$self->{fgHwSensorEntAlarmStatus});
if ($self->{fgHwSensorEntAlarmStatus} eq "true") {
$self->add_critical();
}
if (defined $self->{fgHwSensorEntValue}) {
$self->add_perfdata(
label => sprintf('rpm_%s', $self->{fgHwSensorEntName}),
value => $self->{fgHwSensorEntValue},
);
}
}

package Classes::Fortigate::Component::SensorSubsystem::Temperature;
our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
use strict;

sub check {
my ($self) = @_;
$self->add_info(sprintf '%s%s alarm status is %s',
$self->{fgHwSensorEntName} =~ /Temp/i ? "" : "Temp ",
$self->{fgHwSensorEntName},
$self->{fgHwSensorEntAlarmStatus});
if ($self->{fgHwSensorEntAlarmStatus} eq "true") {
$self->add_critical();
}
if (defined $self->{fgHwSensorEntValue}) {
$self->add_perfdata(
label => sprintf('temp_%s', $self->{fgHwSensorEntName}),
value => $self->{fgHwSensorEntValue},
);
}
}

package Classes::Fortigate::Component::SensorSubsystem::Voltage;
our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
use strict;

sub check {
my ($self) = @_;
$self->add_info(sprintf '%s alarm status is %s',
$self->{fgHwSensorEntName},
$self->{fgHwSensorEntAlarmStatus});
if ($self->{fgHwSensorEntAlarmStatus} eq "true") {
$self->add_critical();
}
if (defined $self->{fgHwSensorEntValue}) {
$self->add_perfdata(
label => sprintf('volt_%s', $self->{fgHwSensorEntName}),
value => $self->{fgHwSensorEntValue},
);
}
}

package Classes::Fortigate::Component::SensorSubsystem::Powersupply;
our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
use strict;

sub check {
my ($self) = @_;
$self->add_info(sprintf '%s alarm status is %s',
$self->{fgHwSensorEntName},
$self->{fgHwSensorEntAlarmStatus});
if ($self->{fgHwSensorEntAlarmStatus} eq "true") {
$self->add_critical();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sub init {
foreach (@{$self->{fanstates}}) {
bless $_, "Classes::Huawei::Component::EnvironmentalSubsystem::Fan";
$_->{entPhysicalName} = $_->{flat_indices};
$_->finish();
}
} else {
$self->merge_tables_with_code("fans", "fanstates", sub {
Expand All @@ -48,6 +49,13 @@ package Classes::Huawei::Component::EnvironmentalSubsystem::Fan;
our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
use strict;

sub finish {
my ($self) = @_;
# kommt auch vor, dass die nicht existieren. Im Zweifelsfall "up"
$self->{hwEntityAdminStatus} ||= "up";
$self->{hwEntityOperStatus} ||= "up";
}

sub check {
my ($self) = @_;
$self->add_info(sprintf 'fan %s is %s, state is %s, admin status is %s, oper status is %s',
Expand Down
10 changes: 8 additions & 2 deletions plugins-scripts/Classes/Huawei/Component/MemSubsystem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ sub finish {

sub check {
my ($self) = @_;
$self->add_info(sprintf 'Memory %s usage is %s%% (of %dMB)',
$self->{name}, $self->{hwEntityMemUsage}, $self->{hwEntityMemSizeMega});
if ($self->{hwEntityMemSizeMega}) {
$self->add_info(sprintf 'Memory %s usage is %s%% (of %dMB)',
$self->{name}, $self->{hwEntityMemUsage},
$self->{hwEntityMemSizeMega});
} else {
$self->add_info(sprintf 'Memory %s usage is %s%%',
$self->{name}, $self->{hwEntityMemUsage});
}
$self->set_thresholds(
metric => 'cpu_'.$self->{name},
warning => $self->{hwEntityMemUsageThreshold},
Expand Down

0 comments on commit 701a44b

Please sign in to comment.