From a267b7a28f37233790b86945e34f01237f3f24b5 Mon Sep 17 00:00:00 2001 From: Konstantin Shalygin Date: Thu, 12 Jan 2017 01:26:49 +0700 Subject: [PATCH] Add support for Eltex (http://eltex-co.ru/en) MES devices. --- plugins-scripts/Classes/Device.pm | 7 +- plugins-scripts/Classes/Eltex.pm | 19 ++++++ plugins-scripts/Classes/Eltex/Access.pm | 27 ++++++++ .../Component/EnvironmentalSubsystem.pm | 51 ++++++++++++++ plugins-scripts/Classes/Eltex/Aggregation.pm | 25 +++++++ .../Component/EnvironmentalSubsystem.pm | 68 +++++++++++++++++++ .../Eltex/MES/Component/CpuSubsystem.pm | 34 ++++++++++ .../Eltex/MES/Component/HaSubsystem.pm | 29 ++++++++ plugins-scripts/Makefile.am | 9 ++- 9 files changed, 266 insertions(+), 3 deletions(-) create mode 100644 plugins-scripts/Classes/Eltex.pm create mode 100644 plugins-scripts/Classes/Eltex/Access.pm create mode 100644 plugins-scripts/Classes/Eltex/Access/Component/EnvironmentalSubsystem.pm create mode 100644 plugins-scripts/Classes/Eltex/Aggregation.pm create mode 100644 plugins-scripts/Classes/Eltex/Aggregation/Component/EnvironmentalSubsystem.pm create mode 100644 plugins-scripts/Classes/Eltex/MES/Component/CpuSubsystem.pm create mode 100644 plugins-scripts/Classes/Eltex/MES/Component/HaSubsystem.pm diff --git a/plugins-scripts/Classes/Device.pm b/plugins-scripts/Classes/Device.pm index 55dcfdf8..97dae218 100644 --- a/plugins-scripts/Classes/Device.pm +++ b/plugins-scripts/Classes/Device.pm @@ -31,6 +31,7 @@ sub classify { $self->{productname} = 'hh3c' if $self->opts->servertype eq 'hh3c'; $self->{productname} = 'hp' if $self->opts->servertype eq 'hp'; $self->{productname} = 'brocade' if $self->opts->servertype eq 'brocade'; + $self->{productname} = 'eltex' if $self->opts->servertype eq 'eltex'; $self->{productname} = 'netscreen' if $self->opts->servertype eq 'netscreen'; $self->{productname} = 'junos' if $self->opts->servertype eq 'junos'; $self->{productname} = 'linuxlocal' if $self->opts->servertype eq 'linuxlocal'; @@ -90,6 +91,9 @@ sub classify { } elsif ($self->{productname} =~ /(Linux cumulus)|(Cumulus Linux)/i) { bless $self, 'Classes::Cumulus'; $self->debug('using Classes::Cumulus'); + } elsif ($self->{productname} =~ /MES/i) { + bless $self, 'Classes::Eltex'; + $self->debug('using Classes::Eltex'); } elsif ($self->{productname} =~ /DS_4100/i) { bless $self, 'Classes::Brocade'; $self->debug('using Classes::Brocade'); @@ -179,7 +183,7 @@ sub classify { bless $self, 'Classes::Foundry'; $self->debug('using Classes::Foundry'); } elsif ($self->{productname} =~ /IronWare/i) { - # although there can be a + # although there can be a # Brocade Communications Systems, Inc. FWS648, IronWare Version 07.1.... bless $self, 'Classes::Foundry'; $self->debug('using Classes::Foundry'); @@ -274,4 +278,3 @@ sub init { $self->no_such_mode(); } } - diff --git a/plugins-scripts/Classes/Eltex.pm b/plugins-scripts/Classes/Eltex.pm new file mode 100644 index 00000000..99fb85ae --- /dev/null +++ b/plugins-scripts/Classes/Eltex.pm @@ -0,0 +1,19 @@ +package Classes::Eltex; +our @ISA = qw(Classes::Device); +use strict; + +sub init { + my $self = shift; + if ($self->{productname} =~ /(MES2324B)|(MES2324F)|(MES31)|(MES53)/i) { + bless $self, 'Classes::Eltex::Aggregation'; + $self->debug('using Classes::Eltex::Aggregation'); + } elsif ($self->{productname} =~ /(MES21)|(MES23)/i) { + bless $self, 'Classes::Eltex::Access'; + $self->debug('using Classes::Eltex::Access'); + } + if (ref($self) ne "Classes::Eltex") { + $self->init(); + } else { + $self->no_such_mode(); + } +} diff --git a/plugins-scripts/Classes/Eltex/Access.pm b/plugins-scripts/Classes/Eltex/Access.pm new file mode 100644 index 00000000..276afef6 --- /dev/null +++ b/plugins-scripts/Classes/Eltex/Access.pm @@ -0,0 +1,27 @@ +package Classes::Eltex::Access; +our @ISA = qw(Classes::Eltex); +use strict; + +# MES2100: 1 PSU, no FAN +# MES2124P: 1 PSU, 2 FAN +# MES2308: 1 PSU, no FAN +# MES2324: 1 PSU, no FAN +# MES2326: 1 PSU, no FAN +# MES2348: 1 PSU, 2 FAN + +sub init { + my $self = shift; + if ($self->mode =~ /device::hardware::load/) { + $self->analyze_and_check_cpu_subsystem('Classes::Eltex::MES::Component::CpuSubsystem'); + } elsif ($self->mode =~ /device::hardware::health/) { + $self->analyze_and_check_environmental_subsystem('Classes::Eltex::Access::Component::EnvironmentalSubsystem'); + if (! $self->check_messages()) { + $self->clear_messages(0); + $self->add_ok('environmental hardware working fine'); + } + } elsif ($self->mode =~ /device::ha::status/) { + $self->analyze_and_check_ha_subsystem('Classes::Eltex::MES::Component::HaSubsystem'); + } else { + $self->no_such_mode(); + } +} diff --git a/plugins-scripts/Classes/Eltex/Access/Component/EnvironmentalSubsystem.pm b/plugins-scripts/Classes/Eltex/Access/Component/EnvironmentalSubsystem.pm new file mode 100644 index 00000000..2fa953ba --- /dev/null +++ b/plugins-scripts/Classes/Eltex/Access/Component/EnvironmentalSubsystem.pm @@ -0,0 +1,51 @@ +package Classes::Eltex::Access::Component::EnvironmentalSubsystem; +our @ISA = qw(Monitoring::GLPlugin::SNMP::Item); +use strict; + +sub init { + my $self = shift; + $self->get_snmp_tables('ELTEX-MIB', [ + ['fans', 'eltexFanTable', 'Classes::Eltex::Access::Component::EnvironmentalSubsystem::Fan'], + ['temperatures', 'eltexSensorTable', 'Classes::Eltex::Access::Component::EnvironmentalSubsystem::Temperature'] + ]); +} + +sub check { + my $self = shift; + foreach (@{$self->{fans}}, @{$self->{temperatures}}) { + $_->check(); + } +} +package Classes::Eltex::Access::Component::EnvironmentalSubsystem::Fan; +our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem); +use strict; + +sub check { + my $self = shift; + $self->add_info(sprintf '%s is %s', + $self->{eltexFanDescription}, $self->{eltexFanStatus}); + if ($self->{eltexFanStatus} eq 'normal') { + $self->add_ok(); + } elsif ($self->{eltexFanStatus} eq 'notPresent') { + $self->add_warning(); + } elsif ($self->{eltexFanStatus} eq 'unknown') { + $self->add(); # Actually fan is not present on device, but in index... + } +} + +package Classes::Eltex::Access::Component::EnvironmentalSubsystem::Temperature; +our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem); +use strict; + +sub check { + my $self = shift; + $self->add_info(sprintf 'sensor %s is %s°C', + $self->{eltexSensorDescription}, $self->{eltexSensorStatus}); + $self->set_thresholds(warning => 55, critical => 65); + $self->add_message($self->check_thresholds($self->{eltexSensorStatus})); + $self->add_perfdata( + label => 'sensor_'.$self->{eltexSensorDescription}.'_temp', + value => $self->{eltexSensorStatus}, + uom => '°C', + ); +} diff --git a/plugins-scripts/Classes/Eltex/Aggregation.pm b/plugins-scripts/Classes/Eltex/Aggregation.pm new file mode 100644 index 00000000..97c24c2d --- /dev/null +++ b/plugins-scripts/Classes/Eltex/Aggregation.pm @@ -0,0 +1,25 @@ +package Classes::Eltex::Aggregation; +our @ISA = qw(Classes::Eltex); +use strict; + +# MES2324B: 2 PSU, no FAN +# MES2324F, MES2324FB: 2 PSU, 4 FAN +# MES3108, MES3116, MES3124, MES3224: 2 PSU, 4 FAN +# MES5324: 2 PSU, 4 FAN + +sub init { + my $self = shift; + if ($self->mode =~ /device::hardware::load/) { + $self->analyze_and_check_cpu_subsystem('Classes::Eltex::MES::Component::CpuSubsystem'); + } elsif ($self->mode =~ /device::hardware::health/) { + $self->analyze_and_check_environmental_subsystem('Classes::Eltex::Aggregation::Component::EnvironmentalSubsystem'); + if (! $self->check_messages()) { + $self->clear_messages(0); + $self->add_ok('environmental hardware working fine'); + } + } elsif ($self->mode =~ /device::ha::status/) { + $self->analyze_and_check_ha_subsystem('Classes::Eltex::MES::Component::HaSubsystem'); + } else { + $self->no_such_mode(); + } +} diff --git a/plugins-scripts/Classes/Eltex/Aggregation/Component/EnvironmentalSubsystem.pm b/plugins-scripts/Classes/Eltex/Aggregation/Component/EnvironmentalSubsystem.pm new file mode 100644 index 00000000..099fcede --- /dev/null +++ b/plugins-scripts/Classes/Eltex/Aggregation/Component/EnvironmentalSubsystem.pm @@ -0,0 +1,68 @@ +package Classes::Eltex::Aggregation::Component::EnvironmentalSubsystem; +our @ISA = qw(Monitoring::GLPlugin::SNMP::Item); +use strict; + +sub init { + my $self = shift; + $self->get_snmp_tables('ELTEX-MIB', [ + ['fans', 'eltexFanTable', 'Classes::Eltex::Aggregation::Component::EnvironmentalSubsystem::Fan'], + ['temperatures', 'eltexSensorTable', 'Classes::Eltex::Aggregation::Component::EnvironmentalSubsystem::Temperature'], + ['power', 'eltexPowerSupplyTable', 'Classes::Eltex::Aggregation::Component::EnvironmentalSubsystem::Power'], + ]); +} + +sub check { + my $self = shift; + foreach (@{$self->{fans}}, @{$self->{temperatures}}, @{$self->{power}}) { + $_->check(); + } +} + +package Classes::Eltex::Aggregation::Component::EnvironmentalSubsystem::Fan; +our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem); +use strict; + +sub check { + my $self = shift; + $self->add_info(sprintf '%s is %s', + $self->{eltexFanDescription}, $self->{eltexFanStatus}); + if ($self->{eltexFanStatus} eq 'normal') { + $self->add_ok(); + } elsif ($self->{eltexFanStatus} eq 'notPresent') { + $self->add_warning(); + } +} + +package Classes::Eltex::Aggregation::Component::EnvironmentalSubsystem::Temperature; +our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem); +use strict; + +sub check { + my $self = shift; + $self->add_info(sprintf 'sensor %s is %s°C', + $self->{eltexSensorDescription}, $self->{eltexSensorStatus}); + $self->set_thresholds(warning => 55, critical => 65); + $self->add_message($self->check_thresholds($self->{eltexSensorStatus})); + $self->add_perfdata( + label => 'sensor_'.$self->{eltexSensorDescription}.'_temp', + value => $self->{eltexSensorStatus}, + uom => '°C', + ); +} + +package Classes::Eltex::Aggregation::Component::EnvironmentalSubsystem::Power; +our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem); +use strict; + +sub check { + my $self = shift; + $self->add_info(sprintf '%s is %s', + $self->{eltexPowerSupplyDescription}, $self->{eltexPowerSupplyStatus}); + if ($self->{eltexPowerSupplyStatus} eq 'normal') { + $self->add_ok(); + } elsif ($self->{eltexPowerSupplyStatus} eq 'notPresent') { + $self->add_warning(); + } elsif ($self->{eltexPowerSupplyStatus} eq 'notFunctioning') { + $self->add_critical(); + } +} diff --git a/plugins-scripts/Classes/Eltex/MES/Component/CpuSubsystem.pm b/plugins-scripts/Classes/Eltex/MES/Component/CpuSubsystem.pm new file mode 100644 index 00000000..a2f9e5e3 --- /dev/null +++ b/plugins-scripts/Classes/Eltex/MES/Component/CpuSubsystem.pm @@ -0,0 +1,34 @@ +package Classes::Eltex::MES::Component::CpuSubsystem; +our @ISA = qw(Monitoring::GLPlugin::SNMP::Item); +use strict; + +sub init { + my $self = shift; + $self->get_snmp_objects('ELTEX-MIB', (qw( + eltexCpuUtilisationLastSecond eltexCpuUtilisationOneMinute + eltexCpuUtilisationFiveMinutes))); +} + +sub check { + my $self = shift; + $self->add_info(sprintf 'cpu usage is %s%%', + $self->{eltexCpuUtilisationLastSecond}); + $self->set_thresholds(warning => 50, critical => 90); + $self->add_message($self->check_thresholds( + $self->{eltexCpuUtilisationLastSecond})); + $self->add_perfdata( + label => 'cpu_usage', + value => $self->{eltexCpuUtilisationLastSecond}, + uom => '%', + ); + $self->add_perfdata( + label => 'cpu_usage_one_minute', + value => $self->{eltexCpuUtilisationOneMinute}, + uom => '%', + ); + $self->add_perfdata( + label => 'cpu_usage_five_minutes', + value => $self->{eltexCpuUtilisationFiveMinutes}, + uom => '%', + ); +} diff --git a/plugins-scripts/Classes/Eltex/MES/Component/HaSubsystem.pm b/plugins-scripts/Classes/Eltex/MES/Component/HaSubsystem.pm new file mode 100644 index 00000000..8218cb09 --- /dev/null +++ b/plugins-scripts/Classes/Eltex/MES/Component/HaSubsystem.pm @@ -0,0 +1,29 @@ +package Classes::Eltex::MES::Component::HaSubsystem; +our @ISA = qw(Monitoring::GLPlugin::SNMP::Item); +use strict; + +sub init { + my $self = shift; + $self->get_snmp_objects('ELTEX-MIB', (qw(eltexStackUnitsNumber))); +} + +# Specify threshold values, so that you understand when the number of units +# decreases, for example we have only 2 units in stack, so we should get +# warning state if one of unit goes down: +# ./check_nwc_health --hostname 10.10.10.2 --mode ha-status --warning 2: +# OK - stack have 2 units | 'units'=2;2:;0:;; +# and when only one unit left: +# WARNING - stack have 1 units | 'units'=1;2:;0:;; + +sub check { + my $self = shift; + $self->add_info(sprintf 'stack have %s units', + $self->{eltexStackUnitsNumber}); + $self->set_thresholds(warning => '0:', critical => '0:'); + $self->add_message($self->check_thresholds( + $self->{eltexStackUnitsNumber})); + $self->add_perfdata( + label => 'units', + value => $self->{eltexStackUnitsNumber}, + ); +} diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am index 1b6847bc..14ae2375 100644 --- a/plugins-scripts/Makefile.am +++ b/plugins-scripts/Makefile.am @@ -54,6 +54,7 @@ GL_MODULES=\ ../GLPlugin/lib/Monitoring/GLPlugin/SNMP/MibsAndOids/CISCOVTPMIB.pm \ ../GLPlugin/lib/Monitoring/GLPlugin/SNMP/MibsAndOids/CLAVISTERMIB.pm \ ../GLPlugin/lib/Monitoring/GLPlugin/SNMP/MibsAndOids/DISKMIB.pm \ + ../GLPlugin/lib/Monitoring/GLPlugin/SNMP/MibsAndOids/ELTEXMIB.pm \ ../GLPlugin/lib/Monitoring/GLPlugin/SNMP/MibsAndOids/ENTITYMIB.pm \ ../GLPlugin/lib/Monitoring/GLPlugin/SNMP/MibsAndOids/ENTITYSENSORMIB.pm \ ../GLPlugin/lib/Monitoring/GLPlugin/SNMP/MibsAndOids/ENTITYSTATEMIB.pm \ @@ -375,6 +376,13 @@ EXTRA_MODULES=\ Classes/PaloAlto.pm \ Classes/Bluecoat.pm \ Classes/Cumulus.pm \ + Classes/Eltex/Access/Component/EnvironmentalSubsystem.pm \ + Classes/Eltex/Access.pm \ + Classes/Eltex/Aggregation/Component/EnvironmentalSubsystem.pm \ + Classes/Eltex/Aggregation.pm \ + Classes/Eltex/MES/Component/CpuSubsystem.pm \ + Classes/Eltex/MES/Component/HaSubsystem.pm \ + Classes/Eltex.pm \ Classes/Netgear.pm \ Classes/Lantronix.pm \ Classes/Lantronix/SLS.pm \ @@ -438,4 +446,3 @@ $(libexec_SCRIPTS) : $(EXTRA_DIST) $(ECHO) "package main;" >> $@ $(CAT) $(libexec_SCRIPTS).pl | $(AWK) -f ./subst >> $@ chmod +x $@ -