Refs #5698
Can use p2000 hardware Begin volume-stats. Begin to work on some class to help do some calc (need to work on name). Could be extend the class for specific calc :)
This commit is contained in:
parent
c18bf9104f
commit
a4128e04b6
|
@ -0,0 +1,190 @@
|
|||
################################################################################
|
||||
# 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 centreon::plugins::class::bytes;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
$self->{statefile} = $options{statefile};
|
||||
$self->{output} = $options{output};
|
||||
$self->{perfdata} = $options{perfdata};
|
||||
$self->{label} = $options{label};
|
||||
|
||||
$self->{perfdata_template} = '%s';
|
||||
$self->{perfdata_use} = 'absolute';
|
||||
$self->{perfdata_extra_instance} = 1;
|
||||
|
||||
$self->{output_template} = $self->{label} . ': %s %s';
|
||||
$self->{output_use} = ['absolute'];
|
||||
$self->{output_change_bytes} = 1;
|
||||
|
||||
$self->{absolute_unit} = 'B';
|
||||
$self->{per_second_unit} = 'B';
|
||||
|
||||
$self->{per_second} = 0;
|
||||
$self->{last_timestamp} = undef;
|
||||
|
||||
$self->{result_values} = {};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub init {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning-' . $self->{label}, value => $self->{option_results}->{'warning-' . $self->{label}})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning-" . $self->{label} . " threshold '" . $self->{option_results}->{'warning-' . $self->{label}} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical-' . $self->{label}, value => $self->{option_results}->{'critical-' . $self->{label}})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical-" . $self->{label} . " threshold '" . $self->{option_results}->{'warning-' . $self->{label}} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub set {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output_template} = $options{output_template} if (defined($options{output_template}));
|
||||
$self->{per_second} = $options{per_second} if (defined($options{per_second}));
|
||||
$self->{instance} = $options{instance} if (defined($options{instance}));
|
||||
$self->{key_values} = $options{key_values} if (defined($options{key_values}));
|
||||
$self->{perfdata_extra_instance} = $options{perfdata_extra_instance} if (defined($options{perfdata_extra_instance}));
|
||||
$self->{perfdata_template} = $options{perfdata_template} if (defined($options{perfdata_template}));
|
||||
$self->{perfdata_use} = $options{perfdata_template} if (defined($options{perfdata_use}));
|
||||
$self->{output_change_bytes} = $options{output_change_bytes} if (defined($options{output_change_bytes}));
|
||||
$self->{absolute_unit} = $options{absolute_unit} if (defined($options{absolute_unit}));
|
||||
$self->{per_second_unit} = $options{per_second_unit} if (defined($options{per_second_unit}));
|
||||
}
|
||||
|
||||
sub calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
# manage only one value ;)
|
||||
my $name = ${$self->{key_values}}[0];
|
||||
|
||||
if ($self->{per_second} == 1) {
|
||||
$self->{result_values}->{per_second} = ($options{new_datas}->{$self->{instance} . '_' . $name} - $options{old_datas}->{$self->{instance} . '_' . $name}) / $options{delta_time}
|
||||
}
|
||||
$self->{result_values}->{absolute} = ($options{new_datas}->{$self->{instance} . '_' . $name} - $options{old_datas}->{$self->{instance} . '_' . $name});
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub check_threshold {
|
||||
my ($self, %options) = @_;
|
||||
my $value = $self->{result_values}->{absolute};
|
||||
|
||||
if ($self->{per_second} == 1) {
|
||||
$value = $self->{result_values}->{per_second};
|
||||
}
|
||||
return $self->{perfdata}->threshold_check(value => $value, threshold => [ { label => 'warning-' . $self->{label}, 'exit_litteral' => 'critical' },
|
||||
{ label => 'critical-' . $self->{label}, 'exit_litteral' => 'warning' }]);
|
||||
}
|
||||
|
||||
sub output {
|
||||
my ($self, %options) = @_;
|
||||
my ($value, $unit) = ($self->{result_values}->{absolute}, $self->{result_values}->{absolute_unit});
|
||||
|
||||
if ($self->{per_second} == 1) {
|
||||
$value = $self->{result_values}->{per_second};
|
||||
$unit = $self->{per_second_unit};
|
||||
}
|
||||
if ($self->{output_change_bytes} == 1) {
|
||||
($value, $unit) = $self->{perfdata}->change_bytes(value => $value);
|
||||
}
|
||||
|
||||
return sprintf($self->{output_template}, $value, $unit);
|
||||
}
|
||||
|
||||
sub perfdata {
|
||||
my ($self, %options) = @_;
|
||||
my $extra_label = '';
|
||||
|
||||
$extra_label .= '_' . $self->{instance} if ($self->{perfdata_extra_instance} == 1);
|
||||
$self->{output}->perfdata_add(label => $self->{label} . $extra_label, unit => $self->{perfdata_unit},
|
||||
value => sprintf($self->{perfdata_template}, $self->{result_values}->{$self->{perfdata_use}}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}),
|
||||
min => 0);
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, %options) = @_;
|
||||
my $old_datas = {};
|
||||
|
||||
my $quit = 0;
|
||||
foreach my $value (@{$self->{key_values}}) {
|
||||
$options{new_datas}->{$self->{instance} . '_' . $value} = $options{values}->{$value};
|
||||
$old_datas->{$self->{instance} . '_' . $value} = $self->{statefile}->get(name => $self->{instance} . '_' . $value);
|
||||
if (!defined($old_datas->{$self->{instance} . '_' . $value})) {
|
||||
$quit = 1;
|
||||
next;
|
||||
}
|
||||
if ($old_datas->{$self->{instance} . '_' . $value} > $options{new_datas}->{$self->{instance} . '_' . $value}) {
|
||||
$old_datas->{$self->{instance} . '_' . $value} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return undef if ($quit == 1);
|
||||
|
||||
if ($self->{per_second} == 1) {
|
||||
if (!defined($self->{last_timestamp})) {
|
||||
$self->{last_timestamp} = $self->{statefile}->get(name => 'last_timestamp');
|
||||
}
|
||||
return undef if (!defined($self->{last_timestamp}));
|
||||
}
|
||||
|
||||
my $delta_time;
|
||||
if ($self->{per_second} == 1) {
|
||||
$delta_time = $options{new_datas}->{last_timestamp} - $self->{last_timestamp};
|
||||
if ($delta_time <= 0) {
|
||||
$delta_time = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $self->calc(old_datas => $old_datas, new_datas => $options{new_datas}, delta_time => $delta_time);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
|
@ -119,7 +119,7 @@ sub check_options {
|
|||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? shift(@{$self->{option_results}->{hostname}}) : undef;
|
||||
$self->{username} = (defined($self->{option_results}->{username})) ? shift(@{$self->{option_results}->{username}}) : undef;
|
||||
$self->{password} = (defined($self->{option_results}->{password})) ? shift(@{$self->{option_results}->{password}}) : undef;
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 30;
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? shift(@{$self->{option_results}->{timeout}}) : 45;
|
||||
$self->{port} = (defined($self->{option_results}->{port})) ? shift(@{$self->{option_results}->{port}}) : undef;
|
||||
$self->{proto} = (defined($self->{option_results}->{proto})) ? shift(@{$self->{option_results}->{proto}}) : 'http';
|
||||
$self->{url_path} = (defined($self->{option_results}->{url_path})) ? shift(@{$self->{option_results}->{url_path}}) : '/api/';
|
||||
|
@ -201,6 +201,46 @@ sub DESTROY {
|
|||
}
|
||||
}
|
||||
|
||||
sub get_infos {
|
||||
my ($self, %options) = @_;
|
||||
my ($xpath, $nodeset);
|
||||
|
||||
my $cmd = $options{cmd};
|
||||
$cmd =~ s/ /\//g;
|
||||
$self->{option_results}->{url_path} = $self->{url_path} . $cmd;
|
||||
my $response = centreon::plugins::httplib::connect($self,
|
||||
headers => {dataType => 'api', sessionKey => $self->{session_id} });
|
||||
|
||||
eval {
|
||||
$xpath = XML::XPath->new(xml => $response);
|
||||
$nodeset = $xpath->find("//OBJECT[\@basetype='" . $options{base_type} . "']");
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot parse 'cmd' response: $@");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $results = {};
|
||||
foreach my $node ($nodeset->get_nodelist()) {
|
||||
my $properties = {};
|
||||
|
||||
foreach my $prop_node ($node->getChildNodes()) {
|
||||
my $prop_name = $prop_node->getAttribute('name');
|
||||
|
||||
if (defined($prop_name) && ($prop_name eq $options{key} ||
|
||||
$prop_name =~ /$options{properties_name}/)) {
|
||||
$properties->{$prop_name} = $prop_node->string_value;
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($properties->{$options{key}})) {
|
||||
$results->{$properties->{$options{key}}} = $properties;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
##############
|
||||
# Specific methods
|
||||
##############
|
||||
|
@ -214,19 +254,6 @@ sub login {
|
|||
$self->{option_results}->{url_path} = $self->{url_path} . 'login/' . $md5_hash;
|
||||
my $response = centreon::plugins::httplib::connect($self);
|
||||
$self->check_login(content => $response);
|
||||
|
||||
# test disk
|
||||
$self->{option_results}->{url_path} = $self->{url_path} . 'show/disks';
|
||||
$response = centreon::plugins::httplib::connect($self,
|
||||
headers => {dataType => 'api', sessionKey => $self->{session_id} });
|
||||
use Data::Dumper;
|
||||
print Data::Dumper::Dumper($response);
|
||||
|
||||
$self->{option_results}->{url_path} = $self->{url_path} . 'show/sensor-status';
|
||||
$response = centreon::plugins::httplib::connect($self,
|
||||
headers => {dataType => 'api', sessionKey => $self->{session_id} });
|
||||
use Data::Dumper;
|
||||
print Data::Dumper::Dumper($response);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -38,38 +38,46 @@ package storage::hp::p2000::xmlapi::mode::components::disk;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %conditions = (
|
||||
1 => ['^Not Ready$' => 'WARNING'],
|
||||
2 => ['^(?!(Present|Valid)$)' => 'CRITICAL'],
|
||||
my @conditions = (
|
||||
['^degraded$' => 'WARNING'],
|
||||
['^failed$' => 'CRITICAL'],
|
||||
['^(unknown|not available)$' => 'UNKNOWN'],
|
||||
);
|
||||
|
||||
my %health = (
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
2 => 'failed',
|
||||
3 => 'unknown',
|
||||
4 => 'not available',
|
||||
);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking batteries");
|
||||
$self->{components}->{battery} = {name => 'battery', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'battery'));
|
||||
$self->{output}->output_add(long_msg => "Checking disks");
|
||||
$self->{components}->{disk} = {name => 'disks', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'disk'));
|
||||
|
||||
# SPS means = Standby Power Supply
|
||||
my $results = $self->{p2000}->get_infos(cmd => 'show disks',
|
||||
base_type => 'drives',
|
||||
key => 'durable-id',
|
||||
properties_name => '^health-numeric$');
|
||||
|
||||
# Enclosure SPE SPS A State: Present
|
||||
while ($self->{response} =~ /^(?:Bus\s+(\d+)\s+){0,1}Enclosure\s+(\S+)\s+(SPS)\s+(\S+)\s+State:\s+(.*)$/mgi) {
|
||||
my ($state, $instance) = ($5, "$2.$3.$4");
|
||||
if (defined($1)) {
|
||||
$instance = "$1.$2.$3.$4";
|
||||
}
|
||||
foreach my $disk_id (keys %$results) {
|
||||
next if ($self->check_exclude(section => 'disk', instance => $disk_id));
|
||||
$self->{components}->{disk}->{total}++;
|
||||
|
||||
next if ($self->check_exclude(section => 'battery', instance => $instance));
|
||||
$self->{components}->{battery}->{total}++;
|
||||
my $state = $health{$results->{$disk_id}->{'health-numeric'}};
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Battery '%s' state is %s.",
|
||||
$instance, $state)
|
||||
$self->{output}->output_add(long_msg => sprintf("Disk '%s' status is %s.",
|
||||
$disk_id, $state)
|
||||
);
|
||||
foreach (keys %conditions) {
|
||||
if ($state =~ /${$conditions{$_}}[0]/i) {
|
||||
$self->{output}->output_add(severity => ${$conditions{$_}}[1],
|
||||
short_msg => sprintf("Battery '%s' state is %s",
|
||||
$instance, $state));
|
||||
foreach (@conditions) {
|
||||
if ($state =~ /$$_[0]/i) {
|
||||
$self->{output}->output_add(severity => $$_[1],
|
||||
short_msg => sprintf("Disk '%s' status is %s",
|
||||
$disk_id, $state));
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
################################################################################
|
||||
# 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 storage::hp::p2000::xmlapi::mode::components::enclosure;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my @conditions = (
|
||||
['^degraded$' => 'WARNING'],
|
||||
['^failed$' => 'CRITICAL'],
|
||||
['^(unknown|not available)$' => 'UNKNOWN'],
|
||||
);
|
||||
|
||||
my %health = (
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
2 => 'failed',
|
||||
3 => 'unknown',
|
||||
4 => 'not available',
|
||||
);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking enclosures");
|
||||
$self->{components}->{enclosure} = {name => 'enclosures', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'enclosure'));
|
||||
|
||||
my $results = $self->{p2000}->get_infos(cmd => 'show enclosures',
|
||||
base_type => 'enclosures',
|
||||
key => 'durable-id',
|
||||
properties_name => '^health-numeric|health-reason$');
|
||||
foreach my $enc_id (keys %$results) {
|
||||
next if ($self->check_exclude(section => 'enclosure', instance => $enc_id));
|
||||
$self->{components}->{enclosure}->{total}++;
|
||||
|
||||
my $state = $health{$results->{$enc_id}->{'health-numeric'}};
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("enclosure '%s' status is %s.",
|
||||
$enc_id, $state)
|
||||
);
|
||||
foreach (@conditions) {
|
||||
if ($state =~ /$$_[0]/i) {
|
||||
$self->{output}->output_add(severity => $$_[1],
|
||||
short_msg => sprintf("enclosure '%s' status is %s (reason: %s)",
|
||||
$enc_id, $state, $health{$results->{$enc_id}->{'health-reason'}}));
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -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 : Quentin Garnier <qgarnier@merethis.com>
|
||||
#
|
||||
####################################################################################
|
||||
|
||||
package storage::hp::p2000::xmlapi::mode::components::fru;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my @conditions = (
|
||||
['^absent$' => 'WARNING'],
|
||||
['^fault$' => 'CRITICAL'],
|
||||
['^not available$' => 'UNKNOWN'],
|
||||
);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking frus");
|
||||
$self->{components}->{fru} = {name => 'frus', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'fru'));
|
||||
|
||||
my $results = $self->{p2000}->get_infos(cmd => 'show frus',
|
||||
base_type => 'enclosure-fru',
|
||||
key => 'part-number',
|
||||
properties_name => '^(fru-status|fru-location)$');
|
||||
foreach my $part_number (keys %$results) {
|
||||
my $instance = $results->{$part_number}->{'fru-location'};
|
||||
|
||||
next if ($self->check_exclude(section => 'fru', instance => $instance));
|
||||
$self->{components}->{fru}->{total}++;
|
||||
|
||||
my $state = $results->{$part_number}->{'fru-status'};
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("fru '%s' status is %s.",
|
||||
$instance, $state)
|
||||
);
|
||||
foreach (@conditions) {
|
||||
if ($state =~ /$$_[0]/i) {
|
||||
$self->{output}->output_add(severity => $$_[1],
|
||||
short_msg => sprintf("fru '%s' status is %s",
|
||||
$instance, $state));
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,96 @@
|
|||
################################################################################
|
||||
# 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 storage::hp::p2000::xmlapi::mode::components::sensors;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my @conditions = (
|
||||
['^warning|not installed|unavailable$' => 'WARNING'],
|
||||
['^error|unrecoverable$' => 'CRITICAL'],
|
||||
['^unknown|unsupported$' => 'UNKNOWN'],
|
||||
);
|
||||
|
||||
my %sensor_type = (
|
||||
# 2 it's other. Can be ok or '%'. Need to regexp
|
||||
3 => { unit => 'C' },
|
||||
6 => { unit => 'V' },
|
||||
9 => { unit => 'V' },
|
||||
);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking sensors");
|
||||
$self->{components}->{sensor} = {name => 'sensors', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'sensor'));
|
||||
|
||||
# We don't use status-numeric. Values are buggy !!!???
|
||||
my $results = $self->{p2000}->get_infos(cmd => 'show sensor-status',
|
||||
base_type => 'sensors',
|
||||
key => 'sensor-name',
|
||||
properties_name => '^(value|sensor-type|status)$');
|
||||
|
||||
foreach my $sensor_id (keys %$results) {
|
||||
next if ($self->check_exclude(section => 'sensor', instance => $sensor_id));
|
||||
$self->{components}->{sensor}->{total}++;
|
||||
|
||||
my $state = $results->{$sensor_id}->{status};
|
||||
|
||||
$results->{$sensor_id}->{value} =~ /\s*([0-9\.,]+)\s*(\S*)\s*/;
|
||||
my ($value, $unit) = ($1, $2);
|
||||
if (defined($sensor_type{$results->{$sensor_id}->{'sensor-type'}})) {
|
||||
$unit = $sensor_type{$results->{$sensor_id}->{'sensor-type'}}->{unit};
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("sensor '%s' status is %s (value: %s %s).",
|
||||
$sensor_id, $state, $value, $unit)
|
||||
);
|
||||
foreach (@conditions) {
|
||||
if ($state =~ /$$_[0]/i) {
|
||||
$self->{output}->output_add(severity => $$_[1],
|
||||
short_msg => sprintf("sensor '%s' status is %s",
|
||||
$sensor_id, $state));
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => $sensor_id, unit => $unit,
|
||||
value => $value);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,87 @@
|
|||
################################################################################
|
||||
# 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 storage::hp::p2000::xmlapi::mode::components::vdisk;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my @conditions = (
|
||||
['^degraded$' => 'WARNING'],
|
||||
['^failed$' => 'CRITICAL'],
|
||||
['^(unknown|not available)$' => 'UNKNOWN'],
|
||||
);
|
||||
|
||||
my %health = (
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
2 => 'failed',
|
||||
3 => 'unknown',
|
||||
4 => 'not available',
|
||||
);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking vdisks");
|
||||
$self->{components}->{vdisk} = {name => 'vdisks', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'vdisk'));
|
||||
|
||||
my $results = $self->{p2000}->get_infos(cmd => 'show vdisks',
|
||||
base_type => 'virtual-disks',
|
||||
key => 'name',
|
||||
properties_name => '^health-numeric$');
|
||||
|
||||
foreach my $vdisk_id (keys %$results) {
|
||||
next if ($self->check_exclude(section => 'vdisk', instance => $vdisk_id));
|
||||
$self->{components}->{vdisk}->{total}++;
|
||||
|
||||
my $state = $health{$results->{$vdisk_id}->{'health-numeric'}};
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("vdisk '%s' status is %s.",
|
||||
$vdisk_id, $state)
|
||||
);
|
||||
foreach (@conditions) {
|
||||
if ($state =~ /$$_[0]/i) {
|
||||
$self->{output}->output_add(severity => $$_[1],
|
||||
short_msg => sprintf("vdisk '%s' status is %s",
|
||||
$vdisk_id, $state));
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -41,6 +41,10 @@ use strict;
|
|||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use storage::hp::p2000::xmlapi::mode::components::disk;
|
||||
use storage::hp::p2000::xmlapi::mode::components::vdisk;
|
||||
use storage::hp::p2000::xmlapi::mode::components::sensors;
|
||||
use storage::hp::p2000::xmlapi::mode::components::fru;
|
||||
use storage::hp::p2000::xmlapi::mode::components::enclosure;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -79,8 +83,20 @@ sub component {
|
|||
|
||||
if ($self->{option_results}->{component} eq 'all') {
|
||||
storage::hp::p2000::xmlapi::mode::components::disk::check($self);
|
||||
storage::hp::p2000::xmlapi::mode::components::vdisk::check($self);
|
||||
storage::hp::p2000::xmlapi::mode::components::sensors::check($self);
|
||||
storage::hp::p2000::xmlapi::mode::components::fru::check($self);
|
||||
storage::hp::p2000::xmlapi::mode::components::enclosure::check($self);
|
||||
} elsif ($self->{option_results}->{component} eq 'disk') {
|
||||
storage::hp::p2000::xmlapi::mode::components::disk::check($self);
|
||||
} elsif ($self->{option_results}->{component} eq 'vdisk') {
|
||||
storage::hp::p2000::xmlapi::mode::components::vdisk::check($self);
|
||||
} elsif ($self->{option_results}->{component} eq 'sensor') {
|
||||
storage::hp::p2000::xmlapi::mode::components::sensors::check($self);
|
||||
} elsif ($self->{option_results}->{component} eq 'fru') {
|
||||
storage::hp::p2000::xmlapi::mode::components::fru::check($self);
|
||||
} elsif ($self->{option_results}->{component} eq 'enclosure') {
|
||||
storage::hp::p2000::xmlapi::mode::components::enclosure::check($self);
|
||||
} else {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong option. Cannot find component '" . $self->{option_results}->{component} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
|
@ -149,12 +165,12 @@ Check health status of storage.
|
|||
=item B<--component>
|
||||
|
||||
Which component to check (Default: 'all').
|
||||
Can be: 'disk', 'xxx'.
|
||||
Can be: 'disk', 'vdisk', 'sensor', 'enclosure', 'fru'.
|
||||
|
||||
=item B<--exclude>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=fan,lcc)
|
||||
Can also exclude specific instance: --exclude=fan#1.2#,lcc
|
||||
Exclude some parts (comma seperated list) (Example: --exclude=fru)
|
||||
Can also exclude specific instance: --exclude=disk#disk_1.4#,sensor#Temperature Loc: lower-IOM B#
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
|
|
|
@ -0,0 +1,164 @@
|
|||
################################################################################
|
||||
# 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 storage::hp::p2000::xmlapi::mode::listvolumes;
|
||||
|
||||
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 =>
|
||||
{
|
||||
"name:s" => { name => 'name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"filter-type:s" => { name => 'filter_type' },
|
||||
});
|
||||
$self->{volume_name_selected} = [];
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $self->{p2000}->get_infos(cmd => 'show volumes',
|
||||
base_type => 'volumes',
|
||||
key => 'volume-name',
|
||||
properties_name => '^volume-type$');
|
||||
foreach my $name (keys %{$self->{results}}) {
|
||||
my $volume_type = $self->{results}->{$name}->{'volume-type'};
|
||||
|
||||
if (defined($self->{option_results}->{filter_type}) && $volume_type !~ /$self->{option_results}->{filter_type}/) {
|
||||
$self->{output}->output_add(long_msg => "Skipping volume '" . $name . "': no matching filter type");
|
||||
next;
|
||||
}
|
||||
|
||||
# Get all without a name
|
||||
if (!defined($self->{option_results}->{name})) {
|
||||
push @{$self->{volume_name_selected}}, $name;
|
||||
next;
|
||||
}
|
||||
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $name eq $self->{option_results}->{name}) {
|
||||
push @{$self->{volume_name_selected}}, $name;
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{use_regexp}) && $name =~ /$self->{option_results}->{name}/) {
|
||||
push @{$self->{volume_name_selected}}, $name;
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Skipping volume '" . $name . "': no matching filter name");
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{p2000} = $options{custom};
|
||||
|
||||
$self->{p2000}->login();
|
||||
$self->manage_selection();
|
||||
foreach my $name (sort @{$self->{volume_name_selected}}) {
|
||||
$self->{output}->output_add(long_msg => "'" . $name . "' [type = " . $self->{results}->{$name}->{'volume-type'} . "]");
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'List volumes:');
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => ['name', 'type']);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
my ($self, %options) = @_;
|
||||
$self->{p2000} = $options{custom};
|
||||
|
||||
$self->{p2000}->login();
|
||||
$self->manage_selection();
|
||||
foreach my $name (sort @{$self->{volume_name_selected}}) {
|
||||
$self->{output}->add_disco_entry(name => $name, type => $self->{results}->{$name}->{'volume-type'});
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
List volumes.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--name>
|
||||
|
||||
Set the volume name.
|
||||
|
||||
=item B<--regexp>
|
||||
|
||||
Allows to use regexp to filter volume name (with option --name).
|
||||
|
||||
=item B<--filter-type>
|
||||
|
||||
Filter volume type. Regexp can be used.
|
||||
Available types are:
|
||||
- 'standard',
|
||||
- 'standard*',
|
||||
- 'snap-pool',
|
||||
- 'master volume',
|
||||
- 'snapshot',
|
||||
- 'replication source'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
################################################################################
|
||||
# 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 storage::hp::p2000::xmlapi::mode::volumesstats;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::statefile;
|
||||
use centreon::plugins::class::bytes;
|
||||
|
||||
my $maps_counters = {
|
||||
read => { class => 'centreon::plugins::class::bytes', obj => undef,
|
||||
set => {
|
||||
key_values => [
|
||||
'data-read-numeric',
|
||||
],
|
||||
output_template => 'Read I/O : %s %s/s', per_second => 1,
|
||||
}
|
||||
},
|
||||
write => { class => 'centreon::plugins::class::bytes', obj => undef,
|
||||
set => {
|
||||
key_values => [
|
||||
'data-written-numeric',
|
||||
],
|
||||
output_template => 'Write I/O : %s %s/s', per_second => 1,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
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 =>
|
||||
{
|
||||
"name:s" => { name => 'name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
});
|
||||
$self->{volume_name_selected} = [];
|
||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
foreach (keys %{$maps_counters}) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $_ . ':s' => { name => 'warning-' . $_ },
|
||||
'critical-' . $_ . ':s' => { name => 'critical-' . $_ },
|
||||
});
|
||||
my $class = $maps_counters->{$_}->{class};
|
||||
$maps_counters->{$_}->{obj} = $class->new(statefile => $self->{statefile_value},
|
||||
output => $self->{output}, perfdata => $self->{perfdata},
|
||||
label => $_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach (keys %{$maps_counters}) {
|
||||
foreach my $name (keys %{$maps_counters->{$_}->{thresholds}}) {
|
||||
if (($self->{perfdata}->threshold_validate(label => $maps_counters->{$_}->{thresholds}->{$name}->{label}, value => $self->{option_results}->{$name})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong " . $maps_counters->{$_}->{thresholds}->{$name}->{label} . " threshold '" . $self->{option_results}->{$name} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{statefile_value}->check_options(%options);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{results} = $self->{p2000}->get_infos(cmd => 'show volume-statistics',
|
||||
base_type => 'volume-statistics',
|
||||
key => 'volume-name',
|
||||
properties_name => '^data-read-numeric|data-written-numeric|write-cache-hits|write-cache-misses|read-cache-hits|read-cache-misses|iops$');
|
||||
foreach my $name (keys %{$self->{results}}) {
|
||||
# Get all without a name
|
||||
if (!defined($self->{option_results}->{name})) {
|
||||
push @{$self->{volume_name_selected}}, $name;
|
||||
next;
|
||||
}
|
||||
|
||||
if (!defined($self->{option_results}->{use_regexp}) && $name eq $self->{option_results}->{name}) {
|
||||
push @{$self->{volume_name_selected}}, $name;
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{use_regexp}) && $name =~ /$self->{option_results}->{name}/) {
|
||||
push @{$self->{volume_name_selected}}, $name;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(@{$self->{volume_name_selected}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No volume found for name '" . $self->{option_results}->{name} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{p2000} = $options{custom};
|
||||
|
||||
$self->{p2000}->login();
|
||||
$self->manage_selection();
|
||||
|
||||
if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp})) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All volumes statistics are ok.');
|
||||
}
|
||||
$self->{new_datas} = {};
|
||||
$self->{statefile_value}->read(statefile => "cache_hp_p2000_" . $self->{p2000}->{hostname} . '_' . $self->{mode});
|
||||
$self->{new_datas}->{last_timestamp} = time();
|
||||
|
||||
foreach my $name (sort @{$self->{volume_name_selected}}) {
|
||||
my ($short_msg, $long_msg) = ('', '');
|
||||
my @exits;
|
||||
foreach (keys %{$maps_counters}) {
|
||||
$maps_counters->{$_}->{obj}->set(instance => $name,
|
||||
%{$maps_counters->{$_}->{set}},
|
||||
);
|
||||
|
||||
my ($value_check) = $maps_counters->{$_}->{obj}->execute(values => $self->{results}->{$name},
|
||||
new_datas => $self->{new_datas});
|
||||
|
||||
next if (!defined($value_check));
|
||||
my $exit2 = $maps_counters->{$_}->{obj}->check_threshold();
|
||||
push @exits, $exit2;
|
||||
|
||||
my $output = $maps_counters->{$_}->{obj}->output();
|
||||
$long_msg .= ' ' . $output;
|
||||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
||||
$short_msg .= ' ' . $output;
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata();
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Volume '$name':$long_msg");
|
||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => "Volume '$name':$short_msg"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$self->{statefile_value}->write(data => $self->{new_datas});
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check volume statistics.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'read', 'write', .
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Can be: 'read', 'write', .
|
||||
|
||||
=item B<--name>
|
||||
|
||||
Set the volume name.
|
||||
|
||||
=item B<--regexp>
|
||||
|
||||
Allows to use regexp to filter volume name (with option --name).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -48,7 +48,9 @@ sub new {
|
|||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'health' => 'storage::hp::p2000::xmlapi::mode::health',
|
||||
'health' => 'storage::hp::p2000::xmlapi::mode::health',
|
||||
'list-volumes' => 'storage::hp::p2000::xmlapi::mode::listvolumes',
|
||||
'volume-stats' => 'storage::hp::p2000::xmlapi::mode::volumesstats',
|
||||
);
|
||||
$self->{custom_modes}{p2000xml} = 'storage::hp::p2000::xmlapi::custom';
|
||||
|
||||
|
|
Loading…
Reference in New Issue