From 90fa9574addc8e8e0dd080806c7f9ee5436e55c8 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Fri, 19 Feb 2021 14:22:33 +0100 Subject: [PATCH] Fix #1123 (#2602) --- .../steelhead/snmp/mode/bwoptimization.pm | 37 ++-- .../steelhead/snmp/mode/bwpassthrough.pm | 27 ++- .../steelhead/snmp/mode/connections.pm | 159 ++++++++++-------- .../steelhead/snmp/mode/diskutilization.pm | 28 +-- .../steelhead/snmp/mode/loadaverage.pm | 36 ++-- .../riverbed/steelhead/snmp/mode/status.pm | 42 ++--- .../steelhead/snmp/mode/temperature.pm | 15 +- .../network/riverbed/steelhead/snmp/plugin.pm | 9 +- 8 files changed, 173 insertions(+), 180 deletions(-) diff --git a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/bwoptimization.pm b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/bwoptimization.pm index b8b02de59..c08bc29dd 100644 --- a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/bwoptimization.pm +++ b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/bwoptimization.pm @@ -39,8 +39,8 @@ sub set_counters { output_template => 'Wan2Lan on Lan: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'wan2lan_lan', template => '%s', min => 0, unit => 'B/s' }, - ], + { label => 'wan2lan_lan', template => '%s', min => 0, unit => 'B/s' } + ] } }, { label => 'wan2lan-wan', set => { @@ -48,8 +48,8 @@ sub set_counters { output_template => 'Wan2Lan on Wan: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'wan2lan_wan', template => '%s', min => 0, unit => 'B/s' }, - ], + { label => 'wan2lan_wan', template => '%s', min => 0, unit => 'B/s' } + ] } }, { label => 'lan2wan-lan', set => { @@ -57,8 +57,8 @@ sub set_counters { output_template => 'Lan2Wan on Lan: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'lan2wan_lan', template => '%s', min => 0, unit => 'B/s' }, - ], + { label => 'lan2wan_lan', template => '%s', min => 0, unit => 'B/s' } + ] } }, { label => 'lan2wan-wan', set => { @@ -66,17 +66,17 @@ sub set_counters { output_template => 'Lan2Wan on Wan: %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'lan2wan_wan', template => '%s', min => 0, unit => 'B/s' }, - ], + { label => 'lan2wan_wan', template => '%s', min => 0, unit => 'B/s' } + ] } - }, + } ]; } sub prefix_output { my ($self, %options) = @_; - - return "Optimized "; + + return 'Optimized '; } sub new { @@ -95,19 +95,19 @@ my $mappings = { bwHCAggInLan => { oid => '.1.3.6.1.4.1.17163.1.1.5.6.1.1' }, bwHCAggInWan => { oid => '.1.3.6.1.4.1.17163.1.1.5.6.1.2' }, bwHCAggOutLan => { oid => '.1.3.6.1.4.1.17163.1.1.5.6.1.3' }, - bwHCAggOutWan => { oid => '.1.3.6.1.4.1.17163.1.1.5.6.1.4' }, + bwHCAggOutWan => { oid => '.1.3.6.1.4.1.17163.1.1.5.6.1.4' } }, ex => { bwHCAggInLan => { oid => '.1.3.6.1.4.1.17163.1.51.5.6.1.1' }, bwHCAggInWan => { oid => '.1.3.6.1.4.1.17163.1.51.5.6.1.2' }, bwHCAggOutLan => { oid => '.1.3.6.1.4.1.17163.1.51.5.6.1.3' }, - bwHCAggOutWan => { oid => '.1.3.6.1.4.1.17163.1.51.5.6.1.4' }, - }, + bwHCAggOutWan => { oid => '.1.3.6.1.4.1.17163.1.51.5.6.1.4' } + } }; my $oids = { common => '.1.3.6.1.4.1.17163.1.1.5.6.1', - ex => '.1.3.6.1.4.1.17163.1.51.5.6.1', + ex => '.1.3.6.1.4.1.17163.1.51.5.6.1' }; sub manage_selection { @@ -123,13 +123,10 @@ sub manage_selection { foreach my $equipment (keys %{$oids}) { next if (!%{$results->{$oids->{$equipment}}}); - my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, - results => $results->{$oids->{$equipment}}, instance => 0); - - $self->{global} = { %$result }; + $self->{global} = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, results => $results->{$oids->{$equipment}}, instance => 0); } - $self->{cache_name} = "riverbed_steelhead_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . + $self->{cache_name} = 'riverbed_steelhead_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . md5_hex('all'); } diff --git a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/bwpassthrough.pm b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/bwpassthrough.pm index 109c52179..222c8c12e 100644 --- a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/bwpassthrough.pm +++ b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/bwpassthrough.pm @@ -39,8 +39,8 @@ sub set_counters { output_template => 'Traffic In (Wan2Lan): %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'traffic_in', template => '%s', min => 0, unit => 'B/s' }, - ], + { label => 'traffic_in', template => '%s', min => 0, unit => 'B/s' } + ] } }, { label => 'traffic-out', set => { @@ -48,33 +48,33 @@ sub set_counters { output_template => 'Traffic Out (Lan2Wan): %s %s/s', output_change_bytes => 1, perfdatas => [ - { label => 'traffic_out', template => '%s', min => 0, unit => 'B/s' }, - ], + { label => 'traffic_out', template => '%s', min => 0, unit => 'B/s' } + ] } - }, + } ]; } sub prefix_output { my ($self, %options) = @_; - return "Passthrough "; + return 'Passthrough '; } my $mappings = { common => { bwPassThroughIn => { oid => '.1.3.6.1.4.1.17163.1.1.5.3.3.1' }, - bwPassThroughOut => { oid => '.1.3.6.1.4.1.17163.1.1.5.3.3.2' }, + bwPassThroughOut => { oid => '.1.3.6.1.4.1.17163.1.1.5.3.3.2' } }, ex => { bwPassThroughIn => { oid => '.1.3.6.1.4.1.17163.1.51.5.3.3.1' }, - bwPassThroughOut => { oid => '.1.3.6.1.4.1.17163.1.51.5.3.3.2' }, - }, + bwPassThroughOut => { oid => '.1.3.6.1.4.1.17163.1.51.5.3.3.2' } + } }; my $oids = { common => '.1.3.6.1.4.1.17163.1.1.5.3.3', - ex => '.1.3.6.1.4.1.17163.1.51.5.3.3', + ex => '.1.3.6.1.4.1.17163.1.51.5.3.3' }; sub new { @@ -101,13 +101,10 @@ sub manage_selection { foreach my $equipment (keys %{$oids}) { next if (!%{$results->{$oids->{$equipment}}}); - my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, - results => $results->{$oids->{$equipment}}, instance => 0); - - $self->{global} = { %$result }; + $self->{global} = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, results => $results->{$oids->{$equipment}}, instance => 0); } - $self->{cache_name} = "riverbed_steelhead_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . + $self->{cache_name} = 'riverbed_steelhead_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . md5_hex('all'); } diff --git a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/connections.pm b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/connections.pm index 214b0ea68..944b677c6 100644 --- a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/connections.pm +++ b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/connections.pm @@ -25,6 +25,19 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub custom_optimized_output { + my ($self, %options) = @_; + + return sprintf( + "optimized total: %s used: %s (%.2f%%) free: %s (%.2f%%)", + $self->{result_values}->{max_optimized}, + $self->{result_values}->{optimized}, + $self->{result_values}->{prct_optimized}, + $self->{result_values}->{optimized_free}, + $self->{result_values}->{prct_optimized_free} + ); +} + sub set_counters { my ($self, %options) = @_; @@ -33,74 +46,83 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total', set => { - key_values => [ { name => 'totalConnections' } ], + { label => 'total', nlabel => 'connections.total.count', set => { + key_values => [ { name => 'total' } ], output_template => 'total %s', perfdatas => [ - { label => 'total', value => 'totalConnections', template => '%s', min => 0 }, - ], + { template => '%s', min => 0 } + ] } }, - { label => 'established', set => { - key_values => [ { name => 'establishedConnections' } ], + { label => 'established', nlabel => 'connections.established.count', set => { + key_values => [ { name => 'established' } ], output_template => 'established %s', perfdatas => [ - { label => 'established', value => 'establishedConnections', template => '%s', min => 0 }, - ], + { template => '%s', min => 0 } + ] } }, - { label => 'active', set => { - key_values => [ { name => 'activeConnections' } ], + { label => 'active', nlabel => 'connections.active.count', set => { + key_values => [ { name => 'active' } ], output_template => 'active %s', perfdatas => [ - { label => 'active', value => 'activeConnections', template => '%s', min => 0 }, - ], + { template => '%s', min => 0 } + ] } }, - { label => 'optimized', set => { - key_values => [ { name => 'optimizedConnections' } ], - output_template => 'optimized %s', + + { label => 'optimized', nlabel => 'connections.optimized.count', set => { + key_values => [ { name => 'optimized' }, { name => 'optimized_free' }, { name => 'prct_optimized' }, { name => 'prct_optimized_free' }, { name => 'max_optimized' } ], + closure_custom_output => $self->can('custom_optimized_output'), perfdatas => [ - { label => 'optimized', value => 'optimizedConnections', template => '%s', min => 0 }, - ], + { template => '%d', min => 0, max => 'max_optimized' } + ] } }, - { label => 'passthrough', set => { - key_values => [ { name => 'passthroughConnections' } ], + { label => 'optimized-prct', display_ok => 0, nlabel => 'connections.optimized.percentage', set => { + key_values => [ { name => 'prct_optimized' }, { name => 'optimized_free' }, { name => 'optimized' }, { name => 'prct_optimized_free' }, { name => 'max_optimized' } ], + closure_custom_output => $self->can('custom_optimized_output'), + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + }, + { label => 'passthrough', nlabel => 'connections.passthrough.count', set => { + key_values => [ { name => 'passthrough' } ], output_template => 'passthrough %s', perfdatas => [ - { label => 'passthrough', value => 'passthroughConnections', template => '%s', min => 0 }, - ], + { template => '%s', min => 0 } + ] } }, - { label => 'half-opened', set => { - key_values => [ { name => 'halfOpenedConnections' } ], + { label => 'half-opened', nlabel => 'connections.half_opened.count', set => { + key_values => [ { name => 'half_opened' } ], output_template => 'half opened %s', perfdatas => [ - { label => 'half_opened', value => 'halfOpenedConnections', template => '%s', min => 0 }, - ], + { template => '%s', min => 0 } + ] } }, - { label => 'half-closed', set => { - key_values => [ { name => 'halfClosedConnections' } ], + { label => 'half-closed', nlabel => 'connections.half_closed.count', set => { + key_values => [ { name => 'half_closed' } ], output_template => 'half closed %s', perfdatas => [ - { label => 'half_closed', value => 'halfClosedConnections', template => '%s', min => 0 }, - ], + { template => '%s', min => 0 } + ] } - }, + } ]; } sub prefix_connection_output { my ($self, %options) = @_; - return "Connections: "; + return 'Connections: '; } sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { @@ -111,48 +133,47 @@ sub new { my $mappings = { common => { - optimizedConnections => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.1' }, - passthroughConnections => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.2' }, - halfOpenedConnections => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.3' }, - halfClosedConnections => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.4' }, - establishedConnections => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.5' }, - activeConnections => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.6' }, - totalConnections => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.7' }, + max_optimized => { oid => '.1.3.6.1.4.1.17163.1.1.2.13.1' }, # shMaxConnections + optimized => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.1' }, # optimizedConnections + passthrough => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.2' }, # passthroughConnections + half_opened => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.3' }, # halfOpenedConnections + half_closed => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.4' }, # halfClosedConnections + established => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.5' }, # establishedConnections + active => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.6' }, # activeConnections + total => { oid => '.1.3.6.1.4.1.17163.1.1.5.2.7' } # totalConnections }, ex => { - optimizedConnections => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.1' }, - passthroughConnections => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.2' }, - halfOpenedConnections => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.3' }, - halfClosedConnections => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.4' }, - establishedConnections => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.5' }, - activeConnections => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.6' }, - totalConnections => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.7' }, - }, -}; - -my $oids = { - common => '.1.3.6.1.4.1.17163.1.1.5.2', - ex => '.1.3.6.1.4.1.17163.1.51.5.2', + max_optimized => { oid => '.1.3.6.1.4.1.17163.1.51.2.13.1' }, # shMaxConnections + optimized => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.1' }, # optimizedConnections + passthrough => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.2' }, # passthroughConnections + half_opened => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.3' }, # halfOpenedConnections + half_closed => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.4' }, # halfClosedConnections + established => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.5' }, # establishedConnections + active => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.6' }, # activeConnections + total => { oid => '.1.3.6.1.4.1.17163.1.51.5.2.7' } # totalConnections + } }; sub manage_selection { my ($self, %options) = @_; - my $results = $options{snmp}->get_multiple_table( + my $snmp_result = $options{snmp}->get_leef( oids => [ - { oid => $oids->{common}, start => $mappings->{common}->{optimizedConnections}->{oid}, end => $mappings->{common}->{totalConnections}->{oid} }, - { oid => $oids->{ex}, start => $mappings->{ex}->{optimizedConnections}->{oid}, end => $mappings->{ex}->{totalConnections}->{oid} } - ] + map($_->{oid} . '.0', values(%{$mappings->{common}})), + map($_->{oid} . '.0', values(%{$mappings->{ex}})) + ], + nothing_quit => 1 ); - foreach my $equipment (keys %{$oids}) { - next if (!%{$results->{$oids->{$equipment}}}); - - my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, - results => $results->{$oids->{$equipment}}, instance => 0); - - $self->{global} = { %$result }; + my $result = $options{snmp}->map_instance(mapping => $mappings->{common}, results => $snmp_result, instance => 0); + if (!defined($result->{optimized})) { + $result = $options{snmp}->map_instance(mapping => $mappings->{ex}, results => $snmp_result, instance => 0); } + + $self->{global} = $result; + $self->{global}->{optimized_free} = $result->{max_optimized} - $result->{optimized}; + $self->{global}->{prct_optimized} = $result->{optimized} * 100 / $result->{max_optimized}; + $self->{global}->{prct_optimized_free} = 100 - $self->{global}->{prct_optimized}; } 1; @@ -171,16 +192,10 @@ half opened and half closed ones (STEELHEAD-MIB and STEELHEAD-EX-MIB). Only display some counters (regexp can be used). Example: --filter-counters='^(total)$' -=item B<--warning-*> +=item B<--warning-*> B<--critical-*> -Threshold warning. -Can be: 'total', 'established', 'active', 'optimized', -'passthrough', 'half-opened', 'half-closed'. - -=item B<--critical-*> - -Threshold critical. -Can be: 'total', 'established', 'active', 'optimized', +Thresholds. +Can be: 'total', 'established', 'active', 'optimized', 'optimized-prct', 'passthrough', 'half-opened', 'half-closed'. =back diff --git a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/diskutilization.pm b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/diskutilization.pm index 76c076d8a..4de42e293 100644 --- a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/diskutilization.pm +++ b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/diskutilization.pm @@ -30,7 +30,7 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', type => 0 }, + { name => 'global', type => 0 } ]; $self->{maps_counters}->{global} = [ @@ -38,26 +38,26 @@ sub set_counters { key_values => [ { name => 'dsAveDiskUtilization' } ], output_template => 'Datastore Usage: %.2f%%', perfdatas => [ - { label => 'used', template => '%.2f', min => 0, max => 100, unit => '%' }, - ], + { label => 'used', template => '%.2f', min => 0, max => 100, unit => '%' } + ] } }, { label => 'hits', set => { key_values => [ { name => 'dsHitsTotal', per_second => 1 } ], output_template => 'Hits: %s/s', perfdatas => [ - { label => 'hits', template => '%.2f', min => 0, unit => 'hits/s' }, - ], + { label => 'hits', template => '%.2f', min => 0, unit => 'hits/s' } + ] } }, { label => 'misses', set => { key_values => [ { name => 'dsMissTotal', per_second => 1 } ], output_template => 'Misses: %s/s', perfdatas => [ - { label => 'misses', template => '%.2f', min => 0, unit => 'misses/s' }, - ], + { label => 'misses', template => '%.2f', min => 0, unit => 'misses/s' } + ] } - }, + } ]; } @@ -77,14 +77,14 @@ my $mappings = { dsHitsTotal => { oid => '.1.3.6.1.4.1.17163.1.1.5.4.1' }, dsMissTotal => { oid => '.1.3.6.1.4.1.17163.1.1.5.4.2' }, dsCostPerSegment => { oid => '.1.3.6.1.4.1.17163.1.1.5.4.3' }, - dsAveDiskUtilization => { oid => '.1.3.6.1.4.1.17163.1.1.5.4.4' }, + dsAveDiskUtilization => { oid => '.1.3.6.1.4.1.17163.1.1.5.4.4' } }, ex => { dsHitsTotal => { oid => '.1.3.6.1.4.1.17163.1.51.5.4.1' }, dsMissTotal => { oid => '.1.3.6.1.4.1.17163.1.51.5.4.2' }, dsCostPerSegment => { oid => '.1.3.6.1.4.1.17163.1.51.5.4.3' }, - dsAveDiskUtilization => { oid => '.1.3.6.1.4.1.17163.1.51.5.4.4' }, - }, + dsAveDiskUtilization => { oid => '.1.3.6.1.4.1.17163.1.51.5.4.4' } + } }; my $oids = { @@ -106,15 +106,15 @@ sub manage_selection { next if (!%{$results->{$oids->{$equipment}}}); my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, results => $results->{$oids->{$equipment}}, instance => 0); - + $self->{global} = { dsHitsTotal => $result->{dsHitsTotal}, dsMissTotal => $result->{dsMissTotal}, - dsAveDiskUtilization => $result->{dsAveDiskUtilization}, + dsAveDiskUtilization => $result->{dsAveDiskUtilization} }; } - $self->{cache_name} = "riverbed_steelhead_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . + $self->{cache_name} = 'riverbed_steelhead_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' . md5_hex('all'); } diff --git a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/loadaverage.pm b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/loadaverage.pm index c6e02f557..931894f9d 100644 --- a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/loadaverage.pm +++ b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/loadaverage.pm @@ -29,7 +29,7 @@ sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'global', type => 0 }, + { name => 'global', type => 0 } ]; $self->{maps_counters}->{global} = [ @@ -37,38 +37,35 @@ sub set_counters { key_values => [ { name => 'cpuUtil1' } ], output_template => 'CPU Average: %.2f%%', perfdatas => [ - { label => 'total_cpu_avg', value => 'cpuUtil1', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { label => 'total_cpu_avg', template => '%.2f', + min => 0, max => 100, unit => '%' } + ] } }, { label => '1min', nlabel => 'cpu.1m.usage.percentage', set => { key_values => [ { name => 'cpuLoad1' } ], output_template => 'Load 1 min: %.2f', perfdatas => [ - { label => 'load1', value => 'cpuLoad1', template => '%.2f', - min => 0 }, - ], + { label => 'load1', template => '%.2f', min => 0 } + ] } }, { label => '5min', nlabel => 'cpu.5m.usage.percentage', set => { key_values => [ { name => 'cpuLoad5' } ], output_template => 'Load 5 min: %.2f', perfdatas => [ - { label => 'load5', value => 'cpuLoad5', template => '%.2f', - min => 0 }, - ], + { label => 'load5', template => '%.2f', min => 0 } + ] } }, { label => '15min', nlabel => 'cpu.15m.usage.percentage', set => { key_values => [ { name => 'cpuLoad15' } ], output_template => 'Load 15 min: %.2f', perfdatas => [ - { label => 'load15', value => 'cpuLoad15', template => '%.2f', - min => 0 }, - ], + { label => 'load15', template => '%.2f', min => 0 } + ] } - }, + } ]; } @@ -87,26 +84,26 @@ my $mappings = { cpuLoad1 => { oid => '.1.3.6.1.4.1.17163.1.1.5.1.1' }, cpuLoad5 => { oid => '.1.3.6.1.4.1.17163.1.1.5.1.2' }, cpuLoad15 => { oid => '.1.3.6.1.4.1.17163.1.1.5.1.3' }, - cpuUtil1 => { oid => '.1.3.6.1.4.1.17163.1.1.5.1.4' }, + cpuUtil1 => { oid => '.1.3.6.1.4.1.17163.1.1.5.1.4' } }, ex => { cpuLoad1 => { oid => '.1.3.6.1.4.1.17163.1.51.5.1.1' }, cpuLoad5 => { oid => '.1.3.6.1.4.1.17163.1.51.5.1.2' }, cpuLoad15 => { oid => '.1.3.6.1.4.1.17163.1.51.5.1.3' }, - cpuUtil1 => { oid => '.1.3.6.1.4.1.17163.1.51.5.1.4' }, + cpuUtil1 => { oid => '.1.3.6.1.4.1.17163.1.51.5.1.4' } }, interceptor => { cpuLoad1 => { oid => '.1.3.6.1.4.1.17163.1.3.5.1.1' }, cpuLoad5 => { oid => '.1.3.6.1.4.1.17163.1.3.5.1.2' }, cpuLoad15 => { oid => '.1.3.6.1.4.1.17163.1.3.5.1.3' }, - cpuUtil1 => { oid => '.1.3.6.1.4.1.17163.1.3.5.1.4' }, + cpuUtil1 => { oid => '.1.3.6.1.4.1.17163.1.3.5.1.4' } }, }; my $oids = { common => '.1.3.6.1.4.1.17163.1.1.5.1', ex => '.1.3.6.1.4.1.17163.1.51.5.1', - interceptor => '.1.3.6.1.4.1.17163.1.3.5.1', + interceptor => '.1.3.6.1.4.1.17163.1.3.5.1' }; sub manage_selection { @@ -123,8 +120,7 @@ sub manage_selection { foreach my $equipment (keys %{$oids}) { next if (!%{$results->{$oids->{$equipment}}}); - my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, - results => $results->{$oids->{$equipment}}, instance => 0); + my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, results => $results->{$oids->{$equipment}}, instance => 0); $self->{global} = { cpuLoad1 => $result->{cpuLoad1} / 100, diff --git a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/status.pm b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/status.pm index b97bdfe27..326862473 100644 --- a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/status.pm +++ b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/status.pm @@ -24,15 +24,16 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; -use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); sub custom_status_output { my ($self, %options) = @_; - my $msg = sprintf("Health is '%s', Status is '%s'", + return sprintf( + "Health is '%s', Status is '%s'", $self->{result_values}->{health}, - $self->{result_values}->{status}); - return $msg; + $self->{result_values}->{status} + ); } sub custom_status_calc { @@ -50,23 +51,22 @@ sub set_counters { { name => 'global', type => 0, cb_prefix_output => 'prefix_status_output' }, ]; $self->{maps_counters}->{global} = [ - { label => 'status', threshold => 0, set => { + { label => 'status', type => 2, critical_default => '%{health} !~ /Healthy/ || %{status} !~ /running/', set => { key_values => [ { name => 'health' }, { name => 'serviceStatus' } ], closure_custom_calc => $self->can('custom_status_calc'), closure_custom_output => $self->can('custom_status_output'), closure_custom_perfdata => sub { return 0; }, - closure_custom_threshold_check => \&catalog_status_threshold, + closure_custom_threshold_check => \&catalog_status_threshold_ng } }, { label => 'uptime', set => { key_values => [ { name => 'serviceUptime' }, { name => 'serviceUptime_human' } ], output_template => 'Uptime: %s', output_use => 'serviceUptime_human', perfdatas => [ - { label => 'uptime', value => 'serviceUptime', template => '%d', - min => 0, unit => 's' }, - ], + { label => 'uptime', template => '%d', min => 0, unit => 's' } + ] } - }, + } ]; } @@ -82,42 +82,33 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{health} !~ /Healthy/ || %{status} !~ /running/' }, }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_status', 'critical_status']); -} - my $mappings = { common => { health => { oid => '.1.3.6.1.4.1.17163.1.1.2.2' }, serviceStatus => { oid => '.1.3.6.1.4.1.17163.1.1.2.3' }, - serviceUptime => { oid => '.1.3.6.1.4.1.17163.1.1.2.4' }, + serviceUptime => { oid => '.1.3.6.1.4.1.17163.1.1.2.4' } }, ex => { health => { oid => '.1.3.6.1.4.1.17163.1.51.2.2' }, serviceStatus => { oid => '.1.3.6.1.4.1.17163.1.51.2.3' }, - serviceUptime => { oid => '.1.3.6.1.4.1.17163.1.51.2.4' }, + serviceUptime => { oid => '.1.3.6.1.4.1.17163.1.51.2.4' } }, interceptor => { health => { oid => '.1.3.6.1.4.1.17163.1.3.2.2' }, serviceStatus => { oid => '.1.3.6.1.4.1.17163.1.3.2.3' }, - serviceUptime => { oid => '.1.3.6.1.4.1.17163.1.3.2.4' }, + serviceUptime => { oid => '.1.3.6.1.4.1.17163.1.3.2.4' } }, }; my $oids = { common => '.1.3.6.1.4.1.17163.1.1.2', ex => '.1.3.6.1.4.1.17163.1.51.2', - interceptor => '.1.3.6.1.4.1.17163.1.3.2', + interceptor => '.1.3.6.1.4.1.17163.1.3.2' }; sub manage_selection { @@ -134,9 +125,8 @@ sub manage_selection { foreach my $equipment (keys %{$oids}) { next if (!%{$results->{$oids->{$equipment}}}); - my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, - results => $results->{$oids->{$equipment}}, instance => 0); - + my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, results => $results->{$oids->{$equipment}}, instance => 0); + $self->{global} = { health => $result->{health}, serviceStatus => $result->{serviceStatus}, diff --git a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/temperature.pm b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/temperature.pm index 5a65eba83..d73b77be1 100644 --- a/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/temperature.pm +++ b/centreon-plugins/centreon/common/riverbed/steelhead/snmp/mode/temperature.pm @@ -38,11 +38,10 @@ sub set_counters { key_values => [ { name => 'systemTemperature' } ], output_template => 'Temperature: %.2f C', perfdatas => [ - { label => 'temperature', value => 'systemTemperature', template => '%.2f', - min => 0, unit => 'C' }, - ], + { label => 'temperature', template => '%.2f', min => 0, unit => 'C' } + ] } - }, + } ]; } @@ -63,12 +62,12 @@ my $mappings = { }, ex => { systemTemperature => { oid => '.1.3.6.1.4.1.17163.1.51.2.9' }, - }, + } }; my $oids = { common => '.1.3.6.1.4.1.17163.1.1.2.9', - ex => '.1.3.6.1.4.1.17163.1.51.2.9', + ex => '.1.3.6.1.4.1.17163.1.51.2.9' }; sub manage_selection { @@ -83,10 +82,10 @@ sub manage_selection { foreach my $equipment (keys %{$oids}) { next if (!%{$results->{$oids->{$equipment}}}); - + my $result = $options{snmp}->map_instance(mapping => $mappings->{$equipment}, results => $results->{$oids->{$equipment}}, instance => 0); - + $self->{global} = { systemTemperature => $result->{systemTemperature}, }; diff --git a/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm b/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm index 1b615bbe4..0048bfcc9 100644 --- a/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm +++ b/centreon-plugins/network/riverbed/steelhead/snmp/plugin.pm @@ -31,8 +31,7 @@ sub new { bless $self, $class; $self->{version} = '0.1'; - - %{$self->{modes}} = ( + $self->{modes} = { 'bandwidth-optimization' => 'centreon::common::riverbed::steelhead::snmp::mode::bwoptimization', 'bandwidth-passthrough' => 'centreon::common::riverbed::steelhead::snmp::mode::bwpassthrough', 'connections' => 'centreon::common::riverbed::steelhead::snmp::mode::connections', @@ -47,8 +46,8 @@ sub new { 'status' => 'centreon::common::riverbed::steelhead::snmp::mode::status', 'storage' => 'snmp_standard::mode::storage', 'temperature' => 'centreon::common::riverbed::steelhead::snmp::mode::temperature', - 'uptime' => 'snmp_standard::mode::uptime', - ); + 'uptime' => 'snmp_standard::mode::uptime' + }; return $self; } @@ -61,4 +60,4 @@ __END__ Check Riverbed SteelHead WAN optimizer using SNMP. -=cut \ No newline at end of file +=cut