Refs #5716
This commit is contained in:
parent
49a0c50d96
commit
f82fdd71a3
|
@ -38,22 +38,6 @@ package network::f5::mode::components::fan;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
my %map_status = (
|
||||
0 => 'bad',
|
||||
1 => 'good',
|
||||
|
@ -94,8 +78,7 @@ sub check {
|
|||
|
||||
$self->{output}->perfdata_add(label => "fan_" . $instance,
|
||||
value => $speed,
|
||||
);
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ my %map_status = (
|
|||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{components}->{psus} = {name => 'psus', total => 0};
|
||||
$self->{components}->{psu} = {name => 'psus', total => 0};
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
return if ($self->check_exclude(section => 'psus'));
|
||||
return if ($self->check_exclude(section => 'psu'));
|
||||
|
||||
my $oid_sysChassisPowerSupplyEntry = '.1.3.6.1.4.1.3375.2.1.3.2.2.2.1';
|
||||
my $oid_sysChassisPowerSupplyStatus = '.1.3.6.1.4.1.3375.2.1.3.2.2.2.1.2';
|
||||
|
@ -60,11 +60,11 @@ sub check {
|
|||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_sysChassisPowerSupplyStatus\.(\d+)$/);
|
||||
my $instance = $1;
|
||||
next if ($self->check_exclude(section => 'psus', instance => $instance));
|
||||
next if ($self->check_exclude(section => 'psu', instance => $instance));
|
||||
|
||||
my $status = $result->{$oid_sysChassisPowerSupplyStatus . '.' . $instance};
|
||||
|
||||
$self->{components}->{psus}->{total}++;
|
||||
$self->{components}->{psu}->{total}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is %s.",
|
||||
$instance, $map_status{$status}));
|
||||
if ($status < 1) {
|
||||
|
|
|
@ -54,25 +54,22 @@ sub check {
|
|||
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
|
||||
next if ($key !~ /^$oid_sysChassisTempTemperature\.(\d+)$/);
|
||||
my $instance = $1;
|
||||
|
||||
next if ($self->check_exclude(section => 'temperatures', instance => $instance));
|
||||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_sysChassisTempTemperature . '.' . $instance},
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_sysChassisTempTemperature . '.' . $instance},
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{components}->{temperatures}->{total}++;
|
||||
|
||||
$self->{output}->output_add(severity => $exit_code,long_msg => sprintf("temp_" . $instance . " is %.2f C", $result->{$oid_sysChassisTempTemperature . '.' . $instance}));
|
||||
|
||||
if ($exit_code ne 'ok') {
|
||||
if (!$self->{output}->is_status(value => $exit_code, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit_code,short_msg => sprintf("temp_" . $instance . " is %.2f C", $result->{$oid_sysChassisTempTemperature . '.' . $instance}));
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => "temp_" . $instance , unit => 'C', value => sprintf("%.2f", $result->{$oid_sysChassisTempTemperature . '.' . $instance}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => "temp_" . $instance , unit => 'C',
|
||||
value => sprintf("%.2f", $result->{$oid_sysChassisTempTemperature . '.' . $instance}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -90,7 +90,6 @@ sub run {
|
|||
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
my $oid_sysStatClientCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.8.0';
|
||||
my $oid_sysStatServerCurConns = '.1.3.6.1.4.1.3375.2.1.1.2.1.15.0';
|
||||
|
|
|
@ -83,23 +83,6 @@ sub global {
|
|||
network::f5::mode::components::psu::check($self);
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
# $options{snmp} = snmp object
|
||||
|
@ -141,6 +124,21 @@ sub run {
|
|||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
@ -159,8 +157,8 @@ Can be: 'fan', 'psu', 'temperature'.
|
|||
|
||||
=item B<--exclude>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=fans,psus)
|
||||
Can also exclude specific instance: --exclude=fans#1#2#,modules#1#,psus
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=fans,psu)
|
||||
Can also exclude specific instance: --exclude=fan#1#2#,psu
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'hardware' => 'network::f5::mode::hardware',
|
||||
'hardware' => 'network::f5::mode::hardware',
|
||||
'connections' => 'network::f5::mode::connections',
|
||||
);
|
||||
|
||||
|
@ -60,6 +60,7 @@ __END__
|
|||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Brocade hardware in SNMP.
|
||||
Check F-5 hardware in SNMP.
|
||||
Please use plugin SNMP Linux for system checks ('cpu', 'memory', 'traffic',...).
|
||||
|
||||
=cut
|
||||
|
|
Loading…
Reference in New Issue