Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lausser/check_nwc_health
Browse files Browse the repository at this point in the history
  • Loading branch information
lausser committed Sep 10, 2015
2 parents 2581651 + daddd7f commit 01c4efa
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
5 changes: 3 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
* 4.4!
- add rapid-city-mib
* 2015-09-06 4.4
add rapid-city-mib
add entity-mib for cisco asa
* 2015-08-18 4.3.1
add ha-role for Aruba
* 2015-08-17 4.3
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,4.3.1)
AC_INIT(check_nwc_health,4.4)
AM_INIT_AUTOMAKE([1.9 tar-pax])
AM_MAINTAINER_MODE([disable])
AC_CANONICAL_HOST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ sub init {
$self->get_snmp_tables('ENTITY-SENSOR-MIB', [
['sensors', 'entPhySensorTable', 'Classes::ENTITYSENSORMIB::Component::EnvironmentalSubsystem::Sensor' ],
]);
if (! @{$self->{entities}}) {
$self->fake_names();
}
foreach (@{$self->{sensors}}) {
$_->{entPhySensorEntityName} = shift(@{$self->{entities}})->{entPhysicalName};
$_->{entPhySensorEntityName} = shift(@{$self->{entities}})->{entPhysicalName} unless $_->{entPhySensorEntityName};;
}
delete $self->{entities};
}
Expand All @@ -33,11 +36,38 @@ sub dump {
}
}

sub fake_names {
# das ist hoffentlich ein ausnahmefall.
# z.b. cisco asa hat keine entPhysicalTable, aber entPhySensorTable
my $self = shift;
my $no_has_entities_names = {};
foreach (@{$self->{sensors}}) {
if (! exists $no_has_entities_names->{$_->{entPhySensorType}}) {
$no_has_entities_names->{$_->{entPhySensorType}} = {};
}
if (! exists $no_has_entities_names->{$_->{entPhySensorType}}->{$_->{entPhySensorUnitsDisplay}}) {
$no_has_entities_names->{$_->{entPhySensorType}}->{$_->{entPhySensorUnitsDisplay}} = 1;
} else {
$no_has_entities_names->{$_->{entPhySensorType}}->{$_->{entPhySensorUnitsDisplay}}++;
}
if ($_->{entPhySensorType} eq "truthvalue") {
$_->{entPhySensorEntityName} = sprintf "%s %s",
$_->{entPhySensorUnitsDisplay},
$_->{entPhySensorValue};
} else {
$_->{entPhySensorEntityName} = sprintf "%s %s",
$_->{entPhySensorUnitsDisplay},
$no_has_entities_names->{$_->{entPhySensorType}}->{$_->{entPhySensorUnitsDisplay}};
}
$_->{entPhySensorEntityName} =~ s/\s+/_/g;
}
}

package Classes::ENTITYSENSORMIB::Component::EnvironmentalSubsystem::Sensor;
our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
use strict;


sub finish {
my $self = shift;
if ($self->{entPhySensorType} eq 'rpm') {
Expand All @@ -50,16 +80,18 @@ sub finish {
sub check {
my $self = shift;
if ($self->{entPhySensorOperStatus} ne 'ok') {
$self->add_info(sprintf '%s has status %s\n',
$self->{entity}->{entPhysicalName},
$self->add_info(sprintf '%s sensor %s has status %s',
$self->{entPhySensorType},
$self->{entPhySensorEntityName},
$self->{entPhySensorOperStatus});
if ($self->{entPhySensorOperStatus} eq 'nonoperational') {
$self->add_critical();
} else {
$self->add_unknown();
}
} else {
$self->add_info(sprintf "%s reports %s%s",
$self->add_info(sprintf "%s sensor %s reports %s%s",
$self->{entPhySensorType},
$self->{entPhySensorEntityName},
$self->{entPhySensorValue},
$self->{entPhySensorUnitsDisplay}
Expand Down

0 comments on commit 01c4efa

Please sign in to comment.