enh(acmepacket/snmp): force new perfdata (#2723)

This commit is contained in:
qgarnier 2021-04-20 14:26:38 +02:00 committed by GitHub
parent e2e73ef797
commit 3e9f1d64bc
13 changed files with 327 additions and 292 deletions

View File

@ -27,7 +27,7 @@ use network::acmepacket::snmp::mode::components::resources qw($map_status);
my $mapping = { my $mapping = {
apEnvMonFanStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.4.1.1.3' }, 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' }, 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'; 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->absent_problem(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++; $self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is '%s' [instance = %s, speed = %s]", $self->{output}->output_add(
$result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanState}, $instance, defined($result->{apEnvMonFanStatusValue}) ? $result->{apEnvMonFanStatusValue} : 'unknown')); 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}); $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{apEnvMonFanState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Fan '%s' status is '%s'", $result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanState})); 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}); ($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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Fan '%s' is '%s' %%", $result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanStatusValue})); severity => $exit,
short_msg => sprintf("Fan '%s' is '%s' %%", $result->{apEnvMonFanStatusDescr}, $result->{apEnvMonFanStatusValue})
);
} }
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'fan', unit => '%', unit => '%',
nlabel => 'hardware.fan.speed.percentage', nlabel => 'hardware.fan.speed.percentage',
instances => $result->{apEnvMonFanStatusDescr}, instances => $result->{apEnvMonFanStatusDescr},
value => $result->{apEnvMonFanStatusValue}, value => $result->{apEnvMonFanStatusValue},

View File

@ -26,7 +26,7 @@ use network::acmepacket::snmp::mode::components::resources qw($map_status);
my $mapping = { my $mapping = {
apEnvMonPowerSupplyStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.5.1.1.3' }, 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'; 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->absent_problem(section => 'psu', instance => $instance));
$self->{components}->{psu}->{total}++; $self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("power supply '%s' status is '%s' [instance = %s]", $self->{output}->output_add(
$result->{apEnvMonPowerSupplyStatusDescr}, $result->{apEnvMonPowerSupplyState}, $instance)); 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}); my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{apEnvMonPowerSupplyState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Power supply '%s' status is '%s'", $result->{apEnvMonPowerSupplyStatusDescr}, $result->{apEnvMonPowerSupplyState})); severity => $exit,
short_msg => sprintf("Power supply '%s' status is '%s'", $result->{apEnvMonPowerSupplyStatusDescr}, $result->{apEnvMonPowerSupplyState})
);
} }
} }
} }

View File

@ -27,7 +27,7 @@ use network::acmepacket::snmp::mode::components::resources qw($map_status);
my $mapping = { my $mapping = {
apEnvMonTemperatureStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.3.1.1.3' }, 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' }, 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'; 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->absent_problem(section => 'temperature', instance => $instance));
$self->{components}->{temperature}->{total}++; $self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("temperature '%s' status is '%s' [instance = %s, value = %s]", $self->{output}->output_add(
$result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureState}, $instance, long_msg => sprintf(
$result->{apEnvMonTemperatureStatusValue})); "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}); $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{apEnvMonTemperatureState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Temperature '%s' status is '%s'", $result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureState})); 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}); ($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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Temperature '%s' is '%s' C", $result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureStatusValue})); severity => $exit,
short_msg => sprintf("Temperature '%s' is '%s' C", $result->{apEnvMonTemperatureStatusDescr}, $result->{apEnvMonTemperatureStatusValue})
);
} }
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'temperature', unit => 'C', unit => 'C',
nlabel => 'hardware.temperature.celsius', nlabel => 'hardware.temperature.celsius',
instances => $result->{apEnvMonTemperatureStatusDescr}, instances => $result->{apEnvMonTemperatureStatusDescr},
value => $result->{apEnvMonTemperatureStatusValue}, value => $result->{apEnvMonTemperatureStatusValue},

View File

@ -27,7 +27,7 @@ use network::acmepacket::snmp::mode::components::resources qw($map_status);
my $mapping = { my $mapping = {
apEnvMonVoltageStatusDescr => { oid => '.1.3.6.1.4.1.9148.3.3.1.2.1.1.3' }, 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' }, 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'; 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}); $result->{apEnvMonVoltageStatusValue} = sprintf("%.3f", $result->{apEnvMonVoltageStatusValue});
$self->{components}->{voltage}->{total}++; $self->{components}->{voltage}->{total}++;
$self->{output}->output_add(long_msg => sprintf("voltage '%s' status is '%s' [instance = %s, value = %s]", $self->{output}->output_add(
$result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageState}, $instance, long_msg => sprintf(
$result->{apEnvMonVoltageStatusValue})); "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}); $exit = $self->get_severity(label => 'default', section => 'voltage', value => $result->{apEnvMonVoltageState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Voltage '%s' status is '%s'", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageState})); 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}); ($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)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("Voltage '%s' is '%s' V", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageStatusValue})); severity => $exit,
short_msg => sprintf("Voltage '%s' is '%s' V", $result->{apEnvMonVoltageStatusDescr}, $result->{apEnvMonVoltageStatusValue})
);
} }
$self->{output}->perfdata_add( $self->{output}->perfdata_add(
label => 'voltage', unit => 'V', unit => 'V',
nlabel => 'hardware.voltage.volt', nlabel => 'hardware.voltage.volt',
instances => $result->{apEnvMonVoltageStatusDescr}, instances => $result->{apEnvMonVoltageStatusDescr},
value => $result->{apEnvMonVoltageStatusValue}, value => $result->{apEnvMonVoltageStatusValue},

View File

@ -58,7 +58,7 @@ sub snmp_execute {
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
$options{options}->add_options(arguments => {}); $options{options}->add_options(arguments => {});

View File

@ -26,6 +26,12 @@ use strict;
use warnings; use warnings;
use Digest::MD5 qw(md5_hex); use Digest::MD5 qw(md5_hex);
sub prefix_realm_output {
my ($self, %options) = @_;
return "Realm '" . $options{instance_value}->{display} . "' ";
}
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -35,115 +41,100 @@ sub set_counters {
$self->{maps_counters}->{realm} = [ $self->{maps_counters}->{realm} = [
{ label => 'current-in-sessions', nlabel => 'realm.sessions.in.current.count', set => { { label => 'current-in-sessions', nlabel => 'realm.sessions.in.current.count', set => {
key_values => [ { name => 'apSigRealmStatsCurrentActiveSessionsInbound' }, { name => 'display' } ], key_values => [ { name => 'current_active_sessions_inbound' }, { name => 'display' } ],
output_template => 'Current Inbound Sessions : %s', output_template => 'current inbound sessions: %s',
perfdatas => [ perfdatas => [
{ label => 'current_inbound_sessions', value => 'apSigRealmStatsCurrentActiveSessionsInbound', template => '%s', { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'current-in-sessions-rate', nlabel => 'realm.sessions.in.rate.count', set => { { label => 'current-in-sessions-rate', nlabel => 'realm.sessions.in.rate.count', set => {
key_values => [ { name => 'apSigRealmStatsCurrentSessionRateInbound' }, { name => 'display' } ], key_values => [ { name => 'current_session_rate_inbound' }, { name => 'display' } ],
output_template => 'Current Inbound Sessions Rate : %s/s', output_template => 'current inbound sessions rate: %s/s',
perfdatas => [ perfdatas => [
{ label => 'current_inbound_sessions_rate', value => 'apSigRealmStatsCurrentSessionRateInbound', template => '%s', { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'total-in-sessions', nlabel => 'realm.sessions.in.total.count', set => { { label => 'total-in-sessions', nlabel => 'realm.sessions.in.total.count', set => {
key_values => [ { name => 'apSigRealmStatsTotalSessionsInbound', diff => 1 }, { name => 'display' } ], key_values => [ { name => 'total_sessions_inbound', diff => 1 }, { name => 'display' } ],
output_template => 'Total Inbound Sessions : %s', output_template => 'total inbound sessions: %s',
perfdatas => [ perfdatas => [
{ label => 'total_inbound_sessions', value => 'apSigRealmStatsTotalSessionsInbound', template => '%s', { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'current-out-sessions', nlabel => 'realm.sessions.out.current.count', set => { { label => 'current-out-sessions', nlabel => 'realm.sessions.out.current.count', set => {
key_values => [ { name => 'apSigRealmStatsCurrentActiveSessionsOutbound' }, { name => 'display' } ], key_values => [ { name => 'current_active_sessions_outbound' }, { name => 'display' } ],
output_template => 'Current Outbound Sessions : %s', output_template => 'current outbound sessions: %s',
perfdatas => [ perfdatas => [
{ label => 'current_outbound_sessions', value => 'apSigRealmStatsCurrentActiveSessionsOutbound', template => '%s', { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' },
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'current-out-sessions-rate', nlabel => 'realm.sessions.out.current.count', set => { { label => 'current-out-sessions-rate', nlabel => 'realm.sessions.out.rate.count', set => {
key_values => [ { name => 'apSigRealmStatsCurrentSessionRateOutbound' }, { name => 'display' } ], key_values => [ { name => 'current_session_rate_outbound' }, { name => 'display' } ],
output_template => 'Current Outbound Sessions Rate : %s/s', output_template => 'current outbound sessions rate: %s/s',
perfdatas => [ perfdatas => [
{ label => 'current_outbound_sessions_rate', value => 'apSigRealmStatsCurrentSessionRateOutbound', template => '%s', { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'total-out-sessions', nlabel => 'realm.sessions.out.total.count', set => { { label => 'total-out-sessions', nlabel => 'realm.sessions.out.total.count', set => {
key_values => [ { name => 'apSigRealmStatsTotalSessionsOutbound', diff => 1 }, { name => 'display' } ], key_values => [ { name => 'total_sessions_outbound', diff => 1 }, { name => 'display' } ],
output_template => 'Total Outbound Sessions : %s', output_template => 'total outbound sessions: %s',
perfdatas => [ perfdatas => [
{ label => 'total_outbound_sessions', value => 'apSigRealmStatsTotalSessionsOutbound', template => '%s', { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'avg-qos-rfactor', nlabel => 'realm.rfactor.qos.average.count', set => { { label => 'avg-qos-rfactor', nlabel => 'realm.rfactor.qos.average.count', set => {
key_values => [ { name => 'apSigRealmStatsAverageQoSRFactor' }, { name => 'display' } ], key_values => [ { name => 'average_qos_rfactor' }, { name => 'display' } ],
output_template => 'Average QoS RFactor : %s', output_template => 'average QoS RFactor: %s',
perfdatas => [ perfdatas => [
{ label => 'avg_qos_rfactor', value => 'apSigRealmStatsAverageQoSRFactor', template => '%s', { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'total-rfactor', nlabel => 'realm.rfactor.execeded.total.count', set => { { label => 'total-rfactor', nlabel => 'realm.rfactor.execeded.total.count', set => {
key_values => [ { name => 'apSigRealmStatsTotalMajorRFactorExceeded', diff => 1 }, { name => 'display' } ], key_values => [ { name => 'total_major_rfactor_exceeded', diff => 1 }, { name => 'display' } ],
output_template => 'Total Rfactor Exceeded : %s', output_template => 'total RFactor exceeded: %s',
perfdatas => [ perfdatas => [
{ label => 'total_rfactor', value => 'apSigRealmStatsTotalMajorRFactorExceeded', template => '%s', { template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, }
]; ];
} }
sub prefix_realm_output {
my ($self, %options) = @_;
return "Realm '" . $options{instance_value}->{display} . "' ";
}
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'filter-name:s' => { name => 'filter_name' }
"filter-name:s" => { name => 'filter_name' }, });
});
return $self; 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 = { my $mapping = {
apSigRealmStatsCurrentActiveSessionsInbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.3' }, current_active_sessions_inbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.3' }, # apSigRealmStatsCurrentActiveSessionsInbound
apSigRealmStatsCurrentSessionRateInbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.4' }, current_session_rate_inbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.4' }, # apSigRealmStatsCurrentSessionRateInbound
apSigRealmStatsCurrentActiveSessionsOutbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.5' }, current_active_sessions_outbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.5' }, # apSigRealmStatsCurrentActiveSessionsOutbound
apSigRealmStatsCurrentSessionRateOutbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.6' }, current_session_rate_outbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.6' }, # apSigRealmStatsCurrentSessionRateOutbound
apSigRealmStatsTotalSessionsInbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.7' }, total_sessions_inbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.7' }, # apSigRealmStatsTotalSessionsInbound
apSigRealmStatsTotalSessionsOutbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.11' }, total_sessions_outbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.11' }, # apSigRealmStatsTotalSessionsOutbound
apSigRealmStatsAverageQoSRFactor => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.24' }, average_qos_rfactor => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.24' }, # apSigRealmStatsAverageQoSRFactor
apSigRealmStatsTotalMajorRFactorExceeded => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.27' }, total_major_rfactor_exceeded => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.4.1.27' } # apSigRealmStatsTotalMajorRFactorExceeded
}; };
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; 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} = {}; $self->{realm} = {};
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
$oid =~ /\.(\d+)$/; $oid =~ /\.(\d+)$/;
@ -153,15 +144,14 @@ sub manage_selection {
$self->{output}->output_add(long_msg => "skipping realm '" . $snmp_result->{$oid} . "'.", debug => 1); $self->{output}->output_add(long_msg => "skipping realm '" . $snmp_result->{$oid} . "'.", debug => 1);
next; next;
} }
$self->{realm}->{$instance} = { display => $snmp_result->{$oid} }; $self->{realm}->{$instance} = { display => $snmp_result->{$oid} };
} }
$options{snmp}->load(oids => [$mapping->{apSigRealmStatsCurrentActiveSessionsInbound}->{oid}, $mapping->{apSigRealmStatsCurrentSessionRateInbound}->{oid}, $options{snmp}->load(
$mapping->{apSigRealmStatsCurrentActiveSessionsOutbound}->{oid}, $mapping->{apSigRealmStatsCurrentSessionRateOutbound}->{oid}, oids => [ map($_->{oid}, values(%$mapping)) ],
$mapping->{apSigRealmStatsTotalSessionsInbound}->{oid}, $mapping->{apSigRealmStatsTotalSessionsOutbound}->{oid}, instances => [keys %{$self->{realm}}],
$mapping->{apSigRealmStatsAverageQoSRFactor}->{oid}, $mapping->{apSigRealmStatsTotalMajorRFactorExceeded}->{oid} instance_regexp => '^(.*)$'
], );
instances => [keys %{$self->{realm}}], instance_regexp => '^(.*)$');
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1); $snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
foreach (keys %{$self->{realm}}) { foreach (keys %{$self->{realm}}) {
@ -171,13 +161,13 @@ sub manage_selection {
$self->{realm}->{$_}->{$name} = $result->{$name}; $self->{realm}->{$_}->{$name} = $result->{$name};
} }
} }
if (scalar(keys %{$self->{realm}}) <= 0) { 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->{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_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')); (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
} }

View File

@ -25,20 +25,18 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
use Digest::MD5 qw(md5_hex); 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 { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = 'Status : ' . $self->{result_values}->{status}; return 'status: ' . $self->{result_values}->{status};
return $msg;
} }
sub custom_status_calc { sub prefix_sip_output {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_apSipSAStatsSessionAgentStatus'}; return "SIP '" . $options{instance_value}->{display} . "' ";
return 0;
} }
sub set_counters { sub set_counters {
@ -49,99 +47,79 @@ sub set_counters {
]; ];
$self->{maps_counters}->{sip} = [ $self->{maps_counters}->{sip} = [
{ label => 'status', threshold => 0, set => { { label => 'status', type => 2, critical_default => '%{status} =~ /outOfService|constraintsViolation|inServiceTimedOut/i', set => {
key_values => [ { name => 'apSipSAStatsSessionAgentStatus' } ], key_values => [ { name => 'status' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'), closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; }, 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 => { { label => 'in-sessions-rate', nlabel => 'sip.sessions.in.rate', set => {
key_values => [ { name => 'apSipSAStatsTotalSessionsInbound', per_second => 1 }, { name => 'display' } ], key_values => [ { name => 'sessions_inbound', per_second => 1 }, { name => 'display' } ],
output_template => 'Inbound Sessions Rate : %.2f/s', output_template => 'inbound sessions rate: %.2f/s',
perfdatas => [ perfdatas => [
{ label => 'inbound_sessions_rate', template => '%.2f', { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'out-sessions-rate', nlabel => 'sip.sessions.out.rate', set => { { label => 'out-sessions-rate', nlabel => 'sip.sessions.out.rate', set => {
key_values => [ { name => 'apSipSAStatsTotalSessionsOutbound', per_second => 1 }, { name => 'display' } ], key_values => [ { name => 'sessions_outbound', per_second => 1 }, { name => 'display' } ],
output_template => 'Outbound Sessions Rate : %.2f/s', output_template => 'outbound sessions rate: %.2f/s',
perfdatas => [ perfdatas => [
{ label => 'outbound_sessions_rate', template => '%.2f', { template => '%.2f', min => 0, label_extra_instance => 1, instance_use => 'display' }
min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'latency', nlabel => 'sip.stats.latency.milliseconds', set => { { label => 'latency', nlabel => 'sip.stats.latency.milliseconds', set => {
key_values => [ { name => 'apSipSAStatsAverageLatency' }, { name => 'display' } ], key_values => [ { name => 'average_latency' }, { name => 'display' } ],
output_template => 'Average Latency : %s ms', output_template => 'average latency: %s ms',
perfdatas => [ perfdatas => [
{ label => 'avg_latency', template => '%s', { template => '%s', unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }
unit => 'ms', min => 0, label_extra_instance => 1, instance_use => 'display' }, ]
],
} }
}, },
{ label => 'asr', nlabel => 'sip.stats.asr.percentage', set => { { label => 'asr', nlabel => 'sip.stats.asr.percentage', set => {
key_values => [ { name => 'apSipSAStatsPeriodASR' }, { name => 'display' } ], key_values => [ { name => 'period_asr' }, { name => 'display' } ],
output_template => 'Answer-to-seizure Ratio : %s %%', output_template => 'answer-to-seizure ratio: %s %%',
perfdatas => [ perfdatas => [
{ label => 'asr', template => '%s', { template => '%s', unit => '%', min => 0, label_extra_instance => 1, instance_use => 'display' }
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 { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' }, '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' }
}); });
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
my %map_status = ( my %map_status = (
0 => 'disabled', 1 => 'outOfService', 0 => 'disabled', 1 => 'outOfService',
2 => 'standby', 3 => 'inService', 2 => 'standby', 3 => 'inService',
4 => 'constraintsViolation', 5 => 'inServiceTimedOut', 4 => 'constraintsViolation', 5 => 'inServiceTimedOut',
6 => 'oosprovisionedresponse', 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 = { my $mapping = {
apSipSAStatsTotalSessionsInbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.8' }, sessions_inbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.8' }, # apSipSAStatsTotalSessionsInbound
apSipSAStatsTotalSessionsOutbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.12' }, sessions_outbound => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.12' }, # apSipSAStatsTotalSessionsOutbound
apSipSAStatsPeriodASR => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.19' }, period_asr => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.19' }, # apSipSAStatsPeriodASR
apSipSAStatsAverageLatency => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.20' }, average_latency => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.20' }, # apSipSAStatsAverageLatency
apSipSAStatsSessionAgentStatus => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.22', map => \%map_status }, status => { oid => '.1.3.6.1.4.1.9148.3.2.1.2.2.1.22', map => \%map_status } # apSipSAStatsSessionAgentStatus
}; };
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; 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} = {}; $self->{sip} = {};
foreach my $oid (keys %{$snmp_result}) { foreach my $oid (keys %{$snmp_result}) {
$oid =~ /\.(\d+)$/; $oid =~ /\.(\d+)$/;
@ -154,27 +132,27 @@ sub manage_selection {
$self->{sip}->{$instance} = { display => $snmp_result->{$oid} }; $self->{sip}->{$instance} = { display => $snmp_result->{$oid} };
} }
$options{snmp}->load(oids => [$mapping->{apSipSAStatsTotalSessionsInbound}->{oid}, $mapping->{apSipSAStatsTotalSessionsOutbound}->{oid}, $options{snmp}->load(
$mapping->{apSipSAStatsPeriodASR}->{oid}, $mapping->{apSipSAStatsAverageLatency}->{oid}, oids => [ map($_->{oid}, values(%$mapping)) ],
$mapping->{apSipSAStatsSessionAgentStatus}->{oid} instances => [keys %{$self->{sip}}],
], instance_regexp => '^(.*)$'
instances => [keys %{$self->{sip}}], instance_regexp => '^(.*)$'); );
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1); $snmp_result = $options{snmp}->get_leef(nothing_quit => 1);
foreach (keys %{$self->{sip}}) { foreach (keys %{$self->{sip}}) {
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
foreach my $name (keys %$mapping) { foreach my $name (keys %$mapping) {
$self->{sip}->{$_}->{$name} = $result->{$name}; $self->{sip}->{$_}->{$name} = $result->{$name};
} }
} }
if (scalar(keys %{$self->{sip}}) <= 0) { if (scalar(keys %{$self->{sip}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No SIP found."); $self->{output}->add_option_msg(short_msg => "No SIP found.");
$self->{output}->option_exit(); $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_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')); (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
} }

View File

@ -24,146 +24,161 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; 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 { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
my $msg = sprintf('replication state : %s', $self->{result_values}->{replication_state}); return sprintf('replication state: %s', $self->{result_values}->{replication_state});
return $msg;
} }
sub custom_status_calc { sub system_long_output {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{replication_state} = $options{new_datas}->{$self->{instance} . '_replication_state'}; return 'checking system';
return 0;
} }
sub set_counters { sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'global', type => 0, message_separator => ' - ' }, { 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 => { { label => 'health-score', nlabel => 'health.score.percentage', set => {
key_values => [ { name => 'health_score' } ], key_values => [ { name => 'health_score' } ],
output_template => 'Health Score : %.2f %%', output_template => 'health score: %.2f %%',
perfdatas => [ perfdatas => [
{ label => 'health_score', value => 'health_score', template => '%.2f', { template => '%.2f', min => 0, max => 100, unit => '%' }
min => 0, max => 100, unit => '%' }, ]
],
} }
}, }
];
$self->{maps_counters}->{cpu} = [
{ label => 'cpu-load', nlabel => 'cpu.utilization.percentage', set => { { label => 'cpu-load', nlabel => 'cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu_load' } ], key_values => [ { name => 'cpu_load' } ],
output_template => 'Cpu Load : %.2f %%', output_template => 'cpu load: %.2f %%',
perfdatas => [ perfdatas => [
{ label => 'cpu_load', value => 'cpu_load', template => '%.2f', { template => '%.2f', min => 0, max => 100, unit => '%' }
min => 0, max => 100, unit => '%' }, ]
],
} }
}, }
];
$self->{maps_counters}->{memory} = [
{ label => 'memory-usage', nlabel => 'memory.usage.percentage', set => { { label => 'memory-usage', nlabel => 'memory.usage.percentage', set => {
key_values => [ { name => 'memory_used' } ], key_values => [ { name => 'memory_used' } ],
output_template => 'Memory Used : %.2f %%', output_template => 'memory used: %.2f %%',
perfdatas => [ perfdatas => [
{ label => 'memory_used', value => 'memory_used', template => '%.2f', { template => '%.2f', min => 0, max => 100, unit => '%' }
min => 0, max => 100, unit => '%' }, ]
],
} }
}, }
];
$self->{maps_counters}->{license} = [
{ label => 'license-usage', nlabel => 'licence.usage.percentage', set => { { label => 'license-usage', nlabel => 'licence.usage.percentage', set => {
key_values => [ { name => 'license_used' } ], key_values => [ { name => 'license_used' } ],
output_template => 'License Used : %.2f %%', output_template => 'license used: %.2f %%',
perfdatas => [ perfdatas => [
{ label => 'license_used', value => 'license_used', template => '%.2f', { template => '%.2f', min => 0, max => 100, unit => '%' },
min => 0, max => 100, unit => '%' }, ]
],
} }
}, }
];
$self->{maps_counters}->{sessions} = [
{ label => 'current-sessions', nlabel => 'sessions.current.count', set => { { label => 'current-sessions', nlabel => 'sessions.current.count', set => {
key_values => [ { name => 'current_sessions' } ], key_values => [ { name => 'current_sessions' } ],
output_template => 'Current Sessions : %s', output_template => 'current sessions: %s',
perfdatas => [ perfdatas => [
{ label => 'current_sessions', value => 'current_sessions', template => '%s', { template => '%s', min => 0 }
min => 0 }, ]
],
} }
}, }
];
$self->{maps_counters}->{calls} = [
{ label => 'current-calls', nlabel => 'calls.current.count', set => { { label => 'current-calls', nlabel => 'calls.current.count', set => {
key_values => [ { name => 'current_calls' } ], key_values => [ { name => 'current_calls' } ],
output_template => 'Current Calls : %s/s', output_template => 'current calls: %s/s',
perfdatas => [ perfdatas => [
{ label => 'current_calls', value => 'current_calls', template => '%s', { template => '%s', unit => '/s', min => 0 }
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' }, ], key_values => [ { name => 'replication_state' }, ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'), closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold_ng
} }
}, }
]; ];
} }
sub new { sub new {
my ($class, %options) = @_; 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; bless $self, $class;
$options{options}->add_options(arguments => $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' },
});
return $self; 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 { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my %mapping_redundancy = ( my $mapping_redundancy = {
0 => 'unknown', 1 => 'initial', 2 => 'active', 3 => 'standby', 0 => 'unknown', 1 => 'initial', 2 => 'active', 3 => 'standby',
4 => 'outOfService', 5 => 'unassigned', 6 => 'activePending', 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'; $self->{output}->output_add(short_msg => 'System usage is ok');
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->{global} = { $self->{system} = {
cpu_load => $result->{$oid_apSysCPUUtil}, global => {
memory_used => $result->{$oid_apSysMemoryUtil}, health => { health_score => $result->{health_score} },
replication_state => $mapping_redundancy{$result->{$oid_apSysRedundancy}}, cpu => { cpu_load => $result->{cpu_load} },
license_used => $result->{$oid_apSysLicenseCapacity}, memory => { memory_used => $result->{memory_used} },
health_score => $result->{$oid_apSysHealthScore}, license => { license_used => $result->{license_used} },
current_sessions => $result->{$oid_apSysGlobalConSess}, sessions => { current_sessions => $result->{current_sessions} },
current_calls => $result->{$oid_apSysGlobalCPS}, calls => { current_calls => $result->{current_calls} },
replication => { replication_state => $result->{replication_state} }
}
}; };
} }

View File

@ -30,7 +30,7 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
%{$self->{modes}} = ( $self->{modes} = {
'hardware' => 'network::acmepacket::snmp::mode::hardware', 'hardware' => 'network::acmepacket::snmp::mode::hardware',
'interfaces' => 'snmp_standard::mode::interfaces', 'interfaces' => 'snmp_standard::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces', 'list-interfaces' => 'snmp_standard::mode::listinterfaces',
@ -38,8 +38,8 @@ sub new {
'list-sip' => 'network::acmepacket::snmp::mode::listsip', 'list-sip' => 'network::acmepacket::snmp::mode::listsip',
'realm-usage' => 'network::acmepacket::snmp::mode::realmusage', 'realm-usage' => 'network::acmepacket::snmp::mode::realmusage',
'sip-usage' => 'network::acmepacket::snmp::mode::sipusage', 'sip-usage' => 'network::acmepacket::snmp::mode::sipusage',
'system-usage' => 'network::acmepacket::snmp::mode::systemusage', 'system-usage' => 'network::acmepacket::snmp::mode::systemusage'
); };
return $self; return $self;
} }

View File

@ -23,17 +23,17 @@ package storage::overland::neo::snmp::mode::components::drive;
use strict; use strict;
use warnings; use warnings;
my %map_state = ( my $map_state = {
0 => 'initializedNoError', 0 => 'initializedNoError',
1 => 'initializedWithError', 1 => 'initializedWithError',
2 => 'notInitialized', 2 => 'notInitialized',
3 => 'notInstalled', 3 => 'notInstalled',
4 => 'notInserted', 4 => 'notInserted'
); };
my $mapping = { my $mapping = {
dstState => { oid => '.1.3.6.1.4.1.3351.1.3.2.3.1.1.3', map => \%map_state }, 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' }, 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'; my $oid_driveStatusEntry = '.1.3.6.1.4.1.3351.1.3.2.3.1.1';
@ -46,8 +46,8 @@ sub load {
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking drives"); $self->{output}->output_add(long_msg => 'Checking drives');
$self->{components}->{drive} = {name => 'drives', total => 0, skip => 0}; $self->{components}->{drive} = { name => 'drives', total => 0, skip => 0 };
return if ($self->check_filter(section => 'drive')); return if ($self->check_filter(section => 'drive'));
# there is no instance for the table. Weird. Need to manage the two cases. # 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}(?:\.(.*)|$)/); next if ($oid !~ /^$mapping->{dstState}->{oid}(?:\.(.*)|$)/);
my $instance = defined($1) ? $1 : undef; my $instance = defined($1) ? $1 : undef;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_driveStatusEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_driveStatusEntry}, instance => $instance);
# we set a 1 to do some filters # we set a 1 to do some filters
$instance = '1' if (!defined($instance)); $instance = '1' if (!defined($instance));
next if ($self->check_filter(section => 'drive', instance => $instance)); next if ($self->check_filter(section => 'drive', instance => $instance));
$self->{components}->{drive}->{total}++; $self->{components}->{drive}->{total}++;
$self->{output}->output_add(long_msg => sprintf("drive '%s' status is '%s' [instance = %s]", $self->{output}->output_add(
$instance, $result->{dstState}, $instance)); 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}); my $exit = $self->get_severity(section => 'drive', instance => $instance, value => $result->{dstState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("drive '%s' status is '%s'", $instance, $result->{dstState})); severity => $exit,
short_msg => sprintf("drive '%s' status is '%s'", $instance, $result->{dstState})
);
} }
} }
} }
1; 1;

View File

@ -23,14 +23,12 @@ package storage::overland::neo::snmp::mode::components::library;
use strict; use strict;
use warnings; use warnings;
my %map_state = ( my $map_state = {
0 => 'initializing', 0 => 'initializing', 1 => 'online', 2 => 'offline'
1 => 'online', };
2 => 'offline',
);
my $mapping = { 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'; my $oid_libraryStatusEntry = '.1.3.6.1.4.1.3351.1.3.2.3.2.1';
@ -43,8 +41,8 @@ sub load {
sub check { sub check {
my ($self) = @_; my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking libraries"); $self->{output}->output_add(long_msg => 'Checking libraries');
$self->{components}->{library} = {name => 'libraries', total => 0, skip => 0}; $self->{components}->{library} = { name => 'libraries', total => 0, skip => 0 };
return if ($self->check_filter(section => 'library')); return if ($self->check_filter(section => 'library'));
# there is no instance for the table. Weird. Need to manage the two cases. # 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}(?:\.(.*)|$)/); next if ($oid !~ /^$mapping->{lstLibraryState}->{oid}(?:\.(.*)|$)/);
my $instance = defined($1) ? $1 : undef; my $instance = defined($1) ? $1 : undef;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryStatusEntry}, instance => $instance); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_libraryStatusEntry}, instance => $instance);
# we set a 1 to do some filters # we set a 1 to do some filters
$instance = '1' if (!defined($instance)); $instance = '1' if (!defined($instance));
next if ($self->check_filter(section => 'library', instance => $instance)); next if ($self->check_filter(section => 'library', instance => $instance));
$self->{components}->{library}->{total}++; $self->{components}->{library}->{total}++;
$self->{output}->output_add(long_msg => sprintf("library '%s' status is '%s' [instance = %s]", $self->{output}->output_add(
$instance, $result->{lstLibraryState}, $instance)); 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}); my $exit = $self->get_severity(section => 'library', instance => $instance, value => $result->{lstLibraryState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(
short_msg => sprintf("library '%s' status is '%s'", $instance, $result->{lstLibraryState})); severity => $exit,
short_msg => sprintf("library '%s' status is '%s'", $instance, $result->{lstLibraryState})
);
} }
} }
} }
1; 1;

View File

@ -36,13 +36,13 @@ sub set_system {
['initializedWithError', 'CRITICAL'], ['initializedWithError', 'CRITICAL'],
['notInitialized', 'WARNING'], ['notInitialized', 'WARNING'],
['notInstalled', 'OK'], ['notInstalled', 'OK'],
['notInserted', 'OK'], ['notInserted', 'OK']
], ],
library => [ library => [
['initializing', 'OK'], ['initializing', 'OK'],
['online', 'OK'], ['online', 'OK'],
['offline', 'CRITICAL'], ['offline', 'CRITICAL']
], ]
}; };
$self->{components_path} = 'storage::overland::neo::snmp::mode::components'; $self->{components_path} = 'storage::overland::neo::snmp::mode::components';

View File

@ -30,10 +30,10 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
%{$self->{modes}} = ( $self->{modes} = {
'hardware' => 'storage::overland::neo::snmp::mode::hardware',
'eventlog' => 'storage::overland::neo::snmp::mode::eventlog', 'eventlog' => 'storage::overland::neo::snmp::mode::eventlog',
); 'hardware' => 'storage::overland::neo::snmp::mode::hardware'
};
return $self; return $self;
} }