diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm index 624f557d0..bce84245b 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/fan.pm @@ -28,49 +28,73 @@ my %map_fan_state = ( 2 => 'abnormal', ); +my %map_pon_fan_state = ( + 1 => 'normal', + 2 => 'abnormal', + 3 => 'null', + 4 => 'unknown', +); + my $mapping = { raisecomFanSpeedValue => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.2' }, raisecomFanWorkState => { oid => '.1.3.6.1.4.1.8886.1.1.5.2.2.1.3', map => \%map_fan_state }, }; + +my $mapping_pon = { + raisecomFanSpeedValue => { oid => '.1.3.6.1.4.1.8886.1.27.5.1.1.4' }, + raisecomFanWorkState => { oid => '.1.3.6.1.4.1.8886.1.27.5.1.1.3', map => \%map_pon_fan_state }, +}; + + my $oid_raisecomFanMonitorStateEntry = '.1.3.6.1.4.1.8886.1.1.5.2.2.1'; +my $oid_pon_raisecomFanMonitorStateEntry = '.1.3.6.1.4.1.8886.1.27.5.1.1'; sub load { - my ($self) = @_; - - push @{$self->{request}}, { oid => $oid_raisecomFanMonitorStateEntry }; } -sub check { - my ($self) = @_; +sub check_fan { + my ($self, %options) = @_; - $self->{output}->output_add(long_msg => "Checking fans"); - $self->{components}->{fan} = {name => 'fan', total => 0, skip => 0}; - return if ($self->check_filter(section => 'fan')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomFanMonitorStateEntry}})) { + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{entry}})) { next if ($oid !~ /^$mapping->{raisecomFanWorkState}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomFanMonitorStateEntry}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $options{entry}, instance => $instance); next if ($self->check_filter(section => 'fan', instance => $instance)); $self->{components}->{fan}->{total}++; - $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance = %s]", - $instance, $result->{raisecomFanWorkState}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "Fan '%s' status is '%s' [instance: %s][speed: %s]", + $instance, + $result->{raisecomFanWorkState}, + $instance, + $result->{raisecomFanSpeedValue} + ) + ); + my $exit = $self->get_severity(section => 'fan', value => $result->{raisecomFanWorkState}); 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->{raisecomFanWorkState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Fan '%s' status is '%s'", + $instance, + $result->{raisecomFanWorkState} + ) + ); } - + my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, value => $result->{raisecomFanSpeedValue}); if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit2, - short_msg => sprintf("Fan speed '%s' is %s rpm", $instance, $result->{raisecomFanSpeedValue})); + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf("Fan speed '%s' is %s rpm", $instance, $result->{raisecomFanSpeedValue}) + ); } - + $self->{output}->perfdata_add( - label => 'fan', unit => 'rpm', + unit => 'rpm', nlabel => 'hardware.fan.speed.rpm', instances => $instance, value => $result->{raisecomFanSpeedValue}, @@ -79,6 +103,81 @@ sub check { min => 0 ); } + +} + +sub check_pon_fan { + my ($self, %options) = @_; + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{entry}})) { + next if ($oid !~ /^$mapping_pon->{raisecomFanWorkState}->{oid}\.(.*)$/); + my $fan = $slot_id . '.' . $fan_id; + my $result = $self->{snmp}->map_instance(mapping => $mapping_pon, results => $options{entry}, instance => $fan); + + next if ($self->check_filter(section => 'fan', instance => $fan_id)); + + $self->{components}->{fan}->{total}++; + $self->{output}->output_add( + long_msg => sprintf( + "Fan '%s' status is '%s' [instance: %s][speed: %s]", + $fan, + $result->{raisecomFanWorkState}, + $fan, + $result->{raisecomFanSpeedValue} + ) + ); + my $exit = $self->get_severity(section => 'fan', value => $result->{raisecomFanWorkState}); + 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'", + $fan, + $result->{raisecomFanWorkState} + ) + ); + } + + my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'fan.speed', instance => $fan, value => $result->{raisecomFanSpeedValue}); + if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit2, + short_msg => sprintf( + "Fan speed '%s' is %s rpm", + $fan, + $result->{raisecomFanSpeedValue} + ) + ); + } + + $self->{output}->perfdata_add( + unit => 'rpm', + nlabel => 'hardware.fan.speed.rpm', + instances => $fan, + value => $result->{raisecomFanSpeedValue}, + warning => $warn, + critical => $crit, + min => 0 + ); + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking fans"); + $self->{components}->{fan} = {name => 'fan', total => 0, skip => 0}; + + return if ($self->check_filter(section => 'fan')); + + my $snmp_result = $self->{snmp}->get_table(oid => $oid_raisecomFanMonitorStateEntry); + if (scalar(keys %{$snmp_result}) <= 0) { + my $snmp_result_pon = $self->{snmp}->get_table(oid => $oid_pon_raisecomFanMonitorStateEntry); + + check_pon_fan($self, entry => $snmp_result_pon) + } else { + check_fan($self, entry => $snmp_result); + } } 1; diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm index 8233d9021..9516c7590 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/temperature.pm @@ -24,36 +24,41 @@ use strict; use warnings; my $mapping = { - raisecomTemperatureValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.1' }, - raisecomTemperatureThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.5' }, - raisecomTemperatureThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.6' }, + raisecomTemperatureValue => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.1' }, + raisecomTemperatureThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.5' }, + raisecomTemperatureThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.2.6' } }; + +my $mapping_pon = { + raisecomTemperatureValue => { oid => '.1.3.6.1.4.1.8886.1.27.2.1.1.10' } +}; + my $oid_raisecomTemperatureEntry = '.1.3.6.1.4.1.8886.1.1.4.2'; -sub load { - my ($self) = @_; +my $oid_pon_raisecomShelfTemperature = '.1.3.6.1.4.1.8886.1.27.2.1.1.10'; - push @{$self->{request}}, { oid => $oid_raisecomTemperatureEntry }; +sub load { } -sub check { - my ($self) = @_; +sub check_temp { + my ($self, %options) = @_; - $self->{output}->output_add(long_msg => "Checking temperatures"); - $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; - return if ($self->check_filter(section => 'temperature')); - - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomTemperatureEntry}})) { + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{entry}})) { next if ($oid !~ /^$mapping->{raisecomTemperatureValue}->{oid}\.(.*)$/); my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomTemperatureEntry}, instance => $instance); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $options{entry}, instance => $instance); next if ($self->check_filter(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; - $self->{output}->output_add(long_msg => sprintf("temperature '%s' is %.2f C [instance: %s].", - $instance, $result->{raisecomTemperatureValue}, $instance - )); + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' is %.2f C [instance: %s].", + $instance, + $result->{raisecomTemperatureValue}, + $instance + ) + ); my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{raisecomTemperatureValue}); if ($checked == 0) { @@ -62,18 +67,30 @@ sub check { $self->{perfdata}->threshold_validate(label => 'warning-temperature-instance-' . $instance, value => $warn_th); $self->{perfdata}->threshold_validate(label => 'critical-temperature-instance-' . $instance, value => $crit_th); - $exit = $self->{perfdata}->threshold_check(value => $result->{raisecomTemperatureValue}, threshold => [ { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, - { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } ]); + $exit = $self->{perfdata}->threshold_check( + value => $result->{raisecomTemperatureValue}, + threshold => [ + { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } + ] + ); $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-temperature-instance-' . $instance); $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-temperature-instance-' . $instance); } if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Temperature '%s' is %.2f C", $instance, $result->{raisecomTemperatureValue})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Temperature '%s' is %.2f C", + $instance, + $result->{raisecomTemperatureValue} + ) + ); } + $self->{output}->perfdata_add( - label => 'temp', unit => 'C', + unit => 'C', nlabel => 'hardware.temperature.celsius', instances => $instance, value => $result->{raisecomTemperatureValue}, @@ -83,4 +100,70 @@ sub check { } } +sub check_pon_temp { + my ($self, %options) = @_; + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{entry}})) { + my $instance = (split '\.', $oid)[-1]; + my $temperature = $options{entry}->{$oid}; + + next if ($self->check_filter(section => 'temperature', instance => $instance)); + $self->{components}->{temperature}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' is %.2f C [instance: %s].", + $instance, + $temperature, + $instance + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temperature); + if ($checked == 0) { + $exit = $self->{perfdata}->threshold_check( + value => $temperature, + threshold => [ + { label => 'critical-temperature-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-temperature-instance-' . $instance, exit_litteral => 'warning' } + ] + ); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Temperature '%s' is %.2f C", + $instance, + $temperature + ) + ); + } + + $self->{output}->perfdata_add( + unit => 'C', + nlabel => 'hardware.temperature.celsius', + instances => $instance, + value => $temperature, + ); + } +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => "Checking temperatures"); + $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0}; + return if ($self->check_filter(section => 'temperature')); + + my $snmp_result = $self->{snmp}->get_table(oid => $oid_raisecomTemperatureEntry); + if (scalar(keys %{$snmp_result}) <= 0) { + my $result = $self->{snmp}->get_table(oid => $oid_pon_raisecomShelfTemperature); + check_pon_temp($self, entry => $result); + } else { + check_temp($self, entry => $snmp_result); + } +} + 1; diff --git a/centreon-plugins/network/raisecom/snmp/mode/components/voltage.pm b/centreon-plugins/network/raisecom/snmp/mode/components/voltage.pm index ff0157b21..08bf0957c 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/components/voltage.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/components/voltage.pm @@ -28,12 +28,231 @@ my $mapping = { raisecomVoltThresholdLow => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.7' }, raisecomVoltThresholdHigh => { oid => '.1.3.6.1.4.1.8886.1.1.4.3.1.1.8' }, }; +my $mapping_pon_input = { + volt => { oid => '.1.3.6.1.4.1.8886.1.27.4.1.1.9' }, # raisecomPowerInputvol + lowerThres => { oid => '.1.3.6.1.4.1.8886.1.27.4.1.1.13' }, # raisecomPowerInputvollowerThres + upperThres => { oid => '.1.3.6.1.4.1.8886.1.27.4.1.1.16' }, # raisecomPowerInputvolupperThres + inputType => { oid => '.1.3.6.1.4.1.8886.1.27.4.1.1.2' } # raisecomPowerDeviceInputType +}; +my $mapping_pon_output = { + volt => { oid => '.1.3.6.1.4.1.8886.1.27.4.2.1.3' }, # raisecomPowerOutputvol + lowerThres => { oid => '.1.3.6.1.4.1.8886.1.27.4.2.1.4' }, # raisecomPowerOutputvollowerThres + upperThres => { oid => '.1.3.6.1.4.1.8886.1.27.4.2.1.5' } # raisecomPowerOutputvolupperThres +}; + +my %mapping_input_type = ( + 1 => 'Unknown', + 2 => 'ac', + 3 => 'dc48', + 4 => 'dc24', + 5 => 'dc12', + 6 => 'null', # means power device is plugged out + 7 => 'ac220', + 8 => 'ac110' +); +my %mapping_output_type = ( + 1 => 'Other', + 2 => '3v', + 3 => '5v', # unit is 0.01V + 4 => '12v', + 5 => '-48v' # unit is 0.1V +); + my $oid_raisecomVoltEntry = '.1.3.6.1.4.1.8886.1.1.4.3.1.1'; +my $oid_PON_raisecomPowerInputEntry = '.1.3.6.1.4.1.8886.1.27.4.1.1'; +my $oid_PON_raisecomPowerOutputEntry = '.1.3.6.1.4.1.8886.1.27.4.2.1'; -sub load { - my ($self) = @_; +sub load { +} - push @{$self->{request}}, { oid => $oid_raisecomVoltEntry }; +sub check_voltage { + my ($self, %options) = @_; + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{entry}})) { # check voltage for std Raisecom device + next if ($oid !~ /^$mapping->{raisecomVoltValue}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $options{entry}, instance => $instance); + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + $self->{components}->{voltage}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "voltage '%s' is %.2f mV [instance: %s].", + $instance, + $result->{raisecomVoltValue}, + $instance + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{raisecomVoltValue}); + if ($checked == 0) { + my $warn_th = (defined($result->{raisecomVoltThresholdLow}) && $result->{raisecomVoltThresholdLow} != 0 ? $result->{raisecomVoltThresholdLow} . ':' : undef); + my $crit_th = (defined($result->{raisecomVoltThresholdHigh}) && $result->{raisecomVoltThresholdHigh} != 0 ? ':' . $result->{raisecomVoltThresholdHigh} : undef); + $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check( + value => $result->{raisecomVoltValue}, + threshold => [ + { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } + ] + ); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Voltage '%s' is %.2f mV", + $instance, + $result->{raisecomVoltValue} + ) + ); + } + + $self->{output}->perfdata_add( + unit => 'mV', + nlabel => 'hardware.voltage.millivolt', + instances => $instance, + value => $result->{raisecomVoltValue}, + warning => $warn, + critical => $crit, + ); + } +} + +sub check_voltage_input { + my ($self, %options) = @_; + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{entry}})) { # check PON input voltage + next if ($oid !~ /^$mapping_pon_input->{volt}->{oid}\.(.*)$/); + my $instance = $1; + + my $result = $self->{snmp}->map_instance(mapping => $mapping_pon_input, results => $options{entry}, instance => $instance); + my $type = $mapping_input_type{$result->{inputType}}; + $instance = 'input-' . $instance . '-' . $type; + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + $self->{components}->{voltage}->{total}++; + + $self->{output}->output_add( + long_msg => sprintf( + "Input voltage '%s' is %.2f mV [instance: %s].", + $instance, + $result->{volt}, + $instance + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{volt}); + if ($checked == 0) { + my $warn_th = (defined($result->{lowerThres}) && $result->{lowerThres} != 0 ? $result->{lowerThres} . ':' : undef); + my $crit_th = (defined($result->{upperThres}) && $result->{upperThres} != 0 ? ':' . $result->{upperThres} : undef); + $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check( + value => $result->{volt}, + threshold => [ + { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } + ] + ); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Voltage '%s' is %.2f mV", + $instance, + $result->{volt} + ) + ); + } + + $self->{output}->perfdata_add( + unit => 'mV', + nlabel => 'hardware.voltage.input.millivolt', + instances => $instance, + value => $result->{volt}, + warning => $warn, + critical => $crit, + ); + } +} + +sub check_voltage_output { + my ($self, %options) = @_; + + foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$options{entry}})) { # check PON output voltage + next if ($oid !~ /^$mapping_pon_output->{volt}->{oid}\.(.*)\.(.*)$/); + my ($index, $type) = ($1, $2); + my $instance = 'output-'. $index . '-' . $mapping_output_type{$type}; + + my $result = $self->{snmp}->map_instance(mapping => $mapping_pon_output, results => $options{entry}, instance => $index . '.' . $type); + + next if ($self->check_filter(section => 'voltage', instance => $instance)); + $self->{components}->{voltage}->{total}++; + + if ($type == 3) { + $result->{volt} *= 10; + } elsif ($type == 5) { + $result->{volt} *= 100; + } + + $self->{output}->output_add( + long_msg => sprintf( + "voltage '%s' is %.2f mV [instance: %s].", + $instance, + $result->{volt}, + $instance + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{volt}); + if ($checked == 0) { + my $warn_th = (defined($result->{lowerThres}) && $result->{lowerThres} != 0 ? $result->{lowerThres} . ':' : undef); + my $crit_th = (defined($result->{upperThres}) && $result->{upperThres} != 0 ? ':' . $result->{upperThres} : undef); + $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); + $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); + + $exit = $self->{perfdata}->threshold_check( + value => $result->{volt}, + threshold => [ + { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' }, + { label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } + ] + ); + $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); + $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance); + } + + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf( + "Voltage '%s' is %.2f mV", + $instance, + $result->{volt} + ) + ); + } + $self->{output}->perfdata_add( + unit => 'mV', + nlabel => 'hardware.voltage.output.millivolt', + instances => $instance, + value => $result->{volt}, + warning => $warn, + critical => $crit + ); + } } sub check { @@ -43,43 +262,15 @@ sub check { $self->{components}->{voltage} = {name => 'voltages', total => 0, skip => 0}; return if ($self->check_filter(section => 'voltage')); - foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_raisecomVoltEntry}})) { - next if ($oid !~ /^$mapping->{raisecomVoltValue}->{oid}\.(.*)$/); - my $instance = $1; - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_raisecomVoltEntry}, instance => $instance); + my $result = $self->{snmp}->get_table(oid => $oid_raisecomVoltEntry); + if (scalar(keys %{$result}) <= 0) { + my $result_pon_input = $self->{snmp}->get_table(oid => $oid_PON_raisecomPowerInputEntry); + my $result_pon_output = $self->{snmp}->get_table(oid => $oid_PON_raisecomPowerOutputEntry); - next if ($self->check_filter(section => 'voltage', instance => $instance)); - $self->{components}->{voltage}->{total}++; - - $self->{output}->output_add(long_msg => sprintf("voltage '%s' is %.2f mV [instance: %s].", - $instance, $result->{raisecomVoltValue}, $instance - )); - - my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{raisecomVoltValue}); - if ($checked == 0) { - my $warn_th = $result->{raisecomVoltThresholdLow} . ':'; - my $crit_th = ':' . $result->{raisecomVoltThresholdHigh}; - $self->{perfdata}->threshold_validate(label => 'warning-voltage-instance-' . $instance, value => $warn_th); - $self->{perfdata}->threshold_validate(label => 'critical-voltage-instance-' . $instance, value => $crit_th); - - $exit = $self->{perfdata}->threshold_check(value => $result->{raisecomVoltValue}, threshold => [ { label => 'critical-voltage-instance-' . $instance, exit_litteral => 'critical' }, - { label => 'warning-voltage-instance-' . $instance, exit_litteral => 'warning' } ]); - $warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-voltage-instance-' . $instance); - $crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-voltage-instance-' . $instance); - } - - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Voltage '%s' is %.2f mV", $instance, $result->{raisecomVoltValue})); - } - $self->{output}->perfdata_add( - label => 'volt', unit => 'mV', - nlabel => 'hardware.voltage.volt', - instances => $instance, - value => $result->{raisecomVoltValue}, - warning => $warn, - critical => $crit, - ); + check_voltage_input($self, entry => $result_pon_input); + check_voltage_output($self, entry => $result_pon_output); + } else { + check_voltage($self, entry => $result); } } diff --git a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm index 6d7d8ffa2..7769a21d0 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/cpu.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/cpu.pm @@ -25,68 +25,70 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub prefix_cpu_output { + my ($self, %options) = @_; + + return "CPU '" . $options{instance} . "' usage "; +} + sub set_counters { my ($self, %options) = @_; $self->{maps_counters_type} = [ - { name => 'cpu', type => 0, cb_prefix_output => 'prefix_cpu_output' } + { name => 'cpu', type => 1, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All CPU usage for every period are OK.', skipped_code => { -10 => 1 } } ]; $self->{maps_counters}->{cpu} = [ - { label => '5s', set => { + { label => '1s', nlabel => 'cpu.utilization.1s.percentage', set => { + key_values => [ { name => 'oneSec' } ], + output_template => '%.2f%% (1sec)', + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] + } + }, + { label => '5s', nlabel => 'cpu.utilization.5s.percentage', set => { key_values => [ { name => 'fiveSec' } ], output_template => '%.2f%% (5sec)', perfdatas => [ - { label => 'cpu_5s', value => 'fiveSec', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } }, - { label => '1m', set => { + { label => '1m', nlabel => 'cpu.utilization.1m.percentage', set => { key_values => [ { name => 'oneMin' } ], output_template => '%.2f%% (1min)', perfdatas => [ - { label => 'cpu_1m', value => 'oneMin', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } }, - { label => '10m', set => { + { label => '10m', nlabel => 'cpu.utilization.10m.percentage', set => { key_values => [ { name => 'tenMin' } ], output_template => '%.2f%% (10min)', perfdatas => [ - { label => 'cpu_10m', value => 'tenMin', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } }, - { label => '2h', set => { + { label => '2h', nlabel => 'cpu.utilization.2h.percentage', set => { key_values => [ { name => 'twoHour' } ], output_template => '%.2f%% (2h)', perfdatas => [ - { label => 'cpu_2h', value => 'twoHour', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1 } + ] } - }, + } ]; } -sub prefix_cpu_output { - my ($self, %options) = @_; - - return "CPU Usage "; -} - 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; } @@ -94,24 +96,46 @@ my %mapping_period = (1 => 'oneSec', 2 => 'fiveSec', 3 => 'oneMin', 4 => 'tenMin my $mapping = { raisecomCPUUtilizationPeriod => { oid => '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.2', map => \%mapping_period }, - raisecomCPUUtilization => { oid => '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3' }, + raisecomCPUUtilization => { oid => '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1.3' } +}; +my $mapping_pon = { + rcCpuUsage1Second => { oid => '.1.3.6.1.4.1.8886.18.1.7.1.1.1.3' }, + rcCpuUsage10Minutes => { oid => '.1.3.6.1.4.1.8886.18.1.7.1.1.1.4' }, + rcCpuUsage2Hours => { oid => '.1.3.6.1.4.1.8886.18.1.7.1.1.1.5' } }; my $oid_raisecomCPUUtilizationEntry = '.1.3.6.1.4.1.8886.1.1.1.5.1.1.1'; +my $oid_pon_raisecomCPUUtilizationEntry = '.1.3.6.1.4.1.8886.18.1.7.1.1.1'; sub manage_selection { my ($self, %options) = @_; + my $snmp_result = $options{snmp}->get_table(oid => $oid_raisecomCPUUtilizationEntry, nothing_quit => 0); + $self->{cpu} = {}; - my $snmp_result = $options{snmp}->get_table(oid => $oid_raisecomCPUUtilizationEntry, - nothing_quit => 1); - foreach my $oid (keys %{$snmp_result}) { - next if ($oid !~ /^$mapping->{raisecomCPUUtilization}->{oid}\.(.*)$/); - my $instance = $1; - my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); - - $self->{cpu}->{$result->{raisecomCPUUtilizationPeriod}} = $result->{raisecomCPUUtilization}; - } + if (scalar(keys %{$snmp_result}) <= 0) { + my $result = $options{snmp}->get_table(oid => $oid_pon_raisecomCPUUtilizationEntry, nothing_quit => 1); + foreach my $oid (keys %{$result}) { + next if ($oid !~ /^$mapping_pon->{rcCpuUsage1Second}->{oid}\.(.*)\.(.*)$/); + my $instance = $1; + my $mapping_result = $options{snmp}->map_instance(mapping => $mapping_pon, results => $result, instance => $instance . '.' . 0); + $self->{cpu}->{$instance} = { + oneSec => $mapping_result->{rcCpuUsage1Second}, + tenMin => $mapping_result->{rcCpuUsage10Minutes}, + twoHour => $mapping_result->{rcCpuUsage2Hours} + }; + } + } else { + $self->{cpu} = { 0 => {} }; + + foreach my $oid (keys %{$snmp_result}) { + next if ($oid !~ /^$mapping->{raisecomCPUUtilization}->{oid}\.(.*)$/); + my $instance = $1; + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance); + + $self->{cpu}->{0}->{ $result->{raisecomCPUUtilizationPeriod} } = $result->{raisecomCPUUtilization}; + } + }; } 1; @@ -132,13 +156,17 @@ Example: --filter-counters='^(1s|1m)$' =item B<--warning-*> Threshold warning. -Can be: '1s', '5s', '1m', '10m', '2h'. +Can be: '1s', '5s', '1m', '10m', '2h' for standard Raisecom devices. + +Can be: '1s', '10m', '2h' for xPON Raisecom devices. =item B<--critical-*> Threshold critical. Can be: '1s', '5s', '1m', '10m', '2h'. +Can be: '1s', '10m', '2h' for xPON Raisecom devices. + =back =cut diff --git a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm index 5699bf203..f3edbf100 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/hardware.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/hardware.pm @@ -47,12 +47,11 @@ sub snmp_execute { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; - $self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); } 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 => {}); diff --git a/centreon-plugins/network/raisecom/snmp/mode/interfaces.pm b/centreon-plugins/network/raisecom/snmp/mode/interfaces.pm new file mode 100644 index 000000000..d298d1b7a --- /dev/null +++ b/centreon-plugins/network/raisecom/snmp/mode/interfaces.pm @@ -0,0 +1,182 @@ +# +# Copyright 2022 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package network::raisecom::snmp::mode::interfaces; + +use base qw(snmp_standard::mode::interfaces); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + return $self; +} + +1; + +__END__ + +=head1 MODE + +Check interfaces. + +=over 8 + +=item B<--add-global> + +Check global port statistics (By default if no --add-* option is set). + +=item B<--add-status> + +Check interface status. + +=item B<--add-duplex-status> + +Check duplex status (with --warning-status and --critical-status). + +=item B<--add-traffic> + +Check interface traffic. + +=item B<--add-errors> + +Check interface errors. + +=item B<--add-cast> + +Check interface cast. + +=item B<--add-speed> + +Check interface speed. + +=item B<--add-volume> + +Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting). + +=item B<--check-metrics> + +If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"'). + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"'). +Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down', +'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard', +'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast', +'speed' (b/s). + +=item B<--units-traffic> + +Units of thresholds for the traffic (Default: 'percent_delta') ('percent_delta', 'bps', 'counter'). + +=item B<--units-errors> + +Units of thresholds for errors/discards (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter'). + +=item B<--units-cast> + +Units of thresholds for communication types (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter'). + +=item B<--nagvis-perfdata> + +Display traffic perfdata to be compatible with nagvis widget. + +=item B<--interface> + +Set the interface (number expected) ex: 1,2,... (empty means 'check all interface'). + +=item B<--name> + +Allows to use interface name with option --interface instead of interface oid index (Can be a regexp) + +=item B<--speed> + +Set interface speed for incoming/outgoing traffic (in Mb). + +=item B<--speed-in> + +Set interface speed for incoming traffic (in Mb). + +=item B<--speed-out> + +Set interface speed for outgoing traffic (in Mb). + +=item B<--map-speed-dsl> + +Get interface speed configuration for interface type 'adsl' and 'vdsl2'. + +Syntax: --map-speed-dsl=interface-src-name,interface-dsl-name + +E.g: --map-speed-dsl=Et0.835,Et0-vdsl2 + +=item B<--force-counters64> + +Force to use 64 bits counters only. Can be used to improve performance. + +=item B<--force-counters32> + +Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy. + +=item B<--reload-cache-time> + +Time in minutes before reloading cache file (default: 180). + +=item B<--oid-filter> + +Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr). + +=item B<--oid-display> + +Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr). + +=item B<--oid-extra-display> + +Add an OID to display. + +=item B<--display-transform-src> + +Regexp src to transform display value. + +=item B<--display-transform-dst> + +Regexp dst to transform display value. + +=item B<--show-cache> + +Display cache interface datas. + +=back + +=cut diff --git a/centreon-plugins/network/raisecom/snmp/mode/memory.pm b/centreon-plugins/network/raisecom/snmp/mode/memory.pm index 1368f0647..f5ccc92b8 100644 --- a/centreon-plugins/network/raisecom/snmp/mode/memory.pm +++ b/centreon-plugins/network/raisecom/snmp/mode/memory.pm @@ -20,76 +20,98 @@ package network::raisecom::snmp::mode::memory; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub custom_usage_output { + my ($self, %options) = @_; + + return sprintf( + 'Memory total: %s %s used: %s %s (%.2f%%) free: %s %s (%.2f%%)', + $self->{perfdata}->change_bytes(value => $self->{result_values}->{total}), + $self->{perfdata}->change_bytes(value => $self->{result_values}->{used}), + $self->{result_values}->{prct_used}, + $self->{perfdata}->change_bytes(value => $self->{result_values}->{free}), + $self->{result_values}->{prct_free} + ); +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'memory', type => 0, skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{memory} = [ + { label => 'usage', nlabel => 'memory.usage.bytes', set => { + key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-free', display_ok => 0, nlabel => 'memory.free.bytes', set => { + key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { template => '%d', min => 0, max => 'total', unit => 'B', cast_int => 1 } + ] + } + }, + { label => 'usage-prct', display_ok => 0, nlabel => 'memory.usage.percentage', set => { + key_values => [ { name => 'prct_used' }, { name => 'used' }, { name => 'free' }, { name => 'prct_free' }, { name => 'total' } ], + closure_custom_output => $self->can('custom_usage_output'), + perfdatas => [ + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] + } + } + ]; +} + 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 => - { - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::init(%options); - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } -} - -sub run { +sub manage_selection { my ($self, %options) = @_; $self->{snmp} = $options{snmp}; my $oid_raisecomAvailableMemory = '.1.3.6.1.4.1.8886.1.1.3.2.0'; my $oid_raisecomTotalMemory = '.1.3.6.1.4.1.8886.1.1.3.1.0'; + my $oid_PON_raisecomAvailableMemory = '.1.3.6.1.4.1.8886.18.1.7.3.1.1.2.1.0'; + my $oid_PON_raisecomTotalMemory = '.1.3.6.1.4.1.8886.18.1.7.3.1.1.1.1.0'; - my $oids = [$oid_raisecomAvailableMemory, $oid_raisecomTotalMemory]; + my $oids = [$oid_raisecomAvailableMemory, $oid_raisecomTotalMemory, $oid_PON_raisecomAvailableMemory, $oid_PON_raisecomTotalMemory]; - my $result = $self->{snmp}->get_leef(oids => $oids, - nothing_quit => 1); - - my $free_size = $result->{$oid_raisecomAvailableMemory}; - my $total_size = $result->{$oid_raisecomTotalMemory}; + my $result = $self->{snmp}->get_leef(oids => $oids, nothing_quit => 1); + + my $free_size = defined($result->{$oid_raisecomAvailableMemory}) ? $result->{$oid_raisecomAvailableMemory} : $result->{$oid_PON_raisecomAvailableMemory}; + my $total_size = defined($result->{$oid_raisecomTotalMemory}) ? $result->{$oid_raisecomTotalMemory} : $result->{$oid_PON_raisecomTotalMemory}; my $used_size = $total_size - $free_size; my $prct_used = $used_size * 100 / $total_size; my $prct_free = 100 - $prct_used; - my $exit = $self->{perfdata}->threshold_check(value => $prct_used, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_size); my ($used_value, $used_unit) = $self->{perfdata}->change_bytes(value => $used_size); my ($free_value, $free_unit) = $self->{perfdata}->change_bytes(value => $free_size); - - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Memory Total: %s, Used: %s (%.2f%%), Free: %s (%.2f%%)", - $total_value . " " . $total_unit, - $used_value . " " . $used_unit, $prct_used, - $free_value . " " . $free_unit, $prct_free)); - - $self->{output}->perfdata_add(label => "used", unit => 'B', - value => $used_size, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $total_size, cast_int => 1), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size, cast_int => 1), - min => 0, max => $total_size); - $self->{output}->display(); - $self->{output}->exit(); + $self->{memory} = { + total => $total_size, + used => $used_size, + free => $free_size, + prct_used => $prct_used, + prct_free => $prct_free + }; } 1; @@ -102,13 +124,10 @@ Check memory usage. =over 8 -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Threshold warning in percent. - -=item B<--critical> - -Threshold critical in percent. +Thresholds. +Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%). =back diff --git a/centreon-plugins/network/raisecom/snmp/plugin.pm b/centreon-plugins/network/raisecom/snmp/plugin.pm index 2ac40e9cb..95ddb1b2f 100644 --- a/centreon-plugins/network/raisecom/snmp/plugin.pm +++ b/centreon-plugins/network/raisecom/snmp/plugin.pm @@ -29,14 +29,13 @@ sub new { my $self = $class->SUPER::new(package => __PACKAGE__, %options); bless $self, $class; - $self->{version} = '0.1'; - %{$self->{modes}} = ( - 'cpu' => 'network::raisecom::snmp::mode::cpu', - 'hardware' => 'network::raisecom::snmp::mode::hardware', - 'interfaces' => 'snmp_standard::mode::interfaces', - 'list-interfaces' => 'snmp_standard::mode::listinterfaces', - 'memory' => 'network::raisecom::snmp::mode::memory', - ); + $self->{modes} = { + 'cpu' => 'network::raisecom::snmp::mode::cpu', + 'hardware' => 'network::raisecom::snmp::mode::hardware', + 'interfaces' => 'network::raisecom::snmp::mode::interfaces', + 'list-interfaces' => 'snmp_standard::mode::listinterfaces', + 'memory' => 'network::raisecom::snmp::mode::memory' + }; return $self; }