Fix 1061
This commit is contained in:
parent
fb813c45ba
commit
e5176fd40e
|
@ -30,10 +30,6 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
# $options{options} = options object
|
||||
# $options{output} = output object
|
||||
# $options{exit_value} = integer
|
||||
# $options{noptions} = integer
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
|
@ -46,13 +42,13 @@ sub new {
|
|||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s@" => { name => 'hostname' },
|
||||
"port:s@" => { name => 'port' },
|
||||
"proto:s@" => { name => 'proto' },
|
||||
"urlpath:s@" => { name => 'url_path' },
|
||||
"username:s@" => { name => 'username' },
|
||||
"password:s@" => { name => 'password' },
|
||||
"timeout:s@" => { name => 'timeout' },
|
||||
'hostname:s@' => { name => 'hostname' },
|
||||
'port:s@' => { name => 'port' },
|
||||
'proto:s@' => { name => 'proto' },
|
||||
'urlpath:s@' => { name => 'url_path' },
|
||||
'username:s@' => { name => 'username' },
|
||||
'password:s@' => { name => 'password' },
|
||||
'timeout:s@' => { name => 'timeout' },
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'P2000 OPTIONS', once => 1);
|
||||
|
@ -68,20 +64,15 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
# Method to manage multiples
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
# options{options_result}
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
# Method to manage multiples
|
||||
sub set_defaults {
|
||||
my ($self, %options) = @_;
|
||||
# options{default}
|
||||
|
||||
# Manage default value
|
||||
|
||||
foreach (keys %{$options{default}}) {
|
||||
if ($_ eq $self->{mode}) {
|
||||
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
|
||||
|
@ -97,8 +88,6 @@ sub set_defaults {
|
|||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
# return 1 = ok still hostname
|
||||
# return 0 = no hostname left
|
||||
|
||||
$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;
|
||||
|
@ -109,7 +98,7 @@ sub check_options {
|
|||
$self->{url_path} = (defined($self->{option_results}->{url_path})) ? shift(@{$self->{option_results}->{url_path}}) : '/api/';
|
||||
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify hostname option.");
|
||||
$self->{output}->add_option_msg(short_msg => 'Need to specify hostname option.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{username}) || !defined($self->{password})) {
|
||||
|
@ -216,7 +205,8 @@ sub get_infos {
|
|||
if ($return_code != 0) {
|
||||
$nodestatus = $xpath->find("//OBJECT[\@basetype='status']//PROPERTY[\@name='response']");
|
||||
@nodes = $nodestatus->get_nodelist();
|
||||
$node = shift @nodes;
|
||||
$node = shift @nodes;
|
||||
return ({}, 0, $node->string_value) if (defined($options{no_quit}) && $options{no_quit} == 1);
|
||||
$self->{output}->add_option_msg(short_msg => $node->string_value);
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
@ -240,7 +230,7 @@ sub get_infos {
|
|||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
return ($results, 1);
|
||||
}
|
||||
|
||||
##############
|
||||
|
|
|
@ -23,12 +23,6 @@ package storage::hp::p2000::xmlapi::mode::components::disk;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my @conditions = (
|
||||
['^degraded$' => 'WARNING'],
|
||||
['^failed$' => 'CRITICAL'],
|
||||
['^(unknown|not available)$' => 'UNKNOWN'],
|
||||
);
|
||||
|
||||
my %health = (
|
||||
0 => 'ok',
|
||||
1 => 'degraded',
|
||||
|
@ -41,32 +35,32 @@ sub check {
|
|||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking disks");
|
||||
$self->{components}->{disk} = {name => 'disks', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'disk'));
|
||||
|
||||
my $results = $self->{p2000}->get_infos(cmd => 'show disks',
|
||||
base_type => 'drives',
|
||||
key => 'durable-id',
|
||||
properties_name => '^health-numeric$');
|
||||
$self->{components}->{disk} = { name => 'disks', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'disk'));
|
||||
|
||||
my ($results) = $self->{custom}->get_infos(
|
||||
cmd => 'show disks',
|
||||
base_type => 'drives',
|
||||
key => 'durable-id',
|
||||
properties_name => '^health-numeric$',
|
||||
no_quit => 1
|
||||
);
|
||||
|
||||
foreach my $disk_id (keys %$results) {
|
||||
next if ($self->check_exclude(section => 'disk', instance => $disk_id));
|
||||
next if ($self->check_filter(section => 'disk', instance => $disk_id));
|
||||
$self->{components}->{disk}->{total}++;
|
||||
|
||||
my $state = $health{$results->{$disk_id}->{'health-numeric'}};
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Disk '%s' status is %s.",
|
||||
$disk_id, $state)
|
||||
$self->{output}->output_add(long_msg => sprintf("disk '%s' status is %s [instance: %s]",
|
||||
$disk_id, $state, $disk_id)
|
||||
);
|
||||
foreach (@conditions) {
|
||||
if ($state =~ /$$_[0]/i) {
|
||||
$self->{output}->output_add(severity => $$_[1],
|
||||
short_msg => sprintf("Disk '%s' status is %s",
|
||||
$disk_id, $state));
|
||||
last;
|
||||
}
|
||||
my $exit = $self->get_severity(label => 'default', section => 'disk', value => $state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Disk '%s' status is '%s'", $disk_id, $state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -23,12 +23,6 @@ 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',
|
||||
|
@ -42,30 +36,30 @@ sub check {
|
|||
|
||||
$self->{output}->output_add(long_msg => "Checking enclosures");
|
||||
$self->{components}->{enclosure} = {name => 'enclosures', total => 0, skip => 0};
|
||||
return if ($self->check_exclude(section => 'enclosure'));
|
||||
return if ($self->check_filter(section => 'enclosure'));
|
||||
|
||||
my $results = $self->{p2000}->get_infos(cmd => 'show enclosures',
|
||||
base_type => 'enclosures',
|
||||
key => 'durable-id',
|
||||
properties_name => '^health-numeric|health-reason$');
|
||||
my ($results) = $self->{custom}->get_infos(
|
||||
cmd => 'show enclosures',
|
||||
base_type => 'enclosures',
|
||||
key => 'durable-id',
|
||||
properties_name => '^health-numeric|health-reason$',
|
||||
no_quit => 1
|
||||
);
|
||||
foreach my $enc_id (keys %$results) {
|
||||
next if ($self->check_exclude(section => 'enclosure', instance => $enc_id));
|
||||
next if ($self->check_filter(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)
|
||||
$self->{output}->output_add(long_msg => sprintf("enclosure '%s' status is %s [instance: %s] [reason: %s]",
|
||||
$enc_id, $state, $enc_id, $health{$results->{$enc_id}->{'health-reason'}})
|
||||
);
|
||||
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;
|
||||
}
|
||||
my $exit = $self->get_severity(label => 'default', section => 'enclosure', value => $state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Enclosure '%s' status is '%s'", $enc_id, $state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -23,43 +23,37 @@ 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'));
|
||||
return if ($self->check_filter(section => 'fru'));
|
||||
|
||||
my $results = $self->{p2000}->get_infos(cmd => 'show frus',
|
||||
base_type => 'enclosure-fru',
|
||||
key => 'part-number',
|
||||
properties_name => '^(fru-status|fru-location)$');
|
||||
my ($results) = $self->{custom}->get_infos(
|
||||
cmd => 'show frus',
|
||||
base_type => 'enclosure-fru',
|
||||
key => 'part-number',
|
||||
properties_name => '^(fru-status|fru-location)$',
|
||||
no_quit => 1,
|
||||
);
|
||||
foreach my $part_number (keys %$results) {
|
||||
my $instance = $results->{$part_number}->{'fru-location'};
|
||||
|
||||
next if ($self->check_exclude(section => 'fru', instance => $instance));
|
||||
next if ($self->check_filter(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)
|
||||
$self->{output}->output_add(long_msg => sprintf("fru '%s' status is %s [instance: %s]",
|
||||
$instance, $state, $instance)
|
||||
);
|
||||
foreach (@conditions) {
|
||||
if ($state =~ /$$_[0]/i) {
|
||||
$self->{output}->output_add(severity => $$_[1],
|
||||
short_msg => sprintf("fru '%s' status is %s",
|
||||
$instance, $state));
|
||||
last;
|
||||
}
|
||||
my $exit = $self->get_severity(section => 'fru', value => $state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Fru '%s' status is '%s'", $instance, $state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
1;
|
||||
|
|
|
@ -18,36 +18,38 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::p2000::xmlapi::mode::components::sensors;
|
||||
package storage::hp::p2000::xmlapi::mode::components::sensor;
|
||||
|
||||
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' },
|
||||
3 => { unit => 'C', nunit => 'celsius', type => 'temperature' },
|
||||
6 => { unit => 'V', nunit => 'volt', type => 'voltage' },
|
||||
9 => { unit => 'V', nunit => 'volt', type => 'voltage' },
|
||||
);
|
||||
my %units = (
|
||||
C => { long => 'celsius', type => 'temperature' },
|
||||
V => { long => 'volt', type => 'voltage' },
|
||||
'' => { long => undef, type => 'misc' },
|
||||
'%' => { long => 'percentage', type => 'misc' },
|
||||
);
|
||||
|
||||
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'));
|
||||
$self->{output}->output_add(long_msg => "Checking sensor");
|
||||
$self->{components}->{sensor} = {name => 'sensor', total => 0, skip => 0};
|
||||
return if ($self->check_filter(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)$');
|
||||
my ($results) = $self->{custom}->get_infos(
|
||||
cmd => 'show sensor-status',
|
||||
base_type => 'sensors',
|
||||
key => 'sensor-name',
|
||||
properties_name => '^(value|sensor-type|status)$'
|
||||
);
|
||||
|
||||
#<OBJECT basetype="sensors" name="sensor" oid="22" format="rows">
|
||||
# <PROPERTY name="sensor-name" key="true" type="string" size="33" draw="true" sort="string" display-name="Sensor Name">Capacitor Charge-Ctlr B</PROPERTY>
|
||||
|
@ -60,35 +62,43 @@ sub check {
|
|||
# <PROPERTY name="status" type="string" size="8" draw="true" sort="string" display-name="Status">Warning</PROPERTY>
|
||||
#</OBJECT>
|
||||
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};
|
||||
|
||||
my ($value, $unit);
|
||||
($value, $unit) = ($1, $2) if ($results->{$sensor_id}->{value} =~ /\s*([0-9\.,]+)\s*(\S*)\s*/);
|
||||
if (defined($results->{$sensor_id}->{'sensor-type'}) && defined($sensor_type{$results->{$sensor_id}->{'sensor-type'}})) {
|
||||
$unit = $sensor_type{$results->{$sensor_id}->{'sensor-type'}}->{unit};
|
||||
}
|
||||
my $type = $units{$unit}->{type};
|
||||
|
||||
next if ($self->check_filter(section => 'sensor', instance => $type . '.' . $sensor_id));
|
||||
$self->{components}->{sensor}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("sensor '%s' status is %s (value: %s %s).",
|
||||
my $state = $results->{$sensor_id}->{status};
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("sensor '%s' status is %s (value: %s %s)",
|
||||
$sensor_id, $state, defined($value) ? $value : '-', defined($unit) ? $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;
|
||||
}
|
||||
my $exit = $self->get_severity(section => 'sensor', value => $state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("sensor '%s' status is '%s'", $sensor_id, $state));
|
||||
}
|
||||
|
||||
if (defined($value)) {
|
||||
$self->{output}->perfdata_add(
|
||||
label => $sensor_id, unit => $unit,
|
||||
value => $value
|
||||
);
|
||||
next if (!defined($value));
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sensor', instance => $type . '.' . $sensor_id, value => $value);
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Sensor '%s' is %s %s", $sensor_id, $value, defined($unit) ? $unit : '-'));
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'sensor', unit => $unit,
|
||||
nlabel => 'hardware.sensor.' . $type . (defined($units{$unit}->{long}) ? $units{$unit}->{long} : ''),
|
||||
instances => $sensor_id,
|
||||
value => $value,
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -23,12 +23,6 @@ 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',
|
||||
|
@ -37,36 +31,51 @@ my %health = (
|
|||
4 => 'not available',
|
||||
);
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
sub check_vdisk {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$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));
|
||||
foreach my $vdisk_id (keys %{$options{results}}) {
|
||||
next if ($self->check_filter(section => 'vdisk', instance => $vdisk_id));
|
||||
$self->{components}->{vdisk}->{total}++;
|
||||
|
||||
my $state = $health{$results->{$vdisk_id}->{'health-numeric'}};
|
||||
my $state = $health{$options{results}->{$vdisk_id}->{'health-numeric'}};
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("vdisk '%s' status is %s.",
|
||||
$vdisk_id, $state)
|
||||
$self->{output}->output_add(long_msg => sprintf("vdisk '%s' status is %s [instance: %s]",
|
||||
$vdisk_id, $state, $vdisk_id)
|
||||
);
|
||||
foreach (@conditions) {
|
||||
if ($state =~ /$$_[0]/i) {
|
||||
$self->{output}->output_add(severity => $$_[1],
|
||||
short_msg => sprintf("vdisk '%s' status is %s",
|
||||
$vdisk_id, $state));
|
||||
last;
|
||||
}
|
||||
my $exit = $self->get_severity(label => 'default', section => 'vdisk', value => $state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Vdisk '%s' status is '%s'", $vdisk_id, $state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
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_filter(section => 'vdisk'));
|
||||
|
||||
my ($results, $code) = $self->{custom}->get_infos(
|
||||
cmd => 'show vdisks',
|
||||
base_type => 'virtual-disks',
|
||||
key => 'name',
|
||||
properties_name => '^health-numeric$',
|
||||
no_quit => 1,
|
||||
);
|
||||
if ($code == 0) {
|
||||
($results) = $self->{custom}->get_infos(
|
||||
cmd => 'show disk-groups',
|
||||
base_type => 'disk-groups',
|
||||
key => 'name',
|
||||
properties_name => '^health-numeric$',
|
||||
no_quit => 1,
|
||||
);
|
||||
}
|
||||
|
||||
check_vdisk($self, results => $results);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -20,121 +20,63 @@
|
|||
|
||||
package storage::hp::p2000::xmlapi::mode::health;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
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 set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} =
|
||||
'^(disk|enclosure|fru|sensor|vdisk)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} =
|
||||
'^(sensor)$';
|
||||
|
||||
$self->{cb_hook1} = 'init_health';
|
||||
|
||||
$self->{thresholds} = {
|
||||
# disk, enclosure, vdisk
|
||||
default => [
|
||||
['degraded', 'WARNING'],
|
||||
['failed', 'CRITICAL'],
|
||||
['unknown|not available', 'UNKNOWN'],
|
||||
],
|
||||
fru => [
|
||||
['absent', 'WARNING'],
|
||||
['fault', 'CRITICAL'],
|
||||
['not available', 'UNKNOWN'],
|
||||
],
|
||||
sensor => [
|
||||
['warning|not installed|unavailable', 'WARNING'],
|
||||
['error|unrecoverable', 'CRITICAL'],
|
||||
['nknown|unsupported', 'UNKNOWN'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_exec_load} = 0;
|
||||
$self->{components_path} = 'storage::hp::p2000::xmlapi::mode::components';
|
||||
$self->{components_module} = ['disk', 'enclosure', 'fru', 'sensor', 'vdisk'];
|
||||
}
|
||||
|
||||
sub init_health {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{custom} = $options{custom};
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"component:s" => { name => 'component', default => 'all' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
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 component {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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 && $self->{components}->{$comp}->{skip} == 0);
|
||||
$total_components += $self->{components}->{$comp}->{total} + $self->{components}->{$comp}->{skip};
|
||||
$display_by_component .= $display_by_component_append . $self->{components}->{$comp}->{total} . '/' . $self->{components}->{$comp}->{skip} . ' ' . $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)
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{p2000} = $options{custom};
|
||||
|
||||
$self->{p2000}->login();
|
||||
$self->component();
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
sub check_exclude {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{instance})) {
|
||||
if (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)${options{section}}[^,]*#\Q$options{instance}\E#/) {
|
||||
$self->{components}->{$options{section}}->{skip}++;
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section $options{instance} instance."));
|
||||
return 1;
|
||||
}
|
||||
} elsif (defined($self->{option_results}->{exclude}) && $self->{option_results}->{exclude} =~ /(^|\s|,)$options{section}(\s|,|$)/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skipping $options{section} section."));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
@ -147,19 +89,35 @@ Check health status of storage.
|
|||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: 'all').
|
||||
Can be: 'disk', 'vdisk', 'sensor', 'enclosure', 'fru'.
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'disk', 'enclosure', 'fru', 'sensor', 'vdisk'.
|
||||
|
||||
=item B<--exclude>
|
||||
=item B<--filter>
|
||||
|
||||
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#
|
||||
Exclude some parts (comma seperated list) (Example: --filter=fru --filter=enclosure)
|
||||
Can also exclude specific instance: --filter=disk,1
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=item B<--threshold-overload>
|
||||
|
||||
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||
It used before default thresholds (order stays).
|
||||
Example: --threshold-overload='disk,OK,unknown'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for 'sensor' (syntax: type,instance,threshold)
|
||||
Example: --warning='sensor,temperature.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set warning threshold for 'sensors' (syntax: type,instance,threshold)
|
||||
Example: --warning='sensor,temperature.*,30'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -32,9 +32,9 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"name:s" => { name => 'name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"filter-type:s" => { name => 'filter_type' },
|
||||
'name:s' => { name => 'name' },
|
||||
'regexp" => { name => 'use_regexp' },
|
||||
'filter-type:s' => { name => 'filter_type' },
|
||||
});
|
||||
|
||||
$self->{volume_name_selected} = [];
|
||||
|
@ -50,10 +50,12 @@ sub check_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$');
|
||||
($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'};
|
||||
|
||||
|
|
|
@ -127,8 +127,8 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"name:s" => { name => 'name' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
'name:s' => { name => 'name' },
|
||||
'regexp' => { name => 'use_regexp' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -143,7 +143,7 @@ sub prefix_volume_output {
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = $options{custom}->get_infos(
|
||||
my ($result) = $options{custom}->get_infos(
|
||||
cmd => 'show volume-statistics',
|
||||
base_type => 'volume-statistics',
|
||||
key => 'volume-name',
|
||||
|
@ -165,11 +165,11 @@ sub manage_selection {
|
|||
}
|
||||
|
||||
if (scalar(keys %{$self->{volume}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No volume found.");
|
||||
$self->{output}->add_option_msg(short_msg => 'No volume found.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{cache_name} = "hp_p2000_" . $options{custom}->{hostname} . '_' . $self->{mode} . '_' .
|
||||
$self->{cache_name} = 'hp_p2000_' . $options{custom}->{hostname} . '_' . $self->{mode} . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' .
|
||||
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all'));
|
||||
}
|
||||
|
|
|
@ -32,21 +32,15 @@ sub new {
|
|||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'health' => 'storage::hp::p2000::xmlapi::mode::health',
|
||||
'list-volumes' => 'storage::hp::p2000::xmlapi::mode::listvolumes',
|
||||
'volume-stats' => 'storage::hp::p2000::xmlapi::mode::volumesstats',
|
||||
'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';
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub init {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
|
Loading…
Reference in New Issue