WIP
This commit is contained in:
Quentin Garnier 2014-06-06 16:44:18 +02:00
parent a008fbeca3
commit 43338cd1e8
12 changed files with 745 additions and 269 deletions

View File

@ -1,131 +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 : Stephane Duret <sduret@merethis.com>
#
####################################################################################
package network::juniper::common::netscreen::cpu;
use base qw(centreon::plugins::mode);
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', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
my $oid_Cpu = '.1.3.6.1.4.1.3224.16.1.1.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_Cpu], nothing_quit => 1);
my $cpu = 0;
my $i = 0;
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
$key =~ /\.([0-9]+)$/;
my $cpu_num = $1;
$cpu += $result->{$key};
$self->{output}->output_add(long_msg => sprintf("CPU $i Usage is %.2f%%", $result->{$key}));
$self->{output}->perfdata_add(label => 'cpu' . $i, unit => '%',
value => sprintf("%.2f", $result->{$key}),
min => 0, max => 100);
$i++;
}
my $avg_cpu = $cpu / $i;
my $exit_code = $self->{perfdata}->threshold_check(value => $avg_cpu,
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit_code,
short_msg => sprintf("CPU(s) average usage is: %.2f%%", $avg_cpu));
$self->{output}->perfdata_add(label => 'total_cpu_avg', unit => '%',
value => sprintf("%.2f", $avg_cpu),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0, max => 100);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Juniper SSG CPU usage (NETSCREEN-RESOURCE-MIB)
The average of the percentage
of time that this processor was not idle.
=over 8
=item B<--warning>
Threshold warning in percent.
=item B<--critical>
Threshold critical in percent.
=back
=cut

View File

@ -1,114 +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 : Stephane Duret <sduret@merethis.com>
#
####################################################################################
package network::juniper::common::netscreen::temperature;
use base qw(centreon::plugins::mode);
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', },
"critical:s" => { name => 'critical', },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
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->{output}->output_add(severity => $exit_code,
short_msg => sprintf("Temperautre 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;
__END__
=head1 MODE
Check temperature of Juniper SSG (NETSCREEN-CHASSIS-MIB).
=over 8
=item B<--warning>
Threshold warning in degree celsius.
=item B<--critical>
Threshold critical in degree celsius.
=back
=cut

View File

@ -0,0 +1,78 @@
################################################################################
# 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 : Stephane Duret <sduret@merethis.com>
#
####################################################################################
package network::juniper::common::screenos::mode::components::fan;
use strict;
use warnings;
my %map_status = (
1 => 'active',
2 => 'inactive'
);
sub check {
my ($self) = @_;
$self->{components}->{fans} = {name => 'fans', total => 0};
$self->{output}->output_add(long_msg => "Checking fans");
return if ($self->check_exclude(section => 'fans'));
my $oid_nsFanEntry = '.1.3.6.1.4.1.3224.21.2.1';
my $oid_nsFanStatus = '.1.3.6.1.4.1.3224.21.2.1.2';
my $result = $self->{snmp}->get_table(oid => $oid_nsFanEntry);
return if (scalar(keys %$result) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /^$oid_nsFanStatus\.(\d+)$/);
my $instance = $1;
next if ($self->check_exclude(section => 'fans', instance => $instance));
my $status = $result->{$oid_nsFanStatus . '.' . $instance};
$self->{components}->{fans}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s.",
$instance, $map_status{$status}));
if ($status != 1) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Fan '%s' status is %s",
$instance, $map_status{$status}));
}
}
}
1;

View File

@ -0,0 +1,80 @@
################################################################################
# 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 : Stephane Duret <sduret@merethis.com>
#
####################################################################################
package network::juniper::common::screenos::mode::components::module;
use strict;
use warnings;
my %map_status = (
1 => 'active',
2 => 'inactive'
);
sub check {
my ($self) = @_;
$self->{components}->{modules} = {name => 'modules', total => 0};
$self->{output}->output_add(long_msg => "Checking modules");
return if ($self->check_exclude(section => 'modules'));
my $oid_nsSlotEntry = '.1.3.6.1.4.1.3224.21.5.1';
my $oid_nsSlotType = '.1.3.6.1.4.1.3224.21.5.1.2';
my $oid_nsSlotStatus = '.1.3.6.1.4.1.3224.21.5.1.3';
my $result = $self->{snmp}->get_table(oid => $oid_nsSlotEntry);
return if (scalar(keys %$result) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /^$oid_nsSlotStatus\.(\d+)$/);
my $instance = $1;
next if ($self->check_exclude(section => 'modules', instance => $instance));
my $type = $result->{$oid_nsSlotType . '.' . $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].",
$type, $map_status{$status}, $instance));
if ($status != 1) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Module '%s' status is %s",
$type, $map_status{$status}));
}
}
}
1;

View File

@ -0,0 +1,78 @@
################################################################################
# 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 : Stephane Duret <sduret@merethis.com>
#
####################################################################################
package network::juniper::common::screenos::mode::components::psu;
use strict;
use warnings;
my %map_status = (
1 => 'active',
2 => 'inactive'
);
sub check {
my ($self) = @_;
$self->{components}->{psus} = {name => 'psus', total => 0};
$self->{output}->output_add(long_msg => "Checking power supplies");
return if ($self->check_exclude(section => 'psus'));
my $oid_nsPowerEntry= '.1.3.6.1.4.1.3224.21.1.1';
my $oid_nsPowerStatus = '.1.3.6.1.4.1.3224.21.1.1.2';
my $result = $self->{snmp}->get_table(oid => $oid_nsPowerEntry);
return if (scalar(keys %$result) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /^$oid_nsPowerStatus\.(\d+)$/);
my $instance = $1;
next if ($self->check_exclude(section => 'psus', instance => $instance));
my $status = $result->{$oid_nsPowerStatus . '.' . $instance};
$self->{components}->{psus}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power Supply '%s' status is %s.",
$instance, $map_status{$status}));
if ($status != 1) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("Power Supply '%s' status is %s",
$instance, $map_status{$status}));
}
}
}
1;

View File

@ -0,0 +1,82 @@
################################################################################
# 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_nsTemperatureEntry = '.1.3.6.1.4.1.3224.21.4.1';
my $oid_nsTemperatureCur = '.1.3.6.1.4.1.3224.21.4.1.3';
my $oid_nsTemperatureDesc = '.1.3.6.1.4.1.3224.21.4.1.4';
my $result = $self->{snmp}->get_table(oid => $oid_nsTemperatureEntry);
return if (scalar(keys %$result) <= 0);
foreach my $key ($self->{snmp}->oid_lex_sort(keys %$result)) {
next if ($key !~ /^$oid_nsTemperatureCur\.(\d+)$/);
my $instance = $1;
next if ($self->check_exclude(section => 'temperatures', instance => $instance));
my $temperature_name = $result->{$oid_nsTemperatureDesc . '.' . $instance};
my $exit_code = $self->{perfdata}->threshold_check(value => $result->{$oid_nsTemperatureCur . '.' . $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($temperature_name . " is %.2f C", $result->{$oid_nsTemperatureCur . '.' . $instance}));
if ($exit_code ne 'ok') {
$self->{output}->output_add(severity => $exit_code,short_msg => sprintf($temperature_name . " is %.2f C", $result->{$oid_nsTemperatureCur . '.' . $instance}));
}
$temperature_name =~ s/\ /_/g;
$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'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'));
}
}
1;

View File

@ -0,0 +1,67 @@
################################################################################
# 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;

View File

@ -0,0 +1,159 @@
################################################################################
# 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 : Stephane Duret <sduret@merethis.com>
#
####################################################################################
package network::juniper::common::screenos::mode::cpu;
use base qw(centreon::plugins::mode);
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;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
($self->{warn1s}, $self->{warn4s}, $self->{warn64s}) = split /,/, $self->{option_results}->{warning};
($self->{crit1s}, $self->{crit4s}, $self->{crit64s}) = split /,/, $self->{option_results}->{critical};
if (($self->{perfdata}->threshold_validate(label => 'warn1min', value => $self->{warn1s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (1min) threshold '" . $self->{warn1s} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warn5min', value => $self->{warn4s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (5min) threshold '" . $self->{warn4s} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'warn15min', value => $self->{warn64s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning (15min) threshold '" . $self->{warn64s} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit1min', value => $self->{crit1s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (1min) threshold '" . $self->{crit1s} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit5min', value => $self->{crit4s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (5min) threshold '" . $self->{crit4s} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'crit15min', value => $self->{crit64s})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical (15min) threshold '" . $self->{crit64s} . "'.");
$self->{output}->option_exit();
}
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
my $oid_nsResCpuLast1Min = '.1.3.6.1.4.1.3224.16.1.2.0';
my $oid_nsResCpuLast5Min = '.1.3.6.1.4.1.3224.16.1.3.0';
my $oid_nsResCpuLast15Min = '.1.3.6.1.4.1.3224.16.1.4.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_nsResCpuLast1Min, $oid_nsResCpuLast5Min,
$oid_nsResCpuLast15Min], nothing_quit => 1);
my $cpu1min = $result->{$oid_nsResCpuLast1Min};
my $cpu5min = $result->{$oid_nsResCpuLast5Min};
my $cpu15min = $result->{$oid_nsResCpuLast15Min};
my $exit1 = $self->{perfdata}->threshold_check(value => $cpu1min,
threshold => [ { label => 'crit1min', 'exit_litteral' => 'critical' }, { label => 'warn1min', exit_litteral => 'warning' } ]);
my $exit2 = $self->{perfdata}->threshold_check(value => $cpu5min,
threshold => [ { label => 'crit5min', 'exit_litteral' => 'critical' }, { label => 'warn5min', exit_litteral => 'warning' } ]);
my $exit3 = $self->{perfdata}->threshold_check(value => $cpu15min,
threshold => [ { label => 'crit15min', 'exit_litteral' => 'critical' }, { label => 'warn15min', exit_litteral => 'warning' } ]);
my $exit = $self->{output}->get_most_critical(status => [ $exit1, $exit2, $exit3 ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU Usage: %.2f%% (1min), %.2f%% (5min), %.2f%% (15min)",
$cpu1min, $cpu5min, $cpu15min));
$self->{output}->perfdata_add(label => "cpu_1min",
value => $cpu1min,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1min'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1min'),
min => 0, max => 100);
$self->{output}->perfdata_add(label => "cpu_5min",
value => $cpu5min,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5min'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5min'),
min => 0, max => 100);
$self->{output}->perfdata_add(label => "cpu_15min",
value => $cpu15min,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn15min'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit15min'),
min => 0, max => 100);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check Juniper cpu usage (NETSCREEN-RESOURCE-MIB).
=over 8
=item B<--warning>
Threshold warning in percent (1min,5min,15min).
=item B<--critical>
Threshold critical in percent (1min,5min,15min).
=back
=cut

View File

@ -0,0 +1,173 @@
################################################################################
# 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 : Stephane Duret <sduret@merethis.com>
#
####################################################################################
package network::juniper::common::screenos::mode::hardware;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use network::juniper::common::screenos::mode::components::fan;
use network::juniper::common::screenos::mode::components::module;
use network::juniper::common::screenos::mode::components::psu;
use network::juniper::common::screenos::mode::components::temperature;
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 =>
{
"exclude:s" => { name => 'exclude' },
"component:s" => { name => 'component', default => 'all' },
"warning:s" => { name => 'warning', default => '' },
"critical:s" => { name => 'critical', default => '' },
});
$self->{components} = {};
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
$self->{output}->option_exit();
}
}
sub global {
my ($self, %options) = @_;
network::juniper::common::screenos::mode::components::temperature::check($self);
network::juniper::common::screenos::mode::components::fan::check($self);
network::juniper::common::screenos::mode::components::module::check($self);
network::juniper::common::screenos::mode::components::psu::check($self);
}
sub run {
my ($self, %options) = @_;
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
if ($self->{option_results}->{component} eq 'all') {
$self->global();
} elsif ($self->{option_results}->{component} eq 'fan') {
network::juniper::common::screenos::mode::components::fan::check($self);
} elsif ($self->{option_results}->{component} eq 'module') {
network::juniper::common::screenos::mode::components::module::check($self);
} elsif ($self->{option_results}->{component} eq 'psu') {
network::juniper::common::screenos::mode::components::psu::check($self);
} elsif ($self->{option_results}->{component} eq 'temperature') {
network::juniper::common::screenos::mode::components::temperature::check($self);
} else {
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
$self->{output}->option_exit();
}
my $total_components = 0;
my $display_by_component = '';
my $display_by_component_append = '';
foreach my $comp (sort(keys %{$self->{components}})) {
# Skipping short msg when no components
next if ($self->{components}->{$comp}->{total} == 0);
$total_components += $self->{components}->{$comp}->{total};
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . ' ' . $self->{components}->{$comp}->{name};
$display_by_component_append = ', ';
}
$self->{output}->output_add(severity => 'OK',
short_msg => sprintf("All %s components [%s] are ok.",
$total_components,
$display_by_component
)
);
$self->{output}->display();
$self->{output}->exit();
}
sub check_exclude {
my ($self, $section) = @_;
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$section(\s|,|$)/) {
$self->{output}->output_add(long_msg => sprintf("Skipping $section section."));
return 1;
}
return 0;
}
1;
__END__
=head1 MODE
Check hardware (fans, power supplies).
=over 8
=item B<--component>
Which component to check (Default: 'all').
Can be: 'fan', 'psu', 'module'.
=item B<--exclude>
Exclude some parts (comma seperated list) (Example: --exclude=fans,modules)
Can also exclude specific instance: --exclude=fans#1#2#,modules#1#,psus
=item B<--warning>
Threshold warning in degree celsius.
=item B<--critical>
Threshold critical in degree celsius.
=back
=cut

View File

@ -33,7 +33,7 @@
#
####################################################################################
package network::juniper::common::netscreen::memory;
package network::juniper::common::screenos::mode::memory;
use base qw(centreon::plugins::mode);
@ -74,14 +74,14 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
my $oid_MemStatsUsed = '.1.3.6.1.4.1.3224.16.2.1.0';
my $oid_MemStatsFree = '.1.3.6.1.4.1.3224.16.2.2.0';
my $oid_MemStatsFragmented = '.1.3.6.1.4.1.3224.16.2.3.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_MemStatsUsed, $oid_MemStatsFree, $oid_MemStatsFragmented], nothing_quit => 1);
my $oid_nsResMemAllocate= '.1.3.6.1.4.1.3224.16.2.1.0';
my $oid_nsResMemLeft = '.1.3.6.1.4.1.3224.16.2.2.0';
my $oid_nsResMemFrag = '.1.3.6.1.4.1.3224.16.2.3.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_nsResMemAllocate, $oid_nsResMemLeft, $oid_nsResMemFrag], nothing_quit => 1);
my $memory_used = $result->{$oid_MemStatsUsed};
my $memory_free = $result->{$oid_MemStatsFree};
my $memory_frag = $result->{$oid_MemStatsFragmented};
my $memory_used = $result->{$oid_nsResMemAllocate};
my $memory_free = $result->{$oid_nsResMemLeft};
my $memory_frag = $result->{$oid_nsResMemFrag};
my $total_size = $memory_used + $memory_free + $memory_frag;
my $prct_used = $memory_used * 100 / $total_size;
@ -107,6 +107,10 @@ sub run {
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $total_size),
min => 0, max => $total_size);
$self->{output}->perfdata_add(label => "fragmented",
value => $memory_frag,
min => 0, max => $total_size);
$self->{output}->display();
$self->{output}->exit();
}
@ -117,7 +121,7 @@ __END__
=head1 MODE
Check Juniper SSG memory usage (NETSCREEN-RESOURCE-MIB).
Check Juniper memory usage (NETSCREEN-RESOURCE-MIB).
=over 8

View File

@ -33,7 +33,7 @@
#
####################################################################################
package network::juniper::common::netscreen::sessions;
package network::juniper::common::screenos::mode::sessions;
use base qw(centreon::plugins::mode);
@ -74,14 +74,14 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
my $oid_ssgCurrentSession = '.1.3.6.1.4.1.3224.16.3.2.0';
my $oid_ssgMaxSession = '.1.3.6.1.4.1.3224.16.3.3.0';
my $oid_nsResSessAllocate = '.1.3.6.1.4.1.3224.16.3.2.0';
my $oid_nsResSessMaxium = '.1.3.6.1.4.1.3224.16.3.3.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_ssgCurrentSession, $oid_ssgMaxSession], nothing_quit => 1);
my $result = $self->{snmp}->get_leef(oids => [$oid_nsResSessAllocate, $oid_nsResSessMaxium], nothing_quit => 1);
my $spu_done = 0;
my $cp_total = $result->{$oid_ssgMaxSession};
my $cp_used = $result->{$oid_ssgCurrentSession};
my $cp_total = $result->{$oid_nsResSessMaxium};
my $cp_used = $result->{$oid_nsResSessAllocate};
my $prct_used = $cp_used * 100 / $cp_total;
@ -93,8 +93,8 @@ sub run {
$prct_used, $cp_used, $cp_total));
$self->{output}->perfdata_add(label => 'sessions',
value => $cp_used,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $cp_total),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $cp_total),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $cp_total, cast_int => 1),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $cp_total, cast_int => 1),
min => 0, max => $cp_total);
if ($spu_done == 0) {
@ -112,7 +112,7 @@ __END__
=head1 MODE
Check CP ('central point') sessions usage.
Check Juniper sessions usage (NETSCREEN-RESOURCE-MIB).
=over 8

View File

@ -47,12 +47,12 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'cpu' => 'network::juniper::common::netscreen::cpu',
'memory' => 'network::juniper::common::netscreen::memory',
'session' => 'network::juniper::common::netscreen::sessions',
'temperature' => 'network::juniper::common::netscreen::temperature',
'traffic' => 'snmp_standard::mode::traffic',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'cpu' => 'network::juniper::common::screenos::mode::cpu',
'memory' => 'network::juniper::common::screenos::mode::memory',
'sessions' => 'network::juniper::common::screenos::mode::sessions',
'hardware' => 'network::juniper::common::screenos::mode::hardware',
'traffic' => 'snmp_standard::mode::traffic',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
);
return $self;