From 07d3bb5fa23b27373e88093368e0c8acb5d5995d Mon Sep 17 00:00:00 2001 From: cgagnaire Date: Wed, 11 Jul 2018 17:09:09 +0200 Subject: [PATCH] fix peplink silverpeak plugins typos (#1045) * fix peplink plugin typos * fix silverpeak plugin typos --- network/peplink/balance/snmp/mode/cpu.pm | 2 +- network/peplink/balance/snmp/mode/memory.pm | 2 +- network/peplink/balance/snmp/plugin.pm | 8 ++++---- network/silverpeak/snmp/mode/alarms.pm | 7 +++---- network/silverpeak/snmp/mode/status.pm | 5 ++--- network/silverpeak/snmp/mode/uptime.pm | 22 ++++++++++----------- network/silverpeak/snmp/plugin.pm | 10 +++++----- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/network/peplink/balance/snmp/mode/cpu.pm b/network/peplink/balance/snmp/mode/cpu.pm index da22587af..8724c3815 100644 --- a/network/peplink/balance/snmp/mode/cpu.pm +++ b/network/peplink/balance/snmp/mode/cpu.pm @@ -82,7 +82,7 @@ __END__ =head1 MODE -Check cpu usage (DEVICE.mib). +Check cpu usage (PEPLINK-BALANCE-MIB). =over 8 diff --git a/network/peplink/balance/snmp/mode/memory.pm b/network/peplink/balance/snmp/mode/memory.pm index a2e624d26..54a78b0d3 100644 --- a/network/peplink/balance/snmp/mode/memory.pm +++ b/network/peplink/balance/snmp/mode/memory.pm @@ -97,7 +97,7 @@ __END__ =head1 MODE -Check memory usage (Device.mib). +Check memory usage (PEPLINK-BALANCE-MIB). =over 8 diff --git a/network/peplink/balance/snmp/plugin.pm b/network/peplink/balance/snmp/plugin.pm index ad8537c6d..22d869e6b 100644 --- a/network/peplink/balance/snmp/plugin.pm +++ b/network/peplink/balance/snmp/plugin.pm @@ -31,10 +31,10 @@ sub new { $self->{version} = '0.1'; %{$self->{modes}} = ( - 'cpu' => 'network::peplink::balance::snmp::mode::cpu', - 'memory' => 'network::peplink::balance::snmp::mode::memory', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'cpu' => 'network::peplink::balance::snmp::mode::cpu', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::peplink::balance::snmp::mode::memory', ); return $self; diff --git a/network/silverpeak/snmp/mode/alarms.pm b/network/silverpeak/snmp/mode/alarms.pm index 525ded718..24dec2003 100644 --- a/network/silverpeak/snmp/mode/alarms.pm +++ b/network/silverpeak/snmp/mode/alarms.pm @@ -28,7 +28,6 @@ use POSIX; use centreon::plugins::misc; use centreon::plugins::statefile; - my $instance_mode; sub custom_status_threshold { @@ -44,7 +43,7 @@ sub custom_status_threshold { eval "$instance_mode->{option_results}->{critical_status}") { $status = 'critical'; } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && - eval "$instance_mode->{option_results}->{warning_status}") { + eval "$instance_mode->{option_results}->{warning_status}") { $status = 'warning'; } }; @@ -74,7 +73,6 @@ sub custom_status_calc { return 0; } - sub set_counters { my ($self, %options) = @_; @@ -86,7 +84,8 @@ sub set_counters { $self->{maps_counters}->{alarm} = [ { label => 'status', threshold => 0, set => { - key_values => [ { name => 'spsActiveAlarmSource' }, { name => 'spsActiveAlarmDescr' }, { name => 'since' }, { name => 'spsActiveAlarmSeverity' }, { name => 'spsActiveAlarmLogTime' } ], + key_values => [ { name => 'spsActiveAlarmSource' }, { name => 'spsActiveAlarmDescr' }, + { name => 'since' }, { name => 'spsActiveAlarmSeverity' }, { name => 'spsActiveAlarmLogTime' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, diff --git a/network/silverpeak/snmp/mode/status.pm b/network/silverpeak/snmp/mode/status.pm index 1dfe34d7f..1cf06206b 100644 --- a/network/silverpeak/snmp/mode/status.pm +++ b/network/silverpeak/snmp/mode/status.pm @@ -38,7 +38,7 @@ sub custom_status_threshold { eval "$instance_mode->{option_results}->{critical_status}") { $status = 'critical'; } elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' && - eval "$instance_mode->{option_results}->{warning_status}") { + eval "$instance_mode->{option_results}->{warning_status}") { $status = 'warning'; } }; @@ -79,7 +79,6 @@ sub set_counters { ]; } - sub new { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -141,7 +140,7 @@ Trigger warning on %{operStatus} values =item B<--critical-status> Trigger critical on %{operStatus} values -(default: '%{operStatus} !~ /(Normal)/') +(Default: '%{operStatus} !~ /(Normal)/') =back diff --git a/network/silverpeak/snmp/mode/uptime.pm b/network/silverpeak/snmp/mode/uptime.pm index 72a28f5ee..8c81ba104 100644 --- a/network/silverpeak/snmp/mode/uptime.pm +++ b/network/silverpeak/snmp/mode/uptime.pm @@ -40,7 +40,7 @@ sub new { "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, "force-oid:s" => { name => 'force_oid' }, - "check-overload" => { name => 'check_overload' }, + "check-overflow" => { name => 'check_overflow' }, }); $self->{statefile_cache} = centreon::plugins::statefile->new(%options); @@ -63,17 +63,17 @@ sub check_options { $self->{statefile_cache}->check_options(%options); } -sub check_overload { +sub check_overflow { my ($self, %options) = @_; - return $options{timeticks} if (!defined($self->{option_results}->{check_overload})); + return $options{timeticks} if (!defined($self->{option_results}->{check_overflow})); my $current_time = floor(time() * 100); - $self->{new_datas} = { last_time => $current_time, uptime => $options{timeticks}, overload => 0 }; + $self->{new_datas} = { last_time => $current_time, uptime => $options{timeticks}, overflow => 0 }; $self->{statefile_cache}->read(statefile => "cache_" . $self->{snmp}->get_hostname() . '_' . $self->{snmp}->get_port() . '_' . $self->{mode}); my $old_uptime = $self->{statefile_cache}->get(name => 'uptime'); my $last_time = $self->{statefile_cache}->get(name => 'last_time'); - my $overload = $self->{statefile_cache}->get(name => 'overload'); + my $overflow = $self->{statefile_cache}->get(name => 'overflow'); if (defined($old_uptime) && $old_uptime < $current_time) { my $diff_time = $current_time - $last_time; @@ -82,12 +82,12 @@ sub check_overload { if ($division >= 1 && $overflow >= ($options{timeticks} - 5000) && $overflow <= ($options{timeticks} + 5000)) { - $overload++; + $overflow++; } - $options{timeticks} += ($overload * 4294967296); + $options{timeticks} += ($overflow * 4294967296); } - $self->{new_datas}->{overload} = $overload if (defined($overload)); + $self->{new_datas}->{overflow} = $overflow if (defined($overflow)); $self->{statefile_cache}->write(data => $self->{new_datas}); return $options{timeticks}; @@ -97,7 +97,7 @@ sub run { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; - # spsSystemUptime from SILVERPEAK-MGMT-MIB 8.0 + # spsSystemUptime from SILVERPEAK-MGMT-MIB 8.0 my $oid_hrSystemUptime = '.1.3.6.1.4.1.23867.3.1.1.1.5.0'; my ($result, $value); @@ -109,7 +109,7 @@ sub run { $value = $result->{$oid_hrSystemUptime}; } - $value = $self->check_overload(timeticks => $value); + $value = $self->check_overflow(timeticks => $value); $value = floor($value / 100); my $exit_code = $self->{perfdata}->threshold_check(value => $value, @@ -150,7 +150,7 @@ Threshold critical in seconds. Can choose your oid (numeric format only). -=item B<--check-overload> +=item B<--check-overflow> Uptime counter limit is 4294967296 and overflow. With that option, we manage the counter going back. But there is a few chance we can miss a reboot. diff --git a/network/silverpeak/snmp/plugin.pm b/network/silverpeak/snmp/plugin.pm index e030c5fb7..dedc87f10 100644 --- a/network/silverpeak/snmp/plugin.pm +++ b/network/silverpeak/snmp/plugin.pm @@ -31,11 +31,11 @@ sub new { $self->{version} = '1.0'; %{$self->{modes}} = ( - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'uptime' => 'network::silverpeak::snmp::mode::uptime', - 'status' => 'network::silverpeak::snmp::mode::status', - 'alarms' => 'network::silverpeak::snmp::mode::alarms', + 'alarms' => 'network::silverpeak::snmp::mode::alarms', + 'interfaces' => 'snmp_standard::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'status' => 'network::silverpeak::snmp::mode::status', + 'uptime' => 'network::silverpeak::snmp::mode::uptime', ); return $self;