diff --git a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/fan.pm b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/fan.pm index 7f0caa0ab..3526a66b1 100644 --- a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/fan.pm +++ b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/fan.pm @@ -30,7 +30,7 @@ my %map_fan_status = ( my $mapping = { boxServicesFanItemState => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.6.1.3', map => \%map_fan_status }, - boxServicesFanSpeed => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.6.1.4' }, + boxServicesFanSpeed => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.6.1.4' } }; my $oid_boxServicesFansEntry = '.1.3.6.1.4.1.4413.1.1.43.1.6.1'; @@ -52,7 +52,7 @@ sub check { next if ($oid !~ /^$mapping->{boxServicesFanItemState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_boxServicesFansEntry}, instance => $instance); - + next if ($self->check_filter(section => 'fan', instance => $instance)); if ($result->{boxServicesFanItemState} =~ /notpresent/i) { $self->absent_problem(section => 'fan', instance => $instance); @@ -60,24 +60,32 @@ sub check { } $self->{components}->{fan}->{total}++; - $self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s, speed = %s]", - $instance, $result->{boxServicesFanItemState}, $instance, defined($result->{boxServicesFanSpeed}) ? $result->{boxServicesFanSpeed} : 'unknown')); + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' status is '%s' [instance = %s, speed = %s]", + $instance, $result->{boxServicesFanItemState}, $instance, defined($result->{boxServicesFanSpeed}) ? $result->{boxServicesFanSpeed} : 'unknown' + ) + ); $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{boxServicesFanItemState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Fan '%s' status is '%s'", $instance, $result->{boxServicesFanItemState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Fan '%s' status is '%s'", $instance, $result->{boxServicesFanItemState}) + ); } - + next if (!defined($result->{boxServicesFanSpeed}) || $result->{boxServicesFanSpeed} !~ /[0-9]+/); - + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{boxServicesFanSpeed}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Fan '%s' is '%s' rpm", $instance, $result->{boxServicesFanSpeed})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Fan '%s' is '%s' rpm", $instance, $result->{boxServicesFanSpeed}) + ); } $self->{output}->perfdata_add( - label => 'fan', unit => 'rpm', nlabel => 'hardware.fan.speed.rpm', + unit => 'rpm', instances => $instance, value => $result->{boxServicesFanSpeed}, warning => $warn, diff --git a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/psu.pm b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/psu.pm index 65053a787..b332fd967 100644 --- a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/psu.pm +++ b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/psu.pm @@ -50,7 +50,7 @@ sub check { next if ($oid !~ /^$mapping->{boxServicesPowSupplyItemState}->{oid}\.(.*)$/); my $instance = $1; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{boxServicesPowSupplyItemState}->{oid}}, instance => $instance); - + next if ($self->check_filter(section => 'psu', instance => $instance)); if ($result->{boxServicesPowSupplyItemState} =~ /notpresent/i) { $self->absent_problem(section => 'psu', instance => $instance); @@ -58,12 +58,18 @@ sub check { } $self->{components}->{psu}->{total}++; - $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]", - $instance, $result->{boxServicesPowSupplyItemState}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is '%s' [instance = %s]", + $instance, $result->{boxServicesPowSupplyItemState}, $instance + ) + ); $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{boxServicesPowSupplyItemState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Power supply '%s' status is '%s'", $instance, $result->{boxServicesPowSupplyItemState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Power supply '%s' status is '%s'", $instance, $result->{boxServicesPowSupplyItemState}) + ); } } } diff --git a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/temperature.pm b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/temperature.pm index 6ea1e26b2..65a0927bc 100644 --- a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/temperature.pm +++ b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/components/temperature.pm @@ -25,18 +25,18 @@ use warnings; my %map_temp_status = ( 0 => 'low', 1 => 'normal', 2 => 'warning', 3 => 'critical', - 4 => 'shutdown', 5 => 'notpresent', 6 => 'notoperational', + 4 => 'shutdown', 5 => 'notpresent', 6 => 'notoperational' ); my $mapping = { boxServicesTempSensorState => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.8.1.4', map => \%map_temp_status }, - boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.8.1.5' }, + boxServicesTempSensorTemperature => { oid => '.1.3.6.1.4.1.4413.1.1.43.1.8.1.5' } }; my $oid_boxServicesTempSensorsEntry = '.1.3.6.1.4.1.4413.1.1.43.1.8.1'; sub load { my ($self) = @_; - + push @{$self->{request}}, { oid => $oid_boxServicesTempSensorsEntry, begin => $mapping->{boxServicesTempSensorState}->{oid}, end => $mapping->{boxServicesTempSensorTemperature}->{oid} }; } @@ -60,28 +60,36 @@ sub check { } $self->{components}->{temperature}->{total}++; - $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s, temperature = %s]", - $instance, $result->{boxServicesTempSensorState}, $instance, defined($result->{boxServicesTempSensorTemperature}) ? $result->{boxServicesTempSensorTemperature} : 'unknown')); + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' status is '%s' [instance = %s, temperature = %s]", + $instance, $result->{boxServicesTempSensorState}, $instance, defined($result->{boxServicesTempSensorTemperature}) ? $result->{boxServicesTempSensorTemperature} : 'unknown' + ) + ); $exit = $self->get_severity(section => 'temperature', value => $result->{boxServicesTempSensorState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Temperature '%s' status is '%s'", $instance, $result->{boxServicesTempSensorState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", $instance, $result->{boxServicesTempSensorState}) + ); } - + next if (!defined($result->{boxServicesTempSensorTemperature}) || $result->{boxServicesTempSensorTemperature} !~ /[0-9]+/); - + ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{boxServicesTempSensorTemperature}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Temperature '%s' is '%s' rpm", $instance, $result->{boxServicesTempSensorTemperature})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Temperature '%s' is '%s' rpm", $instance, $result->{boxServicesTempSensorTemperature}) + ); } $self->{output}->perfdata_add( - label => 'temp', unit => 'C', nlabel => 'hardware.temperature.celsius', + unit => 'C', instances => $instance, value => $result->{boxServicesTempSensorTemperature}, warning => $warn, - critical => $crit, + critical => $crit ); } } diff --git a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/cpu.pm b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/cpu.pm index a38fb2dbf..9857a667b 100644 --- a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/cpu.pm +++ b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/cpu.pm @@ -25,6 +25,12 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub prefix_cpu_output { + my ($self, %options) = @_; + + return 'CPU '; +} + sub set_counters { my ($self, %options) = @_; @@ -33,50 +39,39 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => '5s', set => { + { label => '5s', nlabel => 'cpu.utilization.5s.percentage', set => { key_values => [ { name => 'usage_5s' } ], output_template => '%.2f %% (5sec)', output_error_template => "%s (5sec)", perfdatas => [ - { label => 'cpu_5s', value => 'usage_5s', template => '%.2f', - unit => '%', min => 0, max => 100 }, - ], + { template => '%.2f', unit => '%', min => 0, max => 100 } + ] } }, - { label => '1m', set => { + { label => '1m', nlabel => 'cpu.utilization.1m.percentage', set => { key_values => [ { name => 'usage_1m' } ], output_template => '%.2f %% (1m)', output_error_template => "%s (1min)", perfdatas => [ - { label => 'cpu_1m', value => 'usage_1m', template => '%.2f', - unit => '%', min => 0, max => 100 }, - ], + { template => '%.2f', unit => '%', min => 0, max => 100 } + ] } }, - { label => '5m', set => { + { label => '5m', nlabel => 'cpu.utilization.5m.percentage', set => { key_values => [ { name => 'usage_5m' } ], output_template => '%.2f %% (5min)', output_error_template => "%s (5min)", perfdatas => [ - { label => 'cpu_5m', value => 'usage_5m', template => '%.2f', - unit => '%', min => 0, max => 100 }, - ], + { template => '%.2f', unit => '%', min => 0, max => 100 } + ] } - }, + } ]; } -sub prefix_cpu_output { - my ($self, %options) = @_; - - return "CPU "; -} - 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 => - { - }); + $options{options}->add_options(arguments => {}); return $self; } diff --git a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/hardware.pm b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/hardware.pm index 252c4c768..03e934753 100644 --- a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/hardware.pm +++ b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/hardware.pm @@ -40,7 +40,7 @@ sub set_system { ['notpowering', 'WARNING'], ['powering', 'OK'], ['nopower', 'OK'], - ['incompatible', 'WARNING'], + ['incompatible', 'WARNING'] ], temperature => [ ['low', 'OK'], @@ -49,8 +49,8 @@ sub set_system { ['critical', 'CRITICAL'], ['notpresent', 'OK'], ['shutdown', 'OK'], - ['notoperational', 'WARNING'], - ], + ['notoperational', 'WARNING'] + ] }; $self->{components_path} = 'centreon::common::broadcom::fastpath::snmp::mode::components'; @@ -66,12 +66,12 @@ sub snmp_execute { 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 => { }); - + return $self; } diff --git a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/memory.pm b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/memory.pm index 2c8c334fc..405d0d282 100644 --- a/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/memory.pm +++ b/centreon-plugins/centreon/common/broadcom/fastpath/snmp/mode/memory.pm @@ -28,17 +28,23 @@ use warnings; sub custom_usage_perfdata { my ($self, %options) = @_; - $self->{output}->perfdata_add(label => 'used', unit => 'B', - value => $self->{result_values}->{used}, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{total}, cast_int => 1), - min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + nlabel => 'memory.usage.bytes', + unit => 'B', + value => $self->{result_values}->{used}, + warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{total}, cast_int => 1), + min => 0, max => $self->{result_values}->{total} + ); } sub custom_usage_threshold { my ($self, %options) = @_; - - my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{prct_used}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]); + + my $exit = $self->{perfdata}->threshold_check( + value => $self->{result_values}->{prct_used}, + threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ] + ); return $exit; } @@ -49,11 +55,12 @@ sub custom_usage_output { my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}); my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}); - my $msg = sprintf("Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", - $total_size_value . " " . $total_size_unit, - $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, - $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); - return $msg; + return sprintf( + "Memory Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)", + $total_size_value . " " . $total_size_unit, + $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, + $total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free} + ); } sub custom_usage_calc { @@ -65,7 +72,7 @@ sub custom_usage_calc { $self->{result_values}->{used} = int($self->{result_values}->{prct_used} * $self->{result_values}->{total} / 100); $self->{result_values}->{free} = $self->{result_values}->{total} - $self->{result_values}->{used}; $self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used}; - + return 0; } @@ -82,21 +89,19 @@ sub set_counters { closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), closure_custom_perfdata => $self->can('custom_usage_perfdata'), - closure_custom_threshold_check => $self->can('custom_usage_threshold'), + closure_custom_threshold_check => $self->can('custom_usage_threshold') } - }, + } ]; } 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 => - { - }); - + + $options{options}->add_options(arguments =>{ }); + return $self; } @@ -110,7 +115,7 @@ sub manage_selection { my $total = $snmp_result->{$oid_agentSwitchCpuProcessMemAvailable} * 1024; $self->{memory} = { prct_used => ($total - $snmp_result->{$oid_agentSwitchCpuProcessMemFree} * 1024) * 100 / $total, - total => $total, + total => $total }; }