This commit is contained in:
Quentin Garnier 2014-03-07 11:20:31 +01:00
parent ed772c5ea7
commit d39518e7f8
3 changed files with 20 additions and 7 deletions

View File

@ -63,7 +63,8 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
{
"skip-not-present" => { name => 'skip_not_present' },
});
return $self;
@ -100,6 +101,12 @@ sub run {
$self->{output}->output_add(long_msg => sprintf("%s sensor '%s' state is %s.",
$object_map{$object}, $instance,
${$states{$status}}[0]));
if (defined($self->{option_results}->{skip_not_present}) &&
$status == 5) {
$self->{output}->output_add(long_msg => sprintf("Skipping %s sensor '%s'.",
$object_map{$object}, $instance));
next;
}
if (${$states{$status}}[1] ne 'OK') {
$self->{output}->output_add(severity => ${$states{$status}}[1],
short_msg => sprintf("%s sensor '%s' state is %s.",
@ -122,6 +129,10 @@ Check sensors (hpicfChassis.mib).
=over 8
=item B<--skip-not-present>
No warning for state 'not present'.
=back
=cut

View File

@ -47,10 +47,11 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::hp::procurve::mode::cpu',
'environment' => 'network::hp::procurve::mode::environment',
'memory' => 'network::hp::procurve::mode::memory',
'traffic' => 'snmp_standard::mode::traffic',
'cpu' => 'network::hp::procurve::mode::cpu',
'environment' => 'network::hp::procurve::mode::environment',
'memory' => 'network::hp::procurve::mode::memory',
'traffic' => 'snmp_standard::mode::traffic',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
);
return $self;

View File

@ -153,7 +153,7 @@ sub run {
my $result = $self->{snmp}->get_leef();
$new_datas->{last_timestamp} = time();
my $old_timestamp;
my $old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
if (!defined($self->{option_results}->{interface}) || defined($self->{option_results}->{use_regexp})) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All traffic are ok');
@ -175,6 +175,8 @@ sub run {
}
$interface_speed = (defined($result->{$oid_speed64 . "." . $_}) && $result->{$oid_speed64 . "." . $_} ne '' ? ($result->{$oid_speed64 . "." . $_} * 1000000) : ($result->{$oid_speed32 . "." . $_}));
if ($interface_speed == 0) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => "Interface '" . $display_value . "' Speed is 0. You should force the value with --speed option");
next;
}
}
@ -214,7 +216,6 @@ sub run {
next;
}
$old_timestamp = $self->{statefile_value}->get(name => 'last_timestamp');
my $old_in = $self->{statefile_value}->get(name => 'in_' . $_);
my $old_out = $self->{statefile_value}->get(name => 'out_' . $_);
if (!defined($old_timestamp) || !defined($old_in) || !defined($old_out)) {