refactoring 3par plugin ssh
This commit is contained in:
parent
c37c23808d
commit
988900b25e
|
@ -1,157 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::battery;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %states = (
|
||||
'ok' => 'OK',
|
||||
'new' => 'OK',
|
||||
'degraded' => 'WARNING',
|
||||
'failed' => 'CRITICAL',
|
||||
);
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "showbattery",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my $total_components = 0;
|
||||
my @batteries = split("\n",$stdout);
|
||||
foreach my $battery (@batteries) {
|
||||
if ($battery =~ /\d+\s+(\d+)\s+(\d+)\s+\S+\s+(\S+)\s+(\d+)/) {
|
||||
$total_components++;
|
||||
my $psuId = $1;
|
||||
my $batteryId = $2;
|
||||
my $batteryState = $3;
|
||||
my $batteryChrgLvl = $4;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Battery '%d' on power supply '%d' is '%s' [Battery charge level: '%d%%']", $batteryId, $psuId, $batteryState, $batteryChrgLvl));
|
||||
if ($states{lc($batteryState)} ne 'OK'){
|
||||
$self->{output}->output_add(severity => $states{lc($batteryState)},
|
||||
short_msg => sprintf("Battery '%d' on power supply '%d' state is '%s' [Battery charge level: '%d%%']", $batteryId, $psuId, $batteryState, $batteryChrgLvl));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %d batteries are ok.", $total_components));
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check batteries.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,155 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::cim;
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"no-cim:s" => { name => 'no_cim' },
|
||||
});
|
||||
$self->{no_cim} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{no_cim})) {
|
||||
if ($self->{option_results}->{no_cim} ne '') {
|
||||
$self->{no_cim} = $self->{option_results}->{no_cim};
|
||||
} else {
|
||||
$self->{no_cim} = 'critical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "showcim",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my @results = split("\n",$stdout);
|
||||
my $total_cim = 0;
|
||||
foreach my $result (@results) {
|
||||
if ($result =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+\S+/) {
|
||||
$total_cim++;
|
||||
my $serviceStatus = $1;
|
||||
my $serviceState = $2;
|
||||
my $slpState = $3;
|
||||
my $slpPort = $4;
|
||||
my $httpState = $5;
|
||||
my $httpPort = $6;
|
||||
my $httpsState = $7;
|
||||
my $httpsPort = $8;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("CIM service is '%s' and '%s' [SLP on port %d is %s] [HTTP on port %d is %s] [HTTPS on port %d is %s]",
|
||||
$serviceStatus, $serviceState, $slpPort, $slpState, $httpPort, $httpState, $httpsPort ,$httpsState));
|
||||
if ((lc($serviceStatus) ne 'enabled') || (lc($serviceState) ne 'active')){
|
||||
$self->{output}->output_add(severity => 'critical',
|
||||
short_msg => sprintf("CIM service is '%s' and '%s' [SLP on port %d is %s] [HTTP on port %d is %s] [HTTPS on port %d is %s]",
|
||||
$serviceStatus, $serviceState, $slpPort, $slpState, $httpPort, $httpState, $httpsPort ,$httpsState));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'CIM service is ok.');
|
||||
|
||||
if (defined($self->{option_results}->{no_cim}) && $total_cim == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_cim},
|
||||
short_msg => 'No CIM service is checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check CIM service status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-cim>
|
||||
|
||||
Return an error if no CIM are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,156 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::iscsi;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %states = (
|
||||
'ready' => 'OK',
|
||||
'loss_sync' => 'WARNING',
|
||||
'offline' => 'CRITICAL',
|
||||
);
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "showport",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my $total_components = 0;
|
||||
my @iscsis = split("\n",$stdout);
|
||||
foreach my $iscsi (@iscsis) {
|
||||
if ($iscsi =~ /(\S+)\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)/) {
|
||||
my $iscsiNsp = $1;
|
||||
my $iscsiState = $2;
|
||||
my $iscsiType = $3;
|
||||
if($iscsiType eq 'iscsi') {
|
||||
$self->{output}->output_add(long_msg => sprintf("Interface '%s' is '%s'", $iscsiNsp, $iscsiState));
|
||||
if ($states{lc($iscsiState)} ne 'OK'){
|
||||
$self->{output}->output_add(severity => $states{lc($iscsiState)},
|
||||
short_msg => sprintf("Interface '%s' is '%s'", $iscsiNsp, $iscsiState));
|
||||
}
|
||||
$total_components++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %d ISCSIs are ok.", $total_components));
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check ISCSIs.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,156 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::node;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %states = (
|
||||
'ok' => 'OK',
|
||||
'new' => 'OK',
|
||||
'degraded' => 'WARNING',
|
||||
'failed' => 'CRITICAL',
|
||||
);
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "shownode -s",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my $total_components = 0;
|
||||
my @nodes = split("\n",$stdout);
|
||||
foreach my $node (@nodes) {
|
||||
if ($node =~ /(\d+)\s+(\S+)\s+(\S+)/) {
|
||||
$total_components++;
|
||||
my $nodeId = $1;
|
||||
my $nodeState = $2;
|
||||
my $detailNodeState = $3;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Node '%d' state is '%s' [Detailed State: %s]", $nodeId, $nodeState, $detailNodeState));
|
||||
if ($states{lc($nodeState)} ne 'OK'){
|
||||
$self->{output}->output_add(severity => $states{lc($nodeState)},
|
||||
short_msg => sprintf("Node '%d' state is '%s' [Detailed State: %s]", $nodeId, $nodeState, $detailNodeState));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %d nodes are ok.", $total_components));
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check nodes.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,155 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::physicaldisk;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %states = (
|
||||
'normal' => 'OK',
|
||||
'new' => 'OK',
|
||||
'degraded' => 'WARNING',
|
||||
'failed' => 'CRITICAL',
|
||||
);
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "showpd -showcols Id,State",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my $total_components = 0;
|
||||
my @disks = split("\n",$stdout);
|
||||
foreach my $disk (@disks) {
|
||||
if ($disk =~ /(\d+)\s+(\S+)/) {
|
||||
$total_components++;
|
||||
my $diskId = $1;
|
||||
my $diskState = $2;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Physical Disk '%d' state is '%s'", $diskId, $diskState));
|
||||
if ($states{$diskState} ne 'OK'){
|
||||
$self->{output}->output_add(severity => $states{$diskState},
|
||||
short_msg => sprintf("Physical Disk '%d' state is '%s'.", $diskId, $diskState));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %d physical disks are ok.", $total_components));
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Physical disks.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,157 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::psu;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %states = (
|
||||
'ok' => 'OK',
|
||||
'new' => 'OK',
|
||||
'degraded' => 'WARNING',
|
||||
'failed' => 'CRITICAL',
|
||||
);
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "shownode -ps",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my $total_components = 0;
|
||||
my @psus = split("\n",$stdout);
|
||||
foreach my $psu (@psus) {
|
||||
if ($psu =~ /\S+\s+(\d+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)/) {
|
||||
$total_components++;
|
||||
my $psuId = $1;
|
||||
my $ACState = $2;
|
||||
my $DCState = $3;
|
||||
my $psuState = $4;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Power Suppply '%d' state is '%s' [AC: %s] [DC: %s]", $psuId, $psuState, $ACState ,$DCState));
|
||||
if ($states{lc($psuState)} ne 'OK'){
|
||||
$self->{output}->output_add(severity => $states{lc($psuState)},
|
||||
short_msg => sprintf("Power Suppply '%d' state is '%s' [AC: %s] [DC: %s]", $psuId, $psuState, $ACState ,$DCState));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %d power supplies are ok.", $total_components));
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check power supplies.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,172 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::storage;
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"filter-type:s" => { name => 'filter_type' },
|
||||
"disk:s" => { name => 'disk' },
|
||||
"regexp" => { name => 'regexp' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
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) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "showpd",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my $total_disks = 0;
|
||||
my @disks = split("\n",$stdout);
|
||||
foreach my $disk (@disks) {
|
||||
if ($disk =~ /(\d+)\s+\S+\s+(\S+)\s+\d+\s+\S+\s+(\d+)\s+(\d+)\s+\S+\s+\S+\s+\d+/) {
|
||||
$total_disks++;
|
||||
my $diskId = $1;
|
||||
my $diskType = $2;
|
||||
my $diskSize = $3 * 1024 * 1024;
|
||||
my $diskFree = $4 * 1024 * 1024;
|
||||
my $diskUsed = $diskSize - $diskFree;
|
||||
my $percentUsed = ($diskUsed / $diskSize) * 100;
|
||||
my $percentFree = ($diskFree / $diskSize) * 100;
|
||||
|
||||
next if (defined($self->{option_results}->{filter_type}) && ($diskType !~ /$self->{option_results}->{filter_type}/i));
|
||||
next if (defined($self->{option_results}->{disk}) && defined($self->{option_results}->{regexp}) && ($diskId !~ /$self->{option_results}->{disk}/i));
|
||||
next if (defined($self->{option_results}->{disk}) && !defined($self->{option_results}->{regexp}) && ($diskId != $self->{option_results}->{disk}));
|
||||
|
||||
my ($diskSizeValue, $diskSizeUnit) = $self->{perfdata}->change_bytes(value => $diskSize);
|
||||
my ($diskUsedValue, $diskUsedUnit) = $self->{perfdata}->change_bytes(value => $diskUsed);
|
||||
my ($diskFreeValue, $diskFreeUnit) = $self->{perfdata}->change_bytes(value => $diskFree);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Disk '%d' Total: %.2f%s Used: %.2f%s (%.2f%%) Free: %.2f%s (%.2f%%)",
|
||||
$diskId, $diskSizeValue, $diskSizeUnit, $diskUsedValue, $diskUsedUnit, $percentUsed, $diskFreeValue, $diskFreeUnit, $percentFree));
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $percentUsed, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Disk '%d' Total: %.2f%s Used: %.2f%s (%.2f%%) Free: %.2f%s (%.2f%%)",
|
||||
$diskId, $diskSizeValue, $diskSizeUnit, $diskUsedValue, $diskUsedUnit, $percentUsed, $diskFreeValue, $diskFreeUnit, $percentFree));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'disk_'.$diskId,
|
||||
unit => 'B',
|
||||
value => $diskUsed,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $diskSize, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $diskSize, cast_int => 1),
|
||||
min => 0,
|
||||
max => $diskSize);
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All disks are ok.');
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Physical disks.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -1,167 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
"sensor:s" => { name => 'sensor' },
|
||||
"regexp" => { name => 'regexp' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
} else {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "shownodeenv",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my $total_components = 0;
|
||||
my $nodeID = 0;
|
||||
my @temperatures = split(/\n/,$stdout);
|
||||
foreach my $temperature (@temperatures) {
|
||||
if ($temperature =~ /^Node\s(\d+)$/) {
|
||||
$nodeID = $1;
|
||||
}
|
||||
if ($temperature =~ /^(.+)\s(\d+)\sC\s+(\d+)\sC\s+(\d+)/) {
|
||||
my $measurement = $1;
|
||||
my $readTemp = $2;
|
||||
my $loTemp = $3;
|
||||
my $hiTemp= $4;
|
||||
$measurement =~ s/^\s+//;
|
||||
$measurement =~ s/\s+$//;
|
||||
$total_components++;
|
||||
|
||||
next if (defined($self->{option_results}->{sensor}) && defined($self->{option_results}->{regexp}) && ($measurement !~ /$self->{option_results}->{sensor}/i));
|
||||
next if (defined($self->{option_results}->{sensor}) && !defined($self->{option_results}->{regexp}) && ($measurement != $self->{option_results}->{sensor}));
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Temperature '%s' on node '%d' is '%dC' [Max temperature: '%dC'] [Min temperature: '%dC'", $measurement, $nodeID, $readTemp, $hiTemp, $loTemp));
|
||||
if (($readTemp > $hiTemp) || ($readTemp < $loTemp)){
|
||||
$self->{output}->output_add(severity => 'critical',
|
||||
short_msg => sprintf("Temperature '%s' on node '%d' is '%dC' [Max temperature: '%dC'] [Min temperature: '%dC'", $measurement, $nodeID, $readTemp, $hiTemp, $loTemp));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => $measurement.'_temperature',
|
||||
unit => 'C',
|
||||
value => $readTemp);
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %d temperatures are ok.", $total_components));
|
||||
|
||||
if (defined($self->{option_results}->{no_component}) && $total_components == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_components},
|
||||
short_msg => 'No components are checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check temperature.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::volume;
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"filter-type:s" => { name => 'filter_type' },
|
||||
"volume:s" => { name => 'volume' },
|
||||
"name" => { name => 'name' },
|
||||
"regexp" => { name => 'regexp' },
|
||||
});
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
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) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "showvv -showcols Id,Name,VSize_MB,Snp_Rsvd_MB,Snp_Used_MB,Adm_Rsvd_MB,Adm_Used_MB,Usr_Rsvd_MB,Usr_Used_MB",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my $total_volumes = 0;
|
||||
my @volumes = split("\n",$stdout);
|
||||
foreach my $volume (@volumes) {
|
||||
if ($volume =~ /(\d+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) {
|
||||
$total_volumes++;
|
||||
my $volumeId = $1;
|
||||
my $volumeName = $2;
|
||||
my $volumeSize = $3 * 1024 * 1024;
|
||||
my $volumeSnpSize = $4 * 1024 * 1024;
|
||||
my $volumeSnpUsed = $5 * 1024 * 1024;
|
||||
my $volumeAdmSize = $6 * 1024 * 1024;
|
||||
my $volumeAdmUsed = $7 * 1024 * 1024;
|
||||
my $volumeUsrSize = $8 * 1024 * 1024;
|
||||
my $volumeUsrUsed = $9 * 1024 * 1024;
|
||||
my $volumeUsed = $volumeSnpUsed + $volumeAdmUsed + $volumeUsrUsed;
|
||||
my $volumeFree = $volumeSize - $volumeUsed;
|
||||
my $percentUsed = ($volumeUsed / $volumeSize) * 100;
|
||||
my $percentFree = 100 - $percentUsed;
|
||||
|
||||
my $string_to_compare = $volumeId;
|
||||
if (defined($self->{option_results}->{name})) {
|
||||
$string_to_compare = $volumeName;
|
||||
}
|
||||
|
||||
next if (defined($self->{option_results}->{volume}) && defined($self->{option_results}->{regexp}) && ($string_to_compare !~ /$self->{option_results}->{volume}/i));
|
||||
next if (defined($self->{option_results}->{volume}) && !defined($self->{option_results}->{regexp}) && ($string_to_compare ne $self->{option_results}->{volume}));
|
||||
|
||||
my ($volumeSizeValue, $volumeSizeUnit) = $self->{perfdata}->change_bytes(value => $volumeSize);
|
||||
my ($volumeUsedValue, $volumeUsedUnit) = $self->{perfdata}->change_bytes(value => $volumeUsed);
|
||||
my ($volumeFreeValue, $volumeFreeUnit) = $self->{perfdata}->change_bytes(value => $volumeFree);
|
||||
my ($volumeSnpSizeValue, $volumeSnpSizeUnit) = $self->{perfdata}->change_bytes(value => $volumeSnpSize);
|
||||
my ($volumeSnpUsedValue, $volumeSnpUsedUnit) = $self->{perfdata}->change_bytes(value => $volumeSnpUsed);
|
||||
my ($volumeAdmSizeValue, $volumeAdmSizeUnit) = $self->{perfdata}->change_bytes(value => $volumeAdmSize);
|
||||
my ($volumeAdmUsedValue, $volumeAdmUsedUnit) = $self->{perfdata}->change_bytes(value => $volumeAdmUsed);
|
||||
my ($volumeUsrSizeValue, $volumeUsrSizeUnit) = $self->{perfdata}->change_bytes(value => $volumeUsrSize);
|
||||
my ($volumeUsrUsedValue, $volumeUsrUsedUnit) = $self->{perfdata}->change_bytes(value => $volumeUsrUsed);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Volume %d '%s' Total: %.2f%s Used: %.2f%s (%.2f%%) Free: %.2f%s (%.2f%%) Usr: %.2f%s Adm: %.2f%s Snp: %.2f%s",
|
||||
$volumeId, $volumeName, $volumeSizeValue, $volumeSizeUnit,
|
||||
$volumeUsedValue, $volumeUsedUnit, $percentUsed,
|
||||
$volumeFreeValue, $volumeFreeUnit, $percentFree,
|
||||
$volumeUsrUsedValue, $volumeUsrUsedUnit,
|
||||
$volumeAdmUsedValue, $volumeAdmUsedUnit,
|
||||
$volumeSnpUsedValue, $volumeSnpUsedUnit,));
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $percentUsed, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Volume %d '%s' Total: %.2f%s Used: %.2f%s (%.2f%%) Free: %.2f%s (%.2f%%) Usr: %.2f%s Adm: %.2f%s Snp: %.2f%s",
|
||||
$volumeId, $volumeName, $volumeSizeValue, $volumeSizeUnit,
|
||||
$volumeUsedValue, $volumeUsedUnit, $percentUsed,
|
||||
$volumeFreeValue, $volumeFreeUnit, $percentFree,
|
||||
$volumeUsrUsedValue, $volumeUsrUsedUnit,
|
||||
$volumeAdmUsedValue, $volumeAdmUsedUnit,
|
||||
$volumeSnpUsedValue, $volumeSnpUsedUnit,));
|
||||
}
|
||||
$self->{output}->perfdata_add(label => 'volume_'.$volumeName,
|
||||
unit => 'B',
|
||||
value => $volumeUsed,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $volumeSize, cast_int => 1),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $volumeSize, cast_int => 1),
|
||||
min => 0,
|
||||
max => $volumeSize);
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All volumes are ok.');
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Physical disks.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-component>
|
||||
|
||||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::mode::wsapi;
|
||||
|
||||
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 =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"ssh-option:s@" => { name => 'ssh_option' },
|
||||
"ssh-path:s" => { name => 'ssh_path' },
|
||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
||||
"no-wsapi:s" => { name => 'no_wsapi' },
|
||||
});
|
||||
$self->{no_wsapi} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{hostname})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a hostname.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{no_wsapi})) {
|
||||
if ($self->{option_results}->{no_wsapi} ne '') {
|
||||
$self->{no_wsapi} = $self->{option_results}->{no_wsapi};
|
||||
} else {
|
||||
$self->{no_wsapi} = 'critical';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => "showwsapi",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
|
||||
my @results = split("\n",$stdout);
|
||||
my $total_wsapi = 0;
|
||||
foreach my $result (@results) {
|
||||
if ($result =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+\S+/) {
|
||||
$total_wsapi++;
|
||||
my $serviceStatus = $1;
|
||||
my $serviceState = $2;
|
||||
my $httpState = $3;
|
||||
my $httpPort = $4;
|
||||
my $httpsState = $5;
|
||||
my $httpsPort = $6;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("WSAPI service is '%s' and '%s' [HTTP on port %d is %s] [HTTPS on port %d is %s]",
|
||||
$serviceStatus, $serviceState, $httpPort, $httpState, $httpsPort ,$httpsState));
|
||||
if ((lc($serviceStatus) ne 'enabled') || (lc($serviceState) ne 'active')){
|
||||
$self->{output}->output_add(severity => 'critical',
|
||||
short_msg => sprintf("WSAPI service is '%s' and '%s' [HTTP on port %d is %s] [HTTPS on port %d is %s]",
|
||||
$serviceStatus, $serviceState, $httpPort, $httpState, $httpsPort ,$httpsState));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'WSAPI service is ok.');
|
||||
|
||||
if (defined($self->{option_results}->{no_wsapi}) && $total_wsapi == 0) {
|
||||
$self->{output}->output_add(severity => $self->{no_wsapi},
|
||||
short_msg => 'No WSAPI service is checked.');
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check WSAPI service status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use sudo.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 30).
|
||||
|
||||
=item B<--no-wsapi>
|
||||
|
||||
Return an error if no WSAPI are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,173 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::custom::custom;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
bless $self, $class;
|
||||
|
||||
if (!defined($options{output})) {
|
||||
print "Class Custom: Need to specify 'output' argument.\n";
|
||||
exit 3;
|
||||
}
|
||||
if (!defined($options{options})) {
|
||||
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (!defined($options{noptions})) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'ssh-option:s@' => { name => 'ssh_option' },
|
||||
'ssh-path:s' => { name => 'ssh_path' },
|
||||
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||
'timeout:s' => { name => 'timeout', default => 45 },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'SSH OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{mode} = $options{mode};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (keys %{$options{default}}) {
|
||||
if ($_ eq $self->{mode}) {
|
||||
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
|
||||
foreach my $opt (keys %{$options{default}->{$_}[$i]}) {
|
||||
if (!defined($self->{option_results}->{$opt}[$i])) {
|
||||
$self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{remote} = 1;
|
||||
if (defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '') {
|
||||
$self->{option_results}->{remote} = undef;
|
||||
} elsif (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to set hostname option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
##############
|
||||
# Specific methods
|
||||
##############
|
||||
sub execute_command {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{ssh_commands} = '';
|
||||
my $append = '';
|
||||
foreach (@{$options{commands}}) {
|
||||
$self->{ssh_commands} .= $append . " $_";
|
||||
$append = ';';
|
||||
}
|
||||
|
||||
return centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
command => defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : $self->{ssh_commands} . "; exit\n",
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '' ? $self->{option_results}->{command_options} : undef
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ssh
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my ssh
|
||||
|
||||
=head1 SSH OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=item B<--ssh-path>
|
||||
|
||||
Specify ssh command path (default: none)
|
||||
|
||||
=item B<--ssh-command>
|
||||
|
||||
Specify ssh command (default: 'ssh'). Useful to use 'plink'.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 45).
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information. Used it you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path.
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options.
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,83 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::components::battery;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
# Node PS Bat Assem_Serial -State- ChrgLvl(%) -ExpDate- Expired Testing
|
||||
# 0,1 0 0 6CQUBA1HN5065R OK 100 n/a No No
|
||||
# 0,1 1 0 6CQUBA1HN5063G OK 100 n/a No No
|
||||
# 2,3 0 0 6CQUBA1HN484RB OK 100 n/a No No
|
||||
# 2,3 1 0 6CQUBA1HN484R9 OK 100 n/a No No
|
||||
push @{$self->{commands}}, 'echo "===showbattery===', 'showbattery';
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking batteries");
|
||||
$self->{components}->{battery} = { name => 'batteries', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'battery'));
|
||||
|
||||
return if ($self->{results} !~ /===showbattery===.*?\n(.*?)(===|\Z)/msi);
|
||||
my @results = split /\n/, $1;
|
||||
|
||||
foreach (@results) {
|
||||
next if (!/^\s*\S+\s+(\d+)\s+(\d+)\s+\S+\s+(\S+)\s+(\d+)/);
|
||||
my ($psu_id, $battery_id, $battery_state, $battery_chrg_lvl) = ($1, $2, $3, $4);
|
||||
my $instance = $psu_id . '.' . $battery_id;
|
||||
|
||||
next if ($self->check_filter(section => 'battery', instance => $instance));
|
||||
$self->{components}->{battery}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("battery '%s' on power supply '%s' status is '%s' [instance: %s, charge level: %d%%]",
|
||||
$psu_id, $battery_id, $battery_state, $instance, $battery_chrg_lvl)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'battery', value => $battery_state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Battery '%s' on power supply '%s' status is '%s'",
|
||||
$psu_id, $battery_id, $battery_state, $instance));
|
||||
}
|
||||
|
||||
my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'battery.charge', instance => $instance, value => $battery_chrg_lvl);
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit2,
|
||||
short_msg => sprintf("Battery '%s' on power supply '%s' charge level is %s %%", $psu_id, $battery_id, $battery_chrg_lvl));
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'battery_charge', unit => '%',
|
||||
nlabel => 'hardware.battery.charge.percentage',
|
||||
instances => ['psu' . $psu_id, 'battery' . $battery_id],
|
||||
value => $battery_chrg_lvl,
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
min => 0, max => 100,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,73 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::components::cim;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
#-Service- -State- --SLP-- SLPPort -HTTP-- HTTPPort -HTTPS- HTTPSPort PGVer CIMVer
|
||||
#Enabled Active Enabled 427 Enabled 5988 Enabled 5989 2.9.1 3.2.2
|
||||
push @{$self->{commands}}, 'echo "===showcim===', 'showcim';
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking cim");
|
||||
$self->{components}->{cim} = { name => 'cim', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'cim'));
|
||||
|
||||
return if ($self->{results} !~ /===showcim===.*?\n(.*?)(===|\Z)/msi);
|
||||
my @results = split /\n/, $1;
|
||||
|
||||
my $instance = 0;
|
||||
foreach (@results) {
|
||||
next if (!/^(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+\S+/);
|
||||
$instance++;
|
||||
my ($service_status, $service_state, $slp_state, $slp_port, $http_state,
|
||||
$http_port, $https_state, $https_port) = ($1, $2, $3, $4, $5, $6, $7, $8);
|
||||
|
||||
next if ($self->check_filter(section => 'cim', instance => $instance));
|
||||
$self->{components}->{cim}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("cim service state is '%s' [status: '%s'] [SLP on port %d is %s] [HTTP on port %d is %s] [HTTPS on port %d is %s] [instance: %s]",
|
||||
$service_state, $service_status, $slp_port, $slp_state, $http_port, $http_state, $https_port ,$https_state, $instance)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default.state', section => 'cim.state', value => $service_state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("cim service state is '%s' [instance: %s]",
|
||||
$service_state, $instance));
|
||||
}
|
||||
|
||||
$exit = $self->get_severity(label => 'default.status', section => 'cim.status', value => $service_status);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("cim service status is '%s' [instance: %s]",
|
||||
$service_status, $instance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,68 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::components::disk;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
# Id State
|
||||
# 0 normal
|
||||
# 1 normal
|
||||
# 2 normal
|
||||
#...
|
||||
# 10 normal
|
||||
# 11 normal
|
||||
push @{$self->{commands}}, 'echo "===showdisk===', 'showpd -showcols Id,State';
|
||||
}
|
||||
|
||||
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_filter(section => 'disk'));
|
||||
|
||||
return if ($self->{results} !~ /===showdisk===.*?\n(.*?)(===|\Z)/msi);
|
||||
my @results = split /\n/, $1;
|
||||
|
||||
foreach (@results) {
|
||||
next if (!/^\s*(\d+)\s+(\S+)/);
|
||||
my ($instance, $state) = ($1, $2);
|
||||
|
||||
next if ($self->check_filter(section => 'disk', instance => $instance));
|
||||
$self->{components}->{disk}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("disk '%s' state is '%s' [instance: '%s']",
|
||||
$instance, $state, $instance)
|
||||
);
|
||||
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' state is '%s'",
|
||||
$instance, $state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,66 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::components::node;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
#Node -State- -Detailed_State-
|
||||
#0 OK OK
|
||||
#1 OK OK
|
||||
#2 OK OK
|
||||
#3 OK OK
|
||||
push @{$self->{commands}}, 'echo "===shownode===', 'shownode -state';
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking nodes");
|
||||
$self->{components}->{node} = { name => 'nodes', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'node'));
|
||||
|
||||
return if ($self->{results} !~ /===shownode===.*?\n(.*?)(===|\Z)/msi);
|
||||
my @results = split /\n/, $1;
|
||||
|
||||
foreach (@results) {
|
||||
next if (!/^\s*(\d+)\s+(\S+)\s+(\S+)/);
|
||||
my ($instance, $state, $detail_state) = ($1, $2, $3);
|
||||
|
||||
next if ($self->check_filter(section => 'node', instance => $instance));
|
||||
$self->{components}->{node}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("node '%s' state is '%s' [instance: '%s'] [detailed state: %s]",
|
||||
$instance, $state, $instance, $detail_state)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'node', value => $state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Node '%s' state is '%s'",
|
||||
$instance, $state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,74 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::components::port;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
#N:S:P Mode State ----Node_WWN---- -Port_WWN/HW_Addr- Type Protocol Label Partner FailoverState
|
||||
#0:0:1 initiator ready 50002ACFF70047C0 50002AC0010047C0 disk SAS DP-1 - -
|
||||
#0:0:2 initiator ready 50002ACFF70047C0 50002AC0020047C0 disk SAS DP-2 - -
|
||||
#0:1:1 target ready 2FF70002AC0047C0 20110002AC0047C0 host FC - 1:1:1 none
|
||||
#0:1:2 target ready 2FF70002AC0047C0 20120002AC0047C0 host FC - 1:1:2 none
|
||||
#0:2:1 initiator ready 2FF70002AC0047C0 20210002AC0047C0 rcfc FC - - -
|
||||
#0:2:2 target ready 2FF70002AC0047C0 20220002AC0047C0 host FC - - -
|
||||
#0:2:3 target ready 2FF70002AC0047C0 20230002AC0047C0 host FC - 1:2:3 none
|
||||
#0:2:4 target ready 2FF70002AC0047C0 20240002AC0047C0 host FC - 1:2:4 none
|
||||
#0:3:1 peer offline - B4B52FA71D43 free IP IP0 - -
|
||||
#1:0:1 initiator ready 50002ACFF70047C0 50002AC1010047C0 disk SAS DP-1 - -
|
||||
#1:0:2 initiator ready 50002ACFF70047C0 50002AC1020047C0 disk SAS DP-2 - -
|
||||
push @{$self->{commands}}, 'echo "===showport===', 'showport';
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking ports");
|
||||
$self->{components}->{port} = { name => 'ports', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'port'));
|
||||
|
||||
return if ($self->{results} !~ /===showport===.*?\n(.*?)(===|\Z)/msi);
|
||||
my @results = split /\n/, $1;
|
||||
|
||||
foreach (@results) {
|
||||
next if (!/^(\d+:\d+:\d+)\s+\S+\s+(\S+)\s+\S+\s+\S+\s+(\S+)/);
|
||||
my ($nsp, $state, $type) = ($1, $2, $3);
|
||||
my $instance = $type . '.' . $nsp;
|
||||
|
||||
next if ($self->check_filter(section => 'port', instance => $instance));
|
||||
$self->{components}->{port}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("port '%s' state is '%s' [instance: '%s']",
|
||||
$nsp, $state, $instance)
|
||||
);
|
||||
my $exit = $self->get_severity(section => 'port', value => $state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("port '%s' state is '%s'",
|
||||
$nsp, $state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,66 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
#Node PS -Assem_Part- -Assem_Serial- ACState DCState PSState
|
||||
# 0,1 0 682372-001 5CQLQA1433H0B8 OK OK OK
|
||||
# 0,1 1 682372-001 5CQLQA1434W2ED OK OK OK
|
||||
# 2,3 0 682372-001 5CQLQA1433Y0KS OK OK OK
|
||||
# 2,3 1 682372-001 5CQLQX1XX3E056 OK OK OK
|
||||
push @{$self->{commands}}, 'echo "===showpsu===', 'shownode -ps';
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
||||
$self->{components}->{psu} = { name => 'psus', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'psu'));
|
||||
|
||||
return if ($self->{results} !~ /===showpsu===.*?\n(.*?)(===|\Z)/msi);
|
||||
my @results = split /\n/, $1;
|
||||
|
||||
foreach (@results) {
|
||||
next if (!/^\s*(\S+)\s+(\d+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)/);
|
||||
my ($instance, $ac_state, $dc_state, $psu_state) = ('node' . $1 . '.psu' . $2, $3, $4, $5);
|
||||
|
||||
next if ($self->check_filter(section => 'psu', instance => $instance));
|
||||
$self->{components}->{psu}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("power supply '%s' state is '%s' [instance: '%s'] [ac state: %s] [dc state: %s]",
|
||||
$instance, $psu_state, $instance, $ac_state, $dc_state)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default', section => 'psu', value => $psu_state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Power supply '%s' state is '%s'",
|
||||
$instance, $psu_state));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,113 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::components::sensor;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
#Node 0
|
||||
#---------
|
||||
#
|
||||
#------Measurement------ -Reading- -Lo_Limit- -Hi_Limit- -----Status-----
|
||||
# Ambient 21 C 5 C 40 C Within Tolerance
|
||||
# Midplane 23 C 10 C 50 C Within Tolerance
|
||||
# PCM 0 inlet 27 C 10 C 50 C Within Tolerance
|
||||
# SBB Canister 1 memory 42 C 5 C 82 C Within Tolerance
|
||||
# PCM 0 (5V) 5.19 V --- --- Within Tolerance
|
||||
# PCM 0 (40A Max) 2.77 A --- --- Within Tolerance
|
||||
#
|
||||
#Node 1
|
||||
#---------
|
||||
#
|
||||
#------Measurement------ -Reading- -Lo_Limit- -Hi_Limit- -----Status-----
|
||||
# Ambient 21 C 5 C 40 C Within Tolerance
|
||||
# Midplane 23 C 10 C 50 C Within Tolerance
|
||||
# PCM 0 inlet 27 C 10 C 50 C Within Tolerance
|
||||
# PCM 0 hotspot 21 C 10 C 65 C Within Tolerance
|
||||
# Node Input PWR 87.6 W 0.0 W 264.0 W Within Tolerance
|
||||
push @{$self->{commands}}, 'echo "===shownodeenv===', 'shownodeenv';
|
||||
}
|
||||
|
||||
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_filter(section => 'sensor'));
|
||||
|
||||
return if ($self->{results} !~ /===shownodeenv===.*?\n(.*?)(===|\Z)/msi);
|
||||
my $content = $1;
|
||||
my $unit_new_perf = { A => 'current.ampere', V => 'voltage.volt', W => 'power.watt', C => 'temperature.celsius' };
|
||||
|
||||
while ($content =~ /^Node\s+(\d+)(.*?)(?=\nNode|\Z$)/msg) {
|
||||
my ($node_id, $measures) = ($1, $2);
|
||||
|
||||
my @lines = split /\n/, $measures;
|
||||
foreach (@lines) {
|
||||
next if (!/^(.*?)\s+(\S+)\s+([CWAV])\s+(\S+\s+[CWAV]|---)\s+(\S+\s+[CWAV]|---)\s+/);
|
||||
my ($name, $reading, $unit, $lo_limit, $hi_limit) = (centreon::plugins::misc::trim($1), $2, $3, $4, $5);
|
||||
my $instance = 'node' . $node_id . '.' . $name;
|
||||
|
||||
next if ($self->check_filter(section => 'sensor', instance => $instance));
|
||||
$self->{components}->{sensor}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("sensor '%s' on node '%s' is %s %s [instance: %s]",
|
||||
$name, $node_id, $reading, $unit, $instance)
|
||||
);
|
||||
|
||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'sensor', instance => $instance, value => $reading);
|
||||
$lo_limit = ($lo_limit =~ s/.*?(\d+(\.\d+)?).*/$1/) ? $lo_limit : undef;
|
||||
$hi_limit = ($hi_limit =~ s/.*?(\d+(\.\d+)?).*/$1/) ? $hi_limit : undef;
|
||||
if ($checked == 0 && (defined($lo_limit) || defined($hi_limit))) {
|
||||
my $warn_th = '';
|
||||
my $crit_th = (defined($lo_limit) ? $lo_limit : '~') . ':' . (defined($hi_limit) ? $hi_limit : '~');
|
||||
$self->{perfdata}->threshold_validate(label => 'warning-sensor-instance-' . $instance, value => $warn_th);
|
||||
$self->{perfdata}->threshold_validate(label => 'critical-sensor-instance-' . $instance, value => $crit_th);
|
||||
|
||||
$exit = $self->{perfdata}->threshold_check(
|
||||
value => $reading,
|
||||
threshold => [ { label => 'critical-sensor-instance-' . $instance, exit_litteral => 'critical' },
|
||||
{ label => 'warning-sensor-instance-' . $instance, exit_litteral => 'warning' } ]);
|
||||
$warn = $self->{perfdata}->get_perfdata_for_output(label => 'warning-sensor-instance-' . $instance);
|
||||
$crit = $self->{perfdata}->get_perfdata_for_output(label => 'critical-sensor-instance-' . $instance)
|
||||
}
|
||||
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Sensor '%s' on node '%s' is %s %s ", $name, $node_id, $reading, $unit));
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'sensor', unit => $unit,
|
||||
nlabel => 'hardware.sensor.' . $unit_new_perf->{$unit},
|
||||
instances => ['node' . $node_id, $name],
|
||||
value => $reading,
|
||||
warning => $warn,
|
||||
critical => $crit,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,73 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::components::wsapi;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
#-Service- -State- -HTTP_State- HTTP_Port -HTTPS_State- HTTPS_Port -Version- -----------------API_URL------------------
|
||||
#Enabled Active Disabled 8008 Enabled 8080 1.5.3 https://xxxx:8080/api/v1
|
||||
push @{$self->{commands}}, 'echo "===showwsapi===', 'showwsapi';
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking wsapi");
|
||||
$self->{components}->{wsapi} = { name => 'wsapi', total => 0, skip => 0 };
|
||||
return if ($self->check_filter(section => 'wsapi'));
|
||||
|
||||
return if ($self->{results} !~ /===showwsapi===.*?\n(.*?)(===|\Z)/msi);
|
||||
my @results = split /\n/, $1;
|
||||
|
||||
my $instance = 0;
|
||||
foreach (@results) {
|
||||
next if (!/^(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\S+)\s+(\d+)\s+\S+/);
|
||||
$instance++;
|
||||
my ($service_status, $service_state, $http_state,
|
||||
$http_port, $https_state, $https_port) = ($1, $2, $3, $4, $5, $6);
|
||||
|
||||
next if ($self->check_filter(section => 'wsapi', instance => $instance));
|
||||
$self->{components}->{wsapi}->{total}++;
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("wsapi service state is '%s' [status: '%s'] [HTTP on port %d is %s] [HTTPS on port %d is %s] [instance: %s]",
|
||||
$service_state, $service_status, $http_port, $http_state, $https_port ,$https_state, $instance)
|
||||
);
|
||||
my $exit = $self->get_severity(label => 'default.state', section => 'wsapi.state', value => $service_state);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("wsapi service state is '%s' [instance: %s]",
|
||||
$service_state, $instance));
|
||||
}
|
||||
|
||||
$exit = $self->get_severity(label => 'default.status', section => 'wsapi.status', value => $service_status);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("wsapi service status is '%s' [instance: %s]",
|
||||
$service_status, $instance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,198 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::diskusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = 'status : ' . $self->{result_values}->{status};
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute});
|
||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute});
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute});
|
||||
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute},
|
||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute});
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'disk', type => 1, cb_prefix_output => 'prefix_disk_output', message_multiple => 'All disks are ok', sort_method => 'num' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{disk} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'status' }, { name => 'display' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_status_output'),
|
||||
closure_custom_perfdata => sub { return 0; },
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
}
|
||||
},
|
||||
{ label => 'usage', nlabel => 'disk.space.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' }, ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute',
|
||||
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'usage-free', display_ok => 0, nlabel => 'disk.space.free.bytes', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' }, ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute',
|
||||
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'usage-prct', display_ok => 0, nlabel => 'disk.space.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'display' } ],
|
||||
output_template => 'Used : %.2f %%',
|
||||
perfdatas => [
|
||||
{ label => 'used_prct', value => 'prct_used_absolute', template => '%d', min => 0, max => 0,
|
||||
unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /normal/i' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub prefix_disk_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Disk '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($result, $exit) = $options{custom}->execute_command(commands => ['showpd -showcols Id,State,Type,Size_MB,Free_MB']);
|
||||
|
||||
#Id State Type Size_MB Free_MB
|
||||
# 0 normal FC 838656 133120
|
||||
# 1 normal FC 838656 101376
|
||||
# 2 normal FC 838656 133120
|
||||
|
||||
$self->{disk} = {};
|
||||
my @lines = split /\n/, $result;
|
||||
foreach (@lines) {
|
||||
next if (!/^\s*(\d+)\s+(\S+)\s+\S+\s+(\d+)\s+(\d+)/);
|
||||
my ($disk_id, $status, $total, $free) = ($1, $2, $3 * 1024 * 1024, $4 * 1024 * 1024);
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$disk_id !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping disk '" . $disk_id . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
$self->{disk}->{$disk_id} = {
|
||||
display => $disk_id,
|
||||
status => $status,
|
||||
total => $total,
|
||||
used => $total - $free,
|
||||
free => $free,
|
||||
prct_used => ($total - $free) * 100 / $total,
|
||||
prct_free => 100 - (($total - $free) * 100 / $total),
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{disk}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No disk found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check disk usages.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='^status$'
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter disk name (can be a regexp).
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status (Default: '').
|
||||
Can used special variables like: %{status}, %{display}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{status} !~ /normal/i').
|
||||
Can used special variables like: %{status}, %{display}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,126 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::hardware;
|
||||
|
||||
use base qw(centreon::plugins::templates::hardware);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_overload_check_section_option} =
|
||||
'^(battery|cim|port|node|disk|psu|sensor)$';
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(battery\.charge|sensor)$';
|
||||
|
||||
$self->{cb_hook2} = 'ssh_execute';
|
||||
|
||||
$self->{thresholds} = {
|
||||
default => [
|
||||
['normal', 'OK'], # disk only
|
||||
['ok', 'OK'],
|
||||
['new', 'OK'],
|
||||
['degraded', 'WARNING'],
|
||||
['failed', 'CRITICAL'],
|
||||
],
|
||||
'default.status' => [
|
||||
['enabled', 'OK'],
|
||||
['.*', 'CRITICAL'],
|
||||
],
|
||||
'default.state' => [
|
||||
['active', 'OK'],
|
||||
['.*', 'CRITICAL'],
|
||||
],
|
||||
port => [
|
||||
['ready', 'OK'],
|
||||
['loss_sync', 'WARNING'],
|
||||
['offline', 'CRITICAL'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'storage::hp::3par::ssh::mode::components';
|
||||
$self->{components_module} = ['battery', 'cim', 'port', 'node', 'disk', 'psu', 'sensor', 'wsapi'];
|
||||
}
|
||||
|
||||
sub ssh_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
($self->{results}, $self->{exit_code}) = $options{custom}->execute_command(commands => $self->{commands});
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
$self->{commands} = [];
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check components.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--component>
|
||||
|
||||
Which component to check (Default: '.*').
|
||||
Can be: 'battery'.
|
||||
|
||||
=item B<--filter>
|
||||
|
||||
Exclude some parts (comma seperated list) (Example: --filter=battery --filter=cim)
|
||||
Can also exclude specific instance: --filter=port,free
|
||||
|
||||
=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='battery,OK,degraded'
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for 'battery.charge' (syntax: type,regexp,threshold)
|
||||
Example: --warning='battery.charge,.*,30'
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold for 'battery.charge' (syntax: type,regexp,threshold)
|
||||
Example: --critical='battery.charge,.*,50'
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,165 @@
|
|||
#
|
||||
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::ssh::mode::volumeusage;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub custom_usage_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute});
|
||||
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute});
|
||||
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute});
|
||||
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||
$total_size_value . " " . $total_size_unit,
|
||||
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_absolute},
|
||||
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_absolute});
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'volume', type => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'All volumes are ok' },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{volume} = [
|
||||
{ label => 'usage', nlabel => 'volume.space.usage.bytes', set => {
|
||||
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' }, ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ label => 'used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute',
|
||||
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'usage-free', display_ok => 0, nlabel => 'volume.space.free.bytes', set => {
|
||||
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' }, { name => 'display' }, ],
|
||||
closure_custom_output => $self->can('custom_usage_output'),
|
||||
perfdatas => [
|
||||
{ label => 'free', value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute',
|
||||
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'usage-prct', display_ok => 0, nlabel => 'volume.space.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' }, { name => 'display' } ],
|
||||
output_template => 'Used : %.2f %%',
|
||||
perfdatas => [
|
||||
{ label => 'used_prct', value => 'prct_used_absolute', template => '%d', min => 0, max => 0,
|
||||
unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub prefix_volume_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Volume '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($result, $exit) = $options{custom}->execute_command(commands => ['showvv -showcols Id,Name,VSize_MB,Snp_Rsvd_MB,Snp_Used_MB,Adm_Rsvd_MB,Adm_Used_MB,Usr_Rsvd_MB,Usr_Used_MB']);
|
||||
|
||||
# Id Name VSize_MB Snp_Rsvd_MB Snp_Used_MB Adm_Rsvd_MB Adm_Used_MB Usr_Rsvd_MB Usr_Used_MB
|
||||
#2056 .srdata 81920 0 0 0 0 81920 81920
|
||||
# 0 admin 10240 0 0 0 0 10240 10240
|
||||
# 494 DFS_DATA01 4608000 0 0 2560 2032 3156864 3147727
|
||||
# 495 DFS_DATA02 1126400 0 0 1024 612 979072 966739
|
||||
# 496 DFS_DATA03 16777216 0 0 10240 9576 15281920 15281185
|
||||
|
||||
$self->{volume} = {};
|
||||
my @lines = split /\n/, $result;
|
||||
foreach (@lines) {
|
||||
next if (!/^\s*\d+\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/);
|
||||
my ($name, $total, $snap_used, $adm_used, $usr_used) = ($1, $2 * 1024 * 1024, $4 * 1024 * 1024, $6 * 1024 * 1024, $8 * 1024 * 1024);
|
||||
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
$name !~ /$self->{option_results}->{filter_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping volume '" . $name . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
my $used = $snap_used + $adm_used + $usr_used;
|
||||
$self->{volume}->{$name} = {
|
||||
display => $name,
|
||||
total => $total,
|
||||
used => $used,
|
||||
free => ($total - $used) >= 0 ? ($total - $used) : 0,
|
||||
prct_used => $used * 100 / $total,
|
||||
prct_free => (100 - ($used * 100 / $total) >= 0) ? (100 - ($used * 100 / $total)) : 0,
|
||||
};
|
||||
}
|
||||
|
||||
if (scalar(keys %{$self->{volume}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No volume found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check volume usages.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-counters>
|
||||
|
||||
Only display some counters (regexp can be used).
|
||||
Example: --filter-counters='^usage$'
|
||||
|
||||
=item B<--filter-name>
|
||||
|
||||
Filter volume name (can be a regexp).
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -18,11 +18,11 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package storage::hp::3par::7000::plugin;
|
||||
package storage::hp::3par::ssh::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_simple);
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
|
@ -31,18 +31,12 @@ sub new {
|
|||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'physicaldisk' => 'storage::hp::3par::7000::mode::physicaldisk',
|
||||
'psu' => 'storage::hp::3par::7000::mode::psu',
|
||||
'node' => 'storage::hp::3par::7000::mode::node',
|
||||
'battery' => 'storage::hp::3par::7000::mode::battery',
|
||||
'wsapi' => 'storage::hp::3par::7000::mode::wsapi',
|
||||
'cim' => 'storage::hp::3par::7000::mode::cim',
|
||||
'temperature' => 'storage::hp::3par::7000::mode::temperature',
|
||||
'storage' => 'storage::hp::3par::7000::mode::storage',
|
||||
'iscsi' => 'storage::hp::3par::7000::mode::iscsi',
|
||||
'volume' => 'storage::hp::3par::7000::mode::volume',
|
||||
);
|
||||
'components' => 'storage::hp::3par::ssh::mode::hardware',
|
||||
'disk-usage' => 'storage::hp::3par::ssh::mode::diskusage',
|
||||
'volume-usage' => 'storage::hp::3par::ssh::mode::volumeusage',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{ssh} = 'storage::hp::3par::ssh::custom::custom';
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -52,6 +46,6 @@ __END__
|
|||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check HP 3par 7000 series in SSH.
|
||||
Check HP 3par in SSH.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue