parent
267ec14b21
commit
a7f4beb36e
|
@ -46,7 +46,7 @@ my %map_status = (
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{components}->{fans} = {name => 'fans', total => 0};
|
$self->{components}->{fans} = {name => 'fans', total => 0, skip => 0};
|
||||||
$self->{output}->output_add(long_msg => "Checking fans");
|
$self->{output}->output_add(long_msg => "Checking fans");
|
||||||
return if ($self->check_exclude(section => 'fans'));
|
return if ($self->check_exclude(section => 'fans'));
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ my %map_status = (
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{components}->{modules} = {name => 'modules', total => 0};
|
$self->{components}->{modules} = {name => 'modules', total => 0, skip => 0};
|
||||||
$self->{output}->output_add(long_msg => "Checking modules");
|
$self->{output}->output_add(long_msg => "Checking modules");
|
||||||
return if ($self->check_exclude(section => 'modules'));
|
return if ($self->check_exclude(section => 'modules'));
|
||||||
|
|
||||||
|
@ -62,11 +62,11 @@ sub check {
|
||||||
my $instance = $1;
|
my $instance = $1;
|
||||||
|
|
||||||
next if ($self->check_exclude(section => 'modules', instance => $instance));
|
next if ($self->check_exclude(section => 'modules', instance => $instance));
|
||||||
|
$self->{components}->{modules}->{total}++;
|
||||||
|
|
||||||
my $type = $result->{$oid_nsSlotType . '.' . $instance};
|
my $type = $result->{$oid_nsSlotType . '.' . $instance};
|
||||||
my $status = $result->{$oid_nsSlotStatus . '.' . $instance};
|
my $status = $result->{$oid_nsSlotStatus . '.' . $instance};
|
||||||
|
|
||||||
$self->{components}->{modules}->{total}++;
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s].",
|
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s].",
|
||||||
$type, $map_status{$status}, $instance));
|
$type, $map_status{$status}, $instance));
|
||||||
if ($status != 1) {
|
if ($status != 1) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ my %map_status = (
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{components}->{psus} = {name => 'psus', total => 0};
|
$self->{components}->{psus} = {name => 'psus', total => 0, skip => 0};
|
||||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||||
return if ($self->check_exclude(section => 'psus'));
|
return if ($self->check_exclude(section => 'psus'));
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
$self->{output}->output_add(long_msg => "Checking temperatures");
|
||||||
$self->{components}->{temperatures} = {name => 'temperatures', total => 0};
|
$self->{components}->{temperatures} = {name => 'temperatures', total => 0, skip => 0};
|
||||||
return if ($self->check_exclude('temperatures'));
|
return if ($self->check_exclude('temperatures'));
|
||||||
|
|
||||||
my $oid_nsTemperatureEntry = '.1.3.6.1.4.1.3224.21.4.1';
|
my $oid_nsTemperatureEntry = '.1.3.6.1.4.1.3224.21.4.1';
|
||||||
|
@ -72,7 +72,8 @@ sub check {
|
||||||
}
|
}
|
||||||
|
|
||||||
$temperature_name =~ s/\ /_/g;
|
$temperature_name =~ s/\ /_/g;
|
||||||
$self->{output}->perfdata_add(label => $temperature_name , unit => 'C', value => sprintf("%.2f", $result->{$oid_nsTemperatureCur . '.' . $instance}),
|
$self->{output}->perfdata_add(label => $temperature_name, unit => 'C',
|
||||||
|
value => sprintf("%.2f", $result->{$oid_nsTemperatureCur . '.' . $instance}),
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
################################################################################
|
|
||||||
# Copyright 2005-2013 MERETHIS
|
|
||||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
|
||||||
# GPL Licence 2.0.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify it under
|
|
||||||
# the terms of the GNU General Public License as published by the Free Software
|
|
||||||
# Foundation ; either version 2 of the License.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along with
|
|
||||||
# this program; if not, see <http://www.gnu.org/licenses>.
|
|
||||||
#
|
|
||||||
# Linking this program statically or dynamically with other modules is making a
|
|
||||||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
|
||||||
# General Public License cover the whole combination.
|
|
||||||
#
|
|
||||||
# As a special exception, the copyright holders of this program give MERETHIS
|
|
||||||
# permission to link this program with independent modules to produce an executable,
|
|
||||||
# regardless of the license terms of these independent modules, and to copy and
|
|
||||||
# distribute the resulting executable under terms of MERETHIS choice, provided that
|
|
||||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
|
||||||
# of the license of that module. An independent module is a module which is not
|
|
||||||
# derived from this program. If you modify this program, you may extend this
|
|
||||||
# exception to your version of the program, but you are not obliged to do so. If you
|
|
||||||
# do not wish to do so, delete this exception statement from your version.
|
|
||||||
#
|
|
||||||
# For more information : contact@centreon.com
|
|
||||||
# Authors : Quentin Garnier <qgarnier@merethis.com>
|
|
||||||
#
|
|
||||||
####################################################################################
|
|
||||||
|
|
||||||
package network::juniper::common::screenos::mode::components::temperature;
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
sub check {
|
|
||||||
my ($self) = @_;
|
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking temperatures");
|
|
||||||
$self->{components}->{temperatures} = {name => 'temperatures', total => 0};
|
|
||||||
return if ($self->check_exclude('temperatures'));
|
|
||||||
|
|
||||||
my $oid_ssgTemperature = '.1.3.6.1.4.1.3224.21.4.1.3.1';
|
|
||||||
|
|
||||||
my $result = $self->{snmp}->get_leef(oids => [$oid_ssgTemperature], nothing_quit => 1);
|
|
||||||
|
|
||||||
my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_ssgTemperature},
|
|
||||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
|
||||||
|
|
||||||
$self->{components}->{temperatures}->{total}++;
|
|
||||||
|
|
||||||
$self->{output}->output_add(severity => $exit_code,short_msg => sprintf("Temperature is %.2f C", $result->{$oid_ssgTemperature}));
|
|
||||||
|
|
||||||
$self->{output}->perfdata_add(label => 'temperature', unit => 'C', value => sprintf("%.2f", $result->{$oid_ssgTemperature}),
|
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
|
|
||||||
|
|
||||||
#$self->{output}->display();
|
|
||||||
#$self->{output}->exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
|
@ -54,9 +54,11 @@ sub new {
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments =>
|
||||||
{
|
{
|
||||||
"exclude:s" => { name => 'exclude' },
|
"exclude:s" => { name => 'exclude' },
|
||||||
|
"absent-problem:s" => { name => 'absent' },
|
||||||
"component:s" => { name => 'component', default => 'all' },
|
"component:s" => { name => 'component', default => 'all' },
|
||||||
"warning:s" => { name => 'warning', default => '' },
|
"no-component:s" => { name => 'no_component' },
|
||||||
"critical:s" => { name => 'critical', default => '' },
|
"warning:s" => { name => 'warning', },
|
||||||
|
"critical:s" => { name => 'critical', },
|
||||||
});
|
});
|
||||||
$self->{components} = {};
|
$self->{components} = {};
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -74,7 +76,13 @@ sub check_options {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
if (defined($self->{option_results}->{no_component})) {
|
||||||
|
if ($self->{option_results}->{no_component} ne '') {
|
||||||
|
$self->{no_components} = $self->{option_results}->{no_component};
|
||||||
|
} else {
|
||||||
|
$self->{no_components} = 'critical';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub global {
|
sub global {
|
||||||
|
@ -106,15 +114,14 @@ sub run {
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my $total_components = 0;
|
my $total_components = 0;
|
||||||
my $display_by_component = '';
|
my $display_by_component = '';
|
||||||
my $display_by_component_append = '';
|
my $display_by_component_append = '';
|
||||||
foreach my $comp (sort(keys %{$self->{components}})) {
|
foreach my $comp (sort(keys %{$self->{components}})) {
|
||||||
# Skipping short msg when no components
|
# Skipping short msg when no components
|
||||||
next if ($self->{components}->{$comp}->{total} == 0);
|
next if ($self->{components}->{$comp}->{total} == 0 && $self->{components}->{$comp}->{skip} == 0);
|
||||||
$total_components += $self->{components}->{$comp}->{total};
|
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name};
|
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $self->{components}->{$comp}->{name};
|
||||||
$display_by_component_append = ', ';
|
$display_by_component_append = ', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,20 +132,46 @@ sub run {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||||
|
$self->{output}->output_add(severity => $self->{no_components},
|
||||||
|
short_msg => 'No components are checked.');
|
||||||
|
}
|
||||||
|
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_exclude {
|
sub check_exclude {
|
||||||
my ($self, $section) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) {
|
if (defined($options{instance})) {
|
||||||
$self->{output}->output_add(long_msg => sprintf("Skipping $section section."));
|
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 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub absent_problem {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{absent}) &&
|
||||||
|
$self->{option_results}->{absent} =~ /(^|\s|,)($options{section}(\s*,|$)|${options{section}}[^,]*#\Q$options{instance}\E#)/) {
|
||||||
|
$self->{output}->output_add(severity => 'CRITICAL',
|
||||||
|
short_msg => sprintf("Component '%s' instance '%s' is not present",
|
||||||
|
$options{section}, $options{instance}));
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance (not present)"));
|
||||||
|
$self->{components}->{$options{section}}->{skip}++;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
@ -159,6 +192,15 @@ Can be: 'fan', 'psu', 'module'.
|
||||||
Exclude some parts (comma seperated list) (Example: --exclude=fans,modules)
|
Exclude some parts (comma seperated list) (Example: --exclude=fans,modules)
|
||||||
Can also exclude specific instance: --exclude=fans#1#2#,modules#1#,psus
|
Can also exclude specific instance: --exclude=fans#1#2#,modules#1#,psus
|
||||||
|
|
||||||
|
=item B<--absent-problem>
|
||||||
|
|
||||||
|
N/A for following equipment. Not needed.
|
||||||
|
|
||||||
|
=item B<--no-component>
|
||||||
|
|
||||||
|
Return an error if no compenents are checked.
|
||||||
|
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning>
|
||||||
|
|
||||||
Threshold warning in degree celsius.
|
Threshold warning in degree celsius.
|
||||||
|
|
Loading…
Reference in New Issue