diff --git a/network/acmepacket/snmp/mode/components/fan.pm b/network/acmepacket/snmp/mode/components/fan.pm index 17b522651..6a44757ff 100644 --- a/network/acmepacket/snmp/mode/components/fan.pm +++ b/network/acmepacket/snmp/mode/components/fan.pm @@ -27,7 +27,7 @@ use network::acmepacket::snmp::mode::components::resources qw($map_status); my $mapping = { apEnvMonFanStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.4.1.1.3' }, apEnvMonFanStatusValue => { oid => '.1.3.6.1.4.1.9148.3.3.1.4.1.1.4' }, - apEnvMonFanState => { oid => '.1.3.6.1.4.1.9148.3.3.1.4.1.1.5', map => $map_status }, + apEnvMonFanState => { oid => '.1.3.6.1.4.1.9148.3.3.1.4.1.1.5', map => $map_status } }; my $oid_apEnvMonFanStatusEntry = '.1.3.6.1.4.1.9148.3.3.1.4.1.1'; @@ -55,21 +55,32 @@ sub check { $self->absent_problem(section => 'fan', instance => $instance)); $self->{components}->{fan}->{total}++; - $self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s, speed = %s]", - $result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanState}, $instance, defined($result->{apEnvMonFanStatusValue}) ? $result->{apEnvMonFanStatusValue} : 'unknown')); + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' status is '%s' [instance = %s, speed = %s]", + $result->{apEnvMonFanStatusDescr}, + $result->{apEnvMonFanState}, + $instance, + defined($result->{apEnvMonFanStatusValue}) ? $result->{apEnvMonFanStatusValue} : 'unknown' + ) + ); $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{apEnvMonFanState}); 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'", $result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Fan '%s' status is '%s'", $result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanState}) + ); } ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{apEnvMonFanStatusValue}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Fan '%s' is '%s' %%", $result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanStatusValue})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Fan '%s' is '%s' %%", $result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanStatusValue}) + ); } $self->{output}->perfdata_add( - label => 'fan', unit => '%', + unit => '%', nlabel => 'hardware.fan.speed.percentage', instances => $result->{apEnvMonFanStatusDescr}, value => $result->{apEnvMonFanStatusValue}, diff --git a/network/acmepacket/snmp/mode/components/psu.pm b/network/acmepacket/snmp/mode/components/psu.pm index ad938e888..0bbd93137 100644 --- a/network/acmepacket/snmp/mode/components/psu.pm +++ b/network/acmepacket/snmp/mode/components/psu.pm @@ -26,7 +26,7 @@ use network::acmepacket::snmp::mode::components::resources qw($map_status); my $mapping = { apEnvMonPowerSupplyStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.5.1.1.3' }, - apEnvMonPowerSupplyState => { oid => '.1.3.6.1.4.1.9148.3.3.1.5.1.1.4', map => $map_status }, + apEnvMonPowerSupplyState => { oid => '.1.3.6.1.4.1.9148.3.3.1.5.1.1.4', map => $map_status } }; my $oid_apEnvMonPowerSupplyStatusEntry = '.1.3.6.1.4.1.9148.3.3.1.5.1.1'; @@ -53,12 +53,19 @@ sub check { $self->absent_problem(section => 'psu', instance => $instance)); $self->{components}->{psu}->{total}++; - $self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]", - $result->{apEnvMonPowerSupplyStatusDescr}, $result->{apEnvMonPowerSupplyState}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "power supply '%s' status is '%s' [instance = %s]", + $result->{apEnvMonPowerSupplyStatusDescr}, + $result->{apEnvMonPowerSupplyState}, $instance + ) + ); my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{apEnvMonPowerSupplyState}); 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'", $result->{apEnvMonPowerSupplyStatusDescr}, $result->{apEnvMonPowerSupplyState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Power supply '%s' status is '%s'", $result->{apEnvMonPowerSupplyStatusDescr}, $result->{apEnvMonPowerSupplyState}) + ); } } } diff --git a/network/acmepacket/snmp/mode/components/temperature.pm b/network/acmepacket/snmp/mode/components/temperature.pm index f9849d495..9f3e36b2c 100644 --- a/network/acmepacket/snmp/mode/components/temperature.pm +++ b/network/acmepacket/snmp/mode/components/temperature.pm @@ -27,7 +27,7 @@ use network::acmepacket::snmp::mode::components::resources qw($map_status); my $mapping = { apEnvMonTemperatureStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.3.1.1.3' }, apEnvMonTemperatureStatusValue => { oid => '.1.3.6.1.4.1.9148.3.3.1.3.1.1.4' }, - apEnvMonTemperatureState => { oid => '.1.3.6.1.4.1.9148.3.3.1.3.1.1.5', map => $map_status }, + apEnvMonTemperatureState => { oid => '.1.3.6.1.4.1.9148.3.3.1.3.1.1.5', map => $map_status } }; my $oid_apEnvMonTemperatureStatusEntry = '.1.3.6.1.4.1.9148.3.3.1.3.1.1'; @@ -55,22 +55,32 @@ sub check { $self->absent_problem(section => 'temperature', instance => $instance)); $self->{components}->{temperature}->{total}++; - $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s, value = %s]", - $result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureState}, $instance, - $result->{apEnvMonTemperatureStatusValue})); + $self->{output}->output_add( + long_msg => sprintf( + "temperature '%s' status is '%s' [instance = %s, value = %s]", + $result->{apEnvMonTemperatureStatusDescr}, + $result->{apEnvMonTemperatureState}, + $instance, + $result->{apEnvMonTemperatureStatusValue} + ) + ); $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{apEnvMonTemperatureState}); 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'", $result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Temperature '%s' status is '%s'", $result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureState}) + ); } ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{apEnvMonTemperatureStatusValue}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Temperature '%s' is '%s' C", $result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureStatusValue})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Temperature '%s' is '%s' C", $result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureStatusValue}) + ); } $self->{output}->perfdata_add( - label => 'temperature', unit => 'C', + unit => 'C', nlabel => 'hardware.temperature.celsius', instances => $result->{apEnvMonTemperatureStatusDescr}, value => $result->{apEnvMonTemperatureStatusValue}, diff --git a/network/acmepacket/snmp/mode/components/voltage.pm b/network/acmepacket/snmp/mode/components/voltage.pm index 43e52d060..34d8db236 100644 --- a/network/acmepacket/snmp/mode/components/voltage.pm +++ b/network/acmepacket/snmp/mode/components/voltage.pm @@ -27,7 +27,7 @@ use network::acmepacket::snmp::mode::components::resources qw($map_status); my $mapping = { apEnvMonVoltageStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.2.1.1.3' }, apEnvMonVoltageStatusValue => { oid => '.1.3.6.1.4.1.9148.3.3.1.2.1.1.4' }, - apEnvMonVoltageState => { oid => '.1.3.6.1.4.1.9148.3.3.1.2.1.1.5', map => $map_status }, + apEnvMonVoltageState => { oid => '.1.3.6.1.4.1.9148.3.3.1.2.1.1.5', map => $map_status } }; my $oid_apEnvMonVoltageStatusEntry = '.1.3.6.1.4.1.9148.3.3.1.2.1.1'; @@ -56,22 +56,32 @@ sub check { $result->{apEnvMonVoltageStatusValue} = sprintf("%.3f", $result->{apEnvMonVoltageStatusValue}); $self->{components}->{voltage}->{total}++; - $self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s, value = %s]", - $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageState}, $instance, - $result->{apEnvMonVoltageStatusValue})); + $self->{output}->output_add( + long_msg => sprintf( + "voltage '%s' status is '%s' [instance = %s, value = %s]", + $result->{apEnvMonVoltageStatusDescr}, + $result->{apEnvMonVoltageState}, + $instance, + $result->{apEnvMonVoltageStatusValue} + ) + ); $exit = $self->get_severity(label => 'default', section => 'voltage', value => $result->{apEnvMonVoltageState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Voltage '%s' status is '%s'", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Voltage '%s' status is '%s'", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageState}) + ); } ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{apEnvMonVoltageStatusValue}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Voltage '%s' is '%s' V", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageStatusValue})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Voltage '%s' is '%s' V", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageStatusValue}) + ); } $self->{output}->perfdata_add( - label => 'voltage', unit => 'V', + unit => 'V', nlabel => 'hardware.voltage.volt', instances => $result->{apEnvMonVoltageStatusDescr}, value => $result->{apEnvMonVoltageStatusValue}, diff --git a/network/acmepacket/snmp/mode/hardware.pm b/network/acmepacket/snmp/mode/hardware.pm index 74432cd89..4390b689d 100644 --- a/network/acmepacket/snmp/mode/hardware.pm +++ b/network/acmepacket/snmp/mode/hardware.pm @@ -58,7 +58,7 @@ 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 => {}); diff --git a/network/acmepacket/snmp/mode/realmusage.pm b/network/acmepacket/snmp/mode/realmusage.pm index 156cc29e5..f80151e2b 100644 --- a/network/acmepacket/snmp/mode/realmusage.pm +++ b/network/acmepacket/snmp/mode/realmusage.pm @@ -26,6 +26,12 @@ use strict; use warnings; use Digest::MD5 qw(md5_hex); +sub prefix_realm_output { + my ($self, %options) = @_; + + return "Realm '" . $options{instance_value}->{display} . "' "; +} + sub set_counters { my ($self, %options) = @_; @@ -35,115 +41,100 @@ sub set_counters { $self->{maps_counters}->{realm} = [ { label => 'current-in-sessions', nlabel => 'realm.sessions.in.current.count', set => { - key_values => [ { name => 'apSigRealmStatsCurrentActiveSessionsInbound' }, { name => 'display' } ], - output_template => 'Current Inbound Sessions : %s', + key_values => [ { name => 'current_active_sessions_inbound' }, { name => 'display' } ], + output_template => 'current inbound sessions: %s', perfdatas => [ - { label => 'current_inbound_sessions', value => 'apSigRealmStatsCurrentActiveSessionsInbound', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'current-in-sessions-rate', nlabel => 'realm.sessions.in.rate.count', set => { - key_values => [ { name => 'apSigRealmStatsCurrentSessionRateInbound' }, { name => 'display' } ], - output_template => 'Current Inbound Sessions Rate : %s/s', + key_values => [ { name => 'current_session_rate_inbound' }, { name => 'display' } ], + output_template => 'current inbound sessions rate: %s/s', perfdatas => [ - { label => 'current_inbound_sessions_rate', value => 'apSigRealmStatsCurrentSessionRateInbound', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'total-in-sessions', nlabel => 'realm.sessions.in.total.count', set => { - key_values => [ { name => 'apSigRealmStatsTotalSessionsInbound', diff => 1 }, { name => 'display' } ], - output_template => 'Total Inbound Sessions : %s', + key_values => [ { name => 'total_sessions_inbound', diff => 1 }, { name => 'display' } ], + output_template => 'total inbound sessions: %s', perfdatas => [ - { label => 'total_inbound_sessions', value => 'apSigRealmStatsTotalSessionsInbound', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'current-out-sessions', nlabel => 'realm.sessions.out.current.count', set => { - key_values => [ { name => 'apSigRealmStatsCurrentActiveSessionsOutbound' }, { name => 'display' } ], - output_template => 'Current Outbound Sessions : %s', + key_values => [ { name => 'current_active_sessions_outbound' }, { name => 'display' } ], + output_template => 'current outbound sessions: %s', perfdatas => [ - { label => 'current_outbound_sessions', value => 'apSigRealmStatsCurrentActiveSessionsOutbound', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }, + ] } }, - { label => 'current-out-sessions-rate', nlabel => 'realm.sessions.out.current.count', set => { - key_values => [ { name => 'apSigRealmStatsCurrentSessionRateOutbound' }, { name => 'display' } ], - output_template => 'Current Outbound Sessions Rate : %s/s', + { label => 'current-out-sessions-rate', nlabel => 'realm.sessions.out.rate.count', set => { + key_values => [ { name => 'current_session_rate_outbound' }, { name => 'display' } ], + output_template => 'current outbound sessions rate: %s/s', perfdatas => [ - { label => 'current_outbound_sessions_rate', value => 'apSigRealmStatsCurrentSessionRateOutbound', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'total-out-sessions', nlabel => 'realm.sessions.out.total.count', set => { - key_values => [ { name => 'apSigRealmStatsTotalSessionsOutbound', diff => 1 }, { name => 'display' } ], - output_template => 'Total Outbound Sessions : %s', + key_values => [ { name => 'total_sessions_outbound', diff => 1 }, { name => 'display' } ], + output_template => 'total outbound sessions: %s', perfdatas => [ - { label => 'total_outbound_sessions', value => 'apSigRealmStatsTotalSessionsOutbound', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'avg-qos-rfactor', nlabel => 'realm.rfactor.qos.average.count', set => { - key_values => [ { name => 'apSigRealmStatsAverageQoSRFactor' }, { name => 'display' } ], - output_template => 'Average QoS RFactor : %s', + key_values => [ { name => 'average_qos_rfactor' }, { name => 'display' } ], + output_template => 'average QoS RFactor: %s', perfdatas => [ - { label => 'avg_qos_rfactor', value => 'apSigRealmStatsAverageQoSRFactor', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'total-rfactor', nlabel => 'realm.rfactor.execeded.total.count', set => { - key_values => [ { name => 'apSigRealmStatsTotalMajorRFactorExceeded', diff => 1 }, { name => 'display' } ], - output_template => 'Total Rfactor Exceeded : %s', + key_values => [ { name => 'total_major_rfactor_exceeded', diff => 1 }, { name => 'display' } ], + output_template => 'total RFactor exceeded: %s', perfdatas => [ - { label => 'total_rfactor', value => 'apSigRealmStatsTotalMajorRFactorExceeded', template => '%s', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } -sub prefix_realm_output { - my ($self, %options) = @_; - - return "Realm '" . $options{instance_value}->{display} . "' "; -} - sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); bless $self, $class; - - $options{options}->add_options(arguments => - { - "filter-name:s" => { name => 'filter_name' }, - }); - + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + return $self; } -my $oid_apSigRealmStatsRealmName = '.1.3.6.1.4.1.9148.3.2.1.2.4.1.2'; +my $oid_realm_name = '.1.3.6.1.4.1.9148.3.2.1.2.4.1.2'; my $mapping = { - apSigRealmStatsCurrentActiveSessionsInbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.3' }, - apSigRealmStatsCurrentSessionRateInbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.4' }, - apSigRealmStatsCurrentActiveSessionsOutbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.5' }, - apSigRealmStatsCurrentSessionRateOutbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.6' }, - apSigRealmStatsTotalSessionsInbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.7' }, - apSigRealmStatsTotalSessionsOutbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.11' }, - apSigRealmStatsAverageQoSRFactor => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.24' }, - apSigRealmStatsTotalMajorRFactorExceeded => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.27' }, + current_active_sessions_inbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.3' }, # apSigRealmStatsCurrentActiveSessionsInbound + current_session_rate_inbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.4' }, # apSigRealmStatsCurrentSessionRateInbound + current_active_sessions_outbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.5' }, # apSigRealmStatsCurrentActiveSessionsOutbound + current_session_rate_outbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.6' }, # apSigRealmStatsCurrentSessionRateOutbound + total_sessions_inbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.7' }, # apSigRealmStatsTotalSessionsInbound + total_sessions_outbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.11' }, # apSigRealmStatsTotalSessionsOutbound + average_qos_rfactor => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.24' }, # apSigRealmStatsAverageQoSRFactor + total_major_rfactor_exceeded => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.27' } # apSigRealmStatsTotalMajorRFactorExceeded }; sub manage_selection { my ($self, %options) = @_; - my $snmp_result = $options{snmp}->get_table(oid => $oid_apSigRealmStatsRealmName, nothing_quit => 1); + my $snmp_result = $options{snmp}->get_table(oid => $oid_realm_name, nothing_quit => 1); $self->{realm} = {}; foreach my $oid (keys %{$snmp_result}) { $oid =~ /\.(\d+)$/; @@ -153,15 +144,14 @@ sub manage_selection { $self->{output}->output_add(long_msg => "skipping realm '" . $snmp_result->{$oid} . "'.", debug => 1); next; } - + $self->{realm}->{$instance} = { display => $snmp_result->{$oid} }; } - $options{snmp}->load(oids => [$mapping->{apSigRealmStatsCurrentActiveSessionsInbound}->{oid}, $mapping->{apSigRealmStatsCurrentSessionRateInbound}->{oid}, - $mapping->{apSigRealmStatsCurrentActiveSessionsOutbound}->{oid}, $mapping->{apSigRealmStatsCurrentSessionRateOutbound}->{oid}, - $mapping->{apSigRealmStatsTotalSessionsInbound}->{oid}, $mapping->{apSigRealmStatsTotalSessionsOutbound}->{oid}, - $mapping->{apSigRealmStatsAverageQoSRFactor}->{oid}, $mapping->{apSigRealmStatsTotalMajorRFactorExceeded}->{oid} - ], - instances => [keys %{$self->{realm}}], instance_regexp => '^(.*)$'); + $options{snmp}->load( + oids => [ map($_->{oid}, values(%$mapping)) ], + instances => [keys %{$self->{realm}}], + instance_regexp => '^(.*)$' + ); $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); foreach (keys %{$self->{realm}}) { @@ -171,13 +161,13 @@ sub manage_selection { $self->{realm}->{$_}->{$name} = $result->{$name}; } } - + if (scalar(keys %{$self->{realm}}) <= 0) { - $self->{output}->add_option_msg(short_msg => "No realm found."); + $self->{output}->add_option_msg(short_msg => 'No realm found.'); $self->{output}->option_exit(); } - - $self->{cache_name} = "acmepacket_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + + $self->{cache_name} = 'acmepacket_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/network/acmepacket/snmp/mode/sipusage.pm b/network/acmepacket/snmp/mode/sipusage.pm index 26b64a4a0..c473ae69c 100644 --- a/network/acmepacket/snmp/mode/sipusage.pm +++ b/network/acmepacket/snmp/mode/sipusage.pm @@ -25,20 +25,18 @@ use base qw(centreon::plugins::templates::counter); use strict; use warnings; use Digest::MD5 qw(md5_hex); -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 = 'Status : ' . $self->{result_values}->{status}; - return $msg; + return 'status: ' . $self->{result_values}->{status}; } -sub custom_status_calc { +sub prefix_sip_output { my ($self, %options) = @_; - - $self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_apSipSAStatsSessionAgentStatus'}; - return 0; + + return "SIP '" . $options{instance_value}->{display} . "' "; } sub set_counters { @@ -49,99 +47,79 @@ sub set_counters { ]; $self->{maps_counters}->{sip} = [ - { label => 'status', threshold => 0, set => { - key_values => [ { name => 'apSipSAStatsSessionAgentStatus' } ], - closure_custom_calc => $self->can('custom_status_calc'), + { label => 'status', type => 2, critical_default => '%{status} =~ /outOfService|constraintsViolation|inServiceTimedOut/i', set => { + key_values => [ { name => 'status' } ], 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 => 'in-sessions-rate', nlabel => 'sip.sessions.in.rate', set => { - key_values => [ { name => 'apSipSAStatsTotalSessionsInbound', per_second => 1 }, { name => 'display' } ], - output_template => 'Inbound Sessions Rate : %.2f/s', + key_values => [ { name => 'sessions_inbound', per_second => 1 }, { name => 'display' } ], + output_template => 'inbound sessions rate: %.2f/s', perfdatas => [ - { label => 'inbound_sessions_rate', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'out-sessions-rate', nlabel => 'sip.sessions.out.rate', set => { - key_values => [ { name => 'apSipSAStatsTotalSessionsOutbound', per_second => 1 }, { name => 'display' } ], - output_template => 'Outbound Sessions Rate : %.2f/s', + key_values => [ { name => 'sessions_outbound', per_second => 1 }, { name => 'display' } ], + output_template => 'outbound sessions rate: %.2f/s', perfdatas => [ - { label => 'outbound_sessions_rate', template => '%.2f', - min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'latency', nlabel => 'sip.stats.latency.milliseconds', set => { - key_values => [ { name => 'apSipSAStatsAverageLatency' }, { name => 'display' } ], - output_template => 'Average Latency : %s ms', + key_values => [ { name => 'average_latency' }, { name => 'display' } ], + output_template => 'average latency: %s ms', perfdatas => [ - { label => 'avg_latency', template => '%s', - unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } }, { label => 'asr', nlabel => 'sip.stats.asr.percentage', set => { - key_values => [ { name => 'apSipSAStatsPeriodASR' }, { name => 'display' } ], - output_template => 'Answer-to-seizure Ratio : %s %%', + key_values => [ { name => 'period_asr' }, { name => 'display' } ], + output_template => 'answer-to-seizure ratio: %s %%', perfdatas => [ - { label => 'asr', template => '%s', - unit => '%', min => 0, label_extra_instance => 1, instance_use => 'display' }, - ], + { template => '%s', unit => '%', min => 0, label_extra_instance => 1, instance_use => 'display' } + ] } - }, + } ]; } -sub prefix_sip_output { - my ($self, %options) = @_; - - return "SIP '" . $options{instance_value}->{display} . "' "; -} - sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); bless $self, $class; - + $options{options}->add_options(arguments => { - 'filter-name:s' => { name => 'filter_name' }, - 'warning-status:s' => { name => 'warning_status', default => '' }, - 'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /outOfService|constraintsViolation|inServiceTimedOut/i' } + 'filter-name:s' => { name => 'filter_name' } }); return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_status', 'critical_status']); -} - my %map_status = ( 0 => 'disabled', 1 => 'outOfService', 2 => 'standby', 3 => 'inService', 4 => 'constraintsViolation', 5 => 'inServiceTimedOut', 6 => 'oosprovisionedresponse', ); -my $oid_apSipSAStatsSessionAgentHostname = '.1.3.6.1.4.1.9148.3.2.1.2.2.1.2'; +my $oid_name = '.1.3.6.1.4.1.9148.3.2.1.2.2.1.2'; # apSipSAStatsSessionAgentHostname my $mapping = { - apSipSAStatsTotalSessionsInbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.8' }, - apSipSAStatsTotalSessionsOutbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.12' }, - apSipSAStatsPeriodASR => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.19' }, - apSipSAStatsAverageLatency => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.20' }, - apSipSAStatsSessionAgentStatus => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.22', map => \%map_status }, + sessions_inbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.8' }, # apSipSAStatsTotalSessionsInbound + sessions_outbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.12' }, # apSipSAStatsTotalSessionsOutbound + period_asr => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.19' }, # apSipSAStatsPeriodASR + average_latency => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.20' }, # apSipSAStatsAverageLatency + status => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.22', map => \%map_status } # apSipSAStatsSessionAgentStatus }; sub manage_selection { my ($self, %options) = @_; - my $snmp_result = $options{snmp}->get_table(oid => $oid_apSipSAStatsSessionAgentHostname, nothing_quit => 1); + my $snmp_result = $options{snmp}->get_table(oid => $oid_name, nothing_quit => 1); $self->{sip} = {}; foreach my $oid (keys %{$snmp_result}) { $oid =~ /\.(\d+)$/; @@ -154,27 +132,27 @@ sub manage_selection { $self->{sip}->{$instance} = { display => $snmp_result->{$oid} }; } - $options{snmp}->load(oids => [$mapping->{apSipSAStatsTotalSessionsInbound}->{oid}, $mapping->{apSipSAStatsTotalSessionsOutbound}->{oid}, - $mapping->{apSipSAStatsPeriodASR}->{oid}, $mapping->{apSipSAStatsAverageLatency}->{oid}, - $mapping->{apSipSAStatsSessionAgentStatus}->{oid} - ], - instances => [keys %{$self->{sip}}], instance_regexp => '^(.*)$'); + $options{snmp}->load( + oids => [ map($_->{oid}, values(%$mapping)) ], + instances => [keys %{$self->{sip}}], + instance_regexp => '^(.*)$' + ); $snmp_result = $options{snmp}->get_leef(nothing_quit => 1); foreach (keys %{$self->{sip}}) { my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); - + foreach my $name (keys %$mapping) { $self->{sip}->{$_}->{$name} = $result->{$name}; } } - + if (scalar(keys %{$self->{sip}}) <= 0) { $self->{output}->add_option_msg(short_msg => "No SIP found."); $self->{output}->option_exit(); } - - $self->{cache_name} = "acmepacket_" . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . + + $self->{cache_name} = 'acmepacket_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); } diff --git a/network/acmepacket/snmp/mode/systemusage.pm b/network/acmepacket/snmp/mode/systemusage.pm index 7f66772e3..0479c9791 100644 --- a/network/acmepacket/snmp/mode/systemusage.pm +++ b/network/acmepacket/snmp/mode/systemusage.pm @@ -24,146 +24,161 @@ 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('replication state : %s', $self->{result_values}->{replication_state}); - return $msg; + return sprintf('replication state: %s', $self->{result_values}->{replication_state}); } -sub custom_status_calc { +sub system_long_output { my ($self, %options) = @_; - - $self->{result_values}->{replication_state} = $options{new_datas}->{$self->{instance} . '_replication_state'}; - return 0; + + return 'checking system'; } sub set_counters { my ($self, %options) = @_; - $self->{maps_counters_type} = [ - { name => 'global', type => 0, message_separator => ' - ' }, + $self->{maps_counters_type} = [ + { name => 'system', type => 3, cb_long_output => 'system_long_output', indent_long_output => ' ', + group => [ + { name => 'health', type => 0, display_short => 0, skipped_code => { -10 => 1 } }, + { name => 'cpu', type => 0, display_short => 0, skipped_code => { -10 => 1 } }, + { name => 'memory', type => 0, display_short => 0, skipped_code => { -10 => 1 } }, + { name => 'license', type => 0, display_short => 0, skipped_code => { -10 => 1 } }, + { name => 'sessions', type => 0, display_short => 0, skipped_code => { -10 => 1 } }, + { name => 'calls', type => 0, display_short => 0, skipped_code => { -10 => 1 } }, + { name => 'replication', type => 0, display_short => 0, skipped_code => { -10 => 1 } } + ] + } ]; - $self->{maps_counters}->{global} = [ + $self->{maps_counters}->{health} = [ { label => 'health-score', nlabel => 'health.score.percentage', set => { key_values => [ { name => 'health_score' } ], - output_template => 'Health Score : %.2f %%', + output_template => 'health score: %.2f %%', perfdatas => [ - { label => 'health_score', value => 'health_score', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] } - }, + } + ]; + + $self->{maps_counters}->{cpu} = [ { label => 'cpu-load', nlabel => 'cpu.utilization.percentage', set => { key_values => [ { name => 'cpu_load' } ], - output_template => 'Cpu Load : %.2f %%', + output_template => 'cpu load: %.2f %%', perfdatas => [ - { label => 'cpu_load', value => 'cpu_load', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] } - }, + } + ]; + + $self->{maps_counters}->{memory} = [ { label => 'memory-usage', nlabel => 'memory.usage.percentage', set => { key_values => [ { name => 'memory_used' } ], - output_template => 'Memory Used : %.2f %%', + output_template => 'memory used: %.2f %%', perfdatas => [ - { label => 'memory_used', value => 'memory_used', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%' } + ] } - }, + } + ]; + + $self->{maps_counters}->{license} = [ { label => 'license-usage', nlabel => 'licence.usage.percentage', set => { key_values => [ { name => 'license_used' } ], - output_template => 'License Used : %.2f %%', + output_template => 'license used: %.2f %%', perfdatas => [ - { label => 'license_used', value => 'license_used', template => '%.2f', - min => 0, max => 100, unit => '%' }, - ], + { template => '%.2f', min => 0, max => 100, unit => '%' }, + ] } - }, + } + ]; + + $self->{maps_counters}->{sessions} = [ { label => 'current-sessions', nlabel => 'sessions.current.count', set => { key_values => [ { name => 'current_sessions' } ], - output_template => 'Current Sessions : %s', + output_template => 'current sessions: %s', perfdatas => [ - { label => 'current_sessions', value => 'current_sessions', template => '%s', - min => 0 }, - ], + { template => '%s', min => 0 } + ] } - }, + } + ]; + + $self->{maps_counters}->{calls} = [ { label => 'current-calls', nlabel => 'calls.current.count', set => { key_values => [ { name => 'current_calls' } ], - output_template => 'Current Calls : %s/s', + output_template => 'current calls: %s/s', perfdatas => [ - { label => 'current_calls', value => 'current_calls', template => '%s', - unit => '/s', min => 0 }, - ], + { template => '%s', unit => '/s', min => 0 } + ] } - }, - { label => 'replication-status', threshold => 0, set => { + } + ]; + + $self->{maps_counters}->{replication} = [ + { label => 'replication-status', type => 2, critical_default => '%{replication_state} =~ /outOfService/i', set => { key_values => [ { name => 'replication_state' }, ], - 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 } - }, + } ]; } 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-replication-status:s" => { name => 'warning_replication_status', default => '' }, - "critical-replication-status:s" => { name => 'critical_replication_status', default => '%{replication_state} =~ /outOfService/i' }, - }); - + + $options{options}->add_options(arguments => { + }); + return $self; } -sub check_options { - my ($self, %options) = @_; - $self->SUPER::check_options(%options); - - $self->change_macros(macros => ['warning_replication_status', 'critical_replication_status']); -} - sub manage_selection { my ($self, %options) = @_; - - my %mapping_redundancy = ( + + my $mapping_redundancy = { 0 => 'unknown', 1 => 'initial', 2 => 'active', 3 => 'standby', 4 => 'outOfService', 5 => 'unassigned', 6 => 'activePending', - 7 => 'standbyPending', 8 => 'outOfServicePending', 9 => 'recovery', + 7 => 'standbyPending', 8 => 'outOfServicePending', 9 => 'recovery' + }; + my $mapping = { + cpu_load => { oid => '.1.3.6.1.4.1.9148.3.2.1.1.1' }, # apSysCPUUtil + memory_used => { oid => '.1.3.6.1.4.1.9148.3.2.1.1.2' }, # apSysMemoryUtil + health_score => { oid => '.1.3.6.1.4.1.9148.3.2.1.1.3' }, # apSysHealthScore + replication_state => { oid => '.1.3.6.1.4.1.9148.3.2.1.1.4', map => $mapping_redundancy }, # apSysRedundancy + current_sessions => { oid => '.1.3.6.1.4.1.9148.3.2.1.1.5' }, # apSysGlobalConSess + current_calls => { oid => '.1.3.6.1.4.1.9148.3.2.1.1.6' }, # apSysGlobalCPS + license_used => { oid => '.1.3.6.1.4.1.9148.3.2.1.1.10' } # apSysLicenseCapacity + }; + + my $snmp_result = $options{snmp}->get_leef( + oids => [ map($_->{oid} . '.0', values(%$mapping)) ], + nothing_quit => 1 ); + my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => 0); - my $oid_apSysCPUUtil = '.1.3.6.1.4.1.9148.3.2.1.1.1.0'; - my $oid_apSysMemoryUtil = '.1.3.6.1.4.1.9148.3.2.1.1.2.0'; - my $oid_apSysHealthScore = '.1.3.6.1.4.1.9148.3.2.1.1.3.0'; - my $oid_apSysRedundancy = '.1.3.6.1.4.1.9148.3.2.1.1.4.0'; - my $oid_apSysGlobalConSess = '.1.3.6.1.4.1.9148.3.2.1.1.5.0'; - my $oid_apSysGlobalCPS = '.1.3.6.1.4.1.9148.3.2.1.1.6.0'; - my $oid_apSysLicenseCapacity = '.1.3.6.1.4.1.9148.3.2.1.1.10.0'; - my $result = $options{snmp}->get_leef(oids => [ - $oid_apSysCPUUtil, $oid_apSysMemoryUtil, $oid_apSysHealthScore, $oid_apSysRedundancy, - $oid_apSysLicenseCapacity, $oid_apSysGlobalConSess, $oid_apSysGlobalCPS - ], - nothing_quit => 1); + $self->{output}->output_add(short_msg => 'System usage is ok'); - $self->{global} = { - cpu_load => $result->{$oid_apSysCPUUtil}, - memory_used => $result->{$oid_apSysMemoryUtil}, - replication_state => $mapping_redundancy{$result->{$oid_apSysRedundancy}}, - license_used => $result->{$oid_apSysLicenseCapacity}, - health_score => $result->{$oid_apSysHealthScore}, - current_sessions => $result->{$oid_apSysGlobalConSess}, - current_calls => $result->{$oid_apSysGlobalCPS}, + $self->{system} = { + global => { + health => { health_score => $result->{health_score} }, + cpu => { cpu_load => $result->{cpu_load} }, + memory => { memory_used => $result->{memory_used} }, + license => { license_used => $result->{license_used} }, + sessions => { current_sessions => $result->{current_sessions} }, + calls => { current_calls => $result->{current_calls} }, + replication => { replication_state => $result->{replication_state} } + } }; } diff --git a/network/acmepacket/snmp/plugin.pm b/network/acmepacket/snmp/plugin.pm index aa0895967..97752d8a5 100644 --- a/network/acmepacket/snmp/plugin.pm +++ b/network/acmepacket/snmp/plugin.pm @@ -30,7 +30,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - %{$self->{modes}} = ( + $self->{modes} = { 'hardware' => 'network::acmepacket::snmp::mode::hardware', 'interfaces' => 'snmp_standard::mode::interfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces', @@ -38,8 +38,8 @@ sub new { 'list-sip' => 'network::acmepacket::snmp::mode::listsip', 'realm-usage' => 'network::acmepacket::snmp::mode::realmusage', 'sip-usage' => 'network::acmepacket::snmp::mode::sipusage', - 'system-usage' => 'network::acmepacket::snmp::mode::systemusage', - ); + 'system-usage' => 'network::acmepacket::snmp::mode::systemusage' + }; return $self; } diff --git a/storage/overland/neo/snmp/mode/components/drive.pm b/storage/overland/neo/snmp/mode/components/drive.pm index 6761d6b6f..80365ab89 100644 --- a/storage/overland/neo/snmp/mode/components/drive.pm +++ b/storage/overland/neo/snmp/mode/components/drive.pm @@ -23,17 +23,17 @@ package storage::overland::neo::snmp::mode::components::drive; use strict; use warnings; -my %map_state = ( +my $map_state = { 0 => 'initializedNoError', 1 => 'initializedWithError', 2 => 'notInitialized', 3 => 'notInstalled', - 4 => 'notInserted', -); + 4 => 'notInserted' +}; my $mapping = { - dstState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.3', map => \%map_state }, - dstSerialNum => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.8' }, + dstState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.3', map => $map_state }, + dstSerialNum => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.8' } }; my $oid_driveStatusEntry = '.1.3.6.1.4.1.3351.1.3.2.3.1.1'; @@ -46,8 +46,8 @@ sub load { sub check { my ($self) = @_; - $self->{output}->output_add(long_msg => "Checking drives"); - $self->{components}->{drive} = {name => 'drives', total => 0, skip => 0}; + $self->{output}->output_add(long_msg => 'Checking drives'); + $self->{components}->{drive} = { name => 'drives', total => 0, skip => 0 }; return if ($self->check_filter(section => 'drive')); # there is no instance for the table. Weird. Need to manage the two cases. @@ -55,20 +55,28 @@ sub check { next if ($oid !~ /^$mapping->{dstState}->{oid}(?:\.(.*)|$)/); my $instance = defined($1) ? $1 : undef; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_driveStatusEntry}, instance => $instance); - + # we set a 1 to do some filters $instance = '1' if (!defined($instance)); next if ($self->check_filter(section => 'drive', instance => $instance)); $self->{components}->{drive}->{total}++; - $self->{output}->output_add(long_msg => sprintf("drive '%s' status is '%s' [instance = %s]", - $instance, $result->{dstState}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "drive '%s' status is '%s' [instance = %s]", + $instance, + $result->{dstState}, + $instance + ) + ); my $exit = $self->get_severity(section => 'drive', instance => $instance, value => $result->{dstState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("drive '%s' status is '%s'", $instance, $result->{dstState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("drive '%s' status is '%s'", $instance, $result->{dstState}) + ); } } } -1; \ No newline at end of file +1; diff --git a/storage/overland/neo/snmp/mode/components/library.pm b/storage/overland/neo/snmp/mode/components/library.pm index 756b8ef26..6575eb6ca 100644 --- a/storage/overland/neo/snmp/mode/components/library.pm +++ b/storage/overland/neo/snmp/mode/components/library.pm @@ -23,14 +23,12 @@ package storage::overland::neo::snmp::mode::components::library; use strict; use warnings; -my %map_state = ( - 0 => 'initializing', - 1 => 'online', - 2 => 'offline', -); +my $map_state = { + 0 => 'initializing', 1 => 'online', 2 => 'offline' +}; my $mapping = { - lstLibraryState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.2.1.6', map => \%map_state }, + lstLibraryState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.2.1.6', map => $map_state } }; my $oid_libraryStatusEntry = '.1.3.6.1.4.1.3351.1.3.2.3.2.1'; @@ -43,8 +41,8 @@ sub load { sub check { my ($self) = @_; - $self->{output}->output_add(long_msg => "Checking libraries"); - $self->{components}->{library} = {name => 'libraries', total => 0, skip => 0}; + $self->{output}->output_add(long_msg => 'Checking libraries'); + $self->{components}->{library} = { name => 'libraries', total => 0, skip => 0 }; return if ($self->check_filter(section => 'library')); # there is no instance for the table. Weird. Need to manage the two cases. @@ -52,20 +50,28 @@ sub check { next if ($oid !~ /^$mapping->{lstLibraryState}->{oid}(?:\.(.*)|$)/); my $instance = defined($1) ? $1 : undef; my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryStatusEntry}, instance => $instance); - + # we set a 1 to do some filters $instance = '1' if (!defined($instance)); next if ($self->check_filter(section => 'library', instance => $instance)); $self->{components}->{library}->{total}++; - $self->{output}->output_add(long_msg => sprintf("library '%s' status is '%s' [instance = %s]", - $instance, $result->{lstLibraryState}, $instance)); + $self->{output}->output_add( + long_msg => sprintf( + "library '%s' status is '%s' [instance = %s]", + $instance, + $result->{lstLibraryState}, + $instance + ) + ); my $exit = $self->get_severity(section => 'library', instance => $instance, value => $result->{lstLibraryState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("library '%s' status is '%s'", $instance, $result->{lstLibraryState})); + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("library '%s' status is '%s'", $instance, $result->{lstLibraryState}) + ); } } } -1; \ No newline at end of file +1; diff --git a/storage/overland/neo/snmp/mode/hardware.pm b/storage/overland/neo/snmp/mode/hardware.pm index 1be04f4a1..1d92b467a 100644 --- a/storage/overland/neo/snmp/mode/hardware.pm +++ b/storage/overland/neo/snmp/mode/hardware.pm @@ -36,13 +36,13 @@ sub set_system { ['initializedWithError', 'CRITICAL'], ['notInitialized', 'WARNING'], ['notInstalled', 'OK'], - ['notInserted', 'OK'], + ['notInserted', 'OK'] ], library => [ ['initializing', 'OK'], ['online', 'OK'], - ['offline', 'CRITICAL'], - ], + ['offline', 'CRITICAL'] + ] }; $self->{components_path} = 'storage::overland::neo::snmp::mode::components'; diff --git a/storage/overland/neo/snmp/plugin.pm b/storage/overland/neo/snmp/plugin.pm index b7fa52f88..a352b8734 100644 --- a/storage/overland/neo/snmp/plugin.pm +++ b/storage/overland/neo/snmp/plugin.pm @@ -30,10 +30,10 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - %{$self->{modes}} = ( - 'hardware' => 'storage::overland::neo::snmp::mode::hardware', + $self->{modes} = { 'eventlog' => 'storage::overland::neo::snmp::mode::eventlog', - ); + 'hardware' => 'storage::overland::neo::snmp::mode::hardware' + }; return $self; }