mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-29 00:24:46 +02:00
security - add method to block command override batch 1 (#4046)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip
This commit is contained in:
parent
512962338c
commit
b5cfc3e9e4
@ -124,7 +124,14 @@ sub new {
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{clamav_command} = 'echo "==== CLAMD ===" ; clamd -V ; echo "==== DAILY ===="; sigtool --info ' . $self->{option_results}->{dailydb_file} . '; echo "==== MAIN ====" ; sigtool --info ' . $self->{option_results}->{maindb_file};
|
||||
}
|
||||
|
||||
|
100
centreon-plugins/apps/apcupsd/local/custom/cli.pm
Normal file
100
centreon-plugins/apps/apcupsd/local/custom/cli.pm
Normal file
@ -0,0 +1,100 @@
|
||||
#
|
||||
# Copyright 2022 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 apps::apcupsd::local::custom::cli;
|
||||
|
||||
use base qw(centreon::plugins::script_custom::cli);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub execute_command {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($stdout) = $self->SUPER::execute_command(%options);
|
||||
|
||||
my $searchpattern = $options{searchpattern};
|
||||
my ($valueok, $value) = (0);
|
||||
foreach (split(/\n/, $stdout)) {
|
||||
if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C Internal|F Internal|C|F)/i) {
|
||||
$valueok = 1;
|
||||
$value = $1;
|
||||
};
|
||||
};
|
||||
|
||||
if ($valueok != 1) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'CRITICAL',
|
||||
short_msg => 'NO DATA FOUND'
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ssh
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my ssh
|
||||
|
||||
=head1 CLI OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Timeout in seconds for the command (Default: 45). Default value can be override by the mode.
|
||||
|
||||
=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.
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
sudo command.
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
@ -24,72 +24,68 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'apcaccess' },
|
||||
"command-path:s" => { name => 'command_path', default => '/sbin/' },
|
||||
"command-options:s" => { name => 'command_options', default => ' status ' },
|
||||
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||
"apchost:s" => { name => 'apchost', default => 'localhost' },
|
||||
"apcport:s" => { name => 'apcport', default => '3551' },
|
||||
"searchpattern:s" => { name => 'searchpattern', default => 'BCHARGE' },
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'apchost:s' => { name => 'apchost', default => 'localhost' },
|
||||
'apcport:s' => { name => 'apcport', default => '3551' },
|
||||
'searchpattern:s' => { name => 'searchpattern', default => 'BCHARGE' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{apchost})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{apcport})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$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();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
|
||||
my $result = $options{custom}->execute_command(
|
||||
command_path => '/sbin',
|
||||
command => 'apcaccess',
|
||||
command_options => 'status ' . $self->{option_results}->{apchost} . ':' . $self->{option_results}->{apcport} . ' 2>&1',
|
||||
searchpattern => $self->{option_results}->{searchpattern}
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
@ -101,7 +97,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check apcupsd Status
|
||||
Check battery charge.
|
||||
|
||||
Command used: /sbin/apcaccess status %(apchost):%(apcport) 2>&1
|
||||
|
||||
=over 8
|
||||
|
||||
@ -121,18 +119,6 @@ Warning Threshold
|
||||
|
||||
Critical Threshold
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,75 +24,71 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'apcaccess' },
|
||||
"command-path:s" => { name => 'command_path', default => '/sbin/' },
|
||||
"command-options:s" => { name => 'command_options', default => ' status ' },
|
||||
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||
"apchost:s" => { name => 'apchost', default => 'localhost' },
|
||||
"apcport:s" => { name => 'apcport', default => '3551' },
|
||||
"searchpattern:s" => { name => 'searchpattern', default => 'BATTV' },
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'apchost:s' => { name => 'apchost', default => 'localhost' },
|
||||
'apcport:s' => { name => 'apcport', default => '3551' },
|
||||
'searchpattern:s' => { name => 'searchpattern', default => 'BATTV' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{apchost})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{apcport})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$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();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
|
||||
my $result = $options{custom}->execute_command(
|
||||
command_path => '/sbin',
|
||||
command => 'apcaccess',
|
||||
command_options => 'status ' . $self->{option_results}->{apchost} . ':' . $self->{option_results}->{apcport} . ' 2>&1',
|
||||
searchpattern => $self->{option_results}->{searchpattern}
|
||||
);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -101,7 +97,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check apcupsd Status
|
||||
Check battery voltage
|
||||
|
||||
Command used: /sbin/apcaccess status %(apchost):%(apcport) 2>&1
|
||||
|
||||
=over 8
|
||||
|
||||
@ -121,18 +119,6 @@ Warning Threshold
|
||||
|
||||
Critical Threshold
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
@ -1,63 +0,0 @@
|
||||
#
|
||||
# Copyright 2022 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 apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub getdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options} . $self->{option_results}->{apchost} . ":" . $self->{option_results}->{apcport} . $self->{option_results}->{command_options2});
|
||||
|
||||
my $searchpattern = $self->{option_results}->{searchpattern};
|
||||
my ($valueok);
|
||||
my ($value);
|
||||
#print $stdout;
|
||||
foreach (split(/\n/, $stdout)) {
|
||||
if (/^$searchpattern\s*:\s*(.*)\s(Percent Load Capacity|Percent|Minutes|Seconds|Volts|Hz|seconds|C Internal|F Internal|C|F)/i) {
|
||||
$valueok = "1";
|
||||
$value = $1;
|
||||
#print $value;
|
||||
#print "\n";
|
||||
};
|
||||
};
|
||||
|
||||
if ($valueok == "1") {
|
||||
#print $value;
|
||||
return $value;
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => 'NO DATA FOUND');
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
};
|
||||
};
|
||||
|
||||
1;
|
@ -24,75 +24,71 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'apcaccess' },
|
||||
"command-path:s" => { name => 'command_path', default => '/sbin/' },
|
||||
"command-options:s" => { name => 'command_options', default => ' status ' },
|
||||
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||
"apchost:s" => { name => 'apchost', default => 'localhost' },
|
||||
"apcport:s" => { name => 'apcport', default => '3551' },
|
||||
"searchpattern:s" => { name => 'searchpattern', default => 'LINEFREQ' },
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'apchost:s' => { name => 'apchost', default => 'localhost' },
|
||||
'apcport:s' => { name => 'apcport', default => '3551' },
|
||||
'searchpattern:s' => { name => 'searchpattern', default => 'LINEFREQ' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{apchost})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{apcport})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$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();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = $options{custom}->execute_command(
|
||||
command_path => '/sbin',
|
||||
command => 'apcaccess',
|
||||
command_options => 'status ' . $self->{option_results}->{apchost} . ':' . $self->{option_results}->{apcport} . ' 2>&1',
|
||||
searchpattern => $self->{option_results}->{searchpattern}
|
||||
);
|
||||
|
||||
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -101,7 +97,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check apcupsd Status
|
||||
Check line frequency
|
||||
|
||||
Command used: /sbin/apcaccess status %(apchost):%(apcport) 2>&1
|
||||
|
||||
=over 8
|
||||
|
||||
@ -121,18 +119,6 @@ Warning Threshold
|
||||
|
||||
Critical Threshold
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,75 +24,71 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'apcaccess' },
|
||||
"command-path:s" => { name => 'command_path', default => '/sbin/' },
|
||||
"command-options:s" => { name => 'command_options', default => ' status ' },
|
||||
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||
"apchost:s" => { name => 'apchost', default => 'localhost' },
|
||||
"apcport:s" => { name => 'apcport', default => '3551' },
|
||||
"searchpattern:s" => { name => 'searchpattern', default => 'LINEV' },
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'apchost:s' => { name => 'apchost', default => 'localhost' },
|
||||
'apcport:s' => { name => 'apcport', default => '3551' },
|
||||
'searchpattern:s' => { name => 'searchpattern', default => 'LINEV' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{apchost})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{apcport})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$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();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
|
||||
my $result = $options{custom}->execute_command(
|
||||
command_path => '/sbin',
|
||||
command => 'apcaccess',
|
||||
command_options => 'status ' . $self->{option_results}->{apchost} . ':' . $self->{option_results}->{apcport} . ' 2>&1',
|
||||
searchpattern => $self->{option_results}->{searchpattern}
|
||||
);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -101,7 +97,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check apcupsd Status
|
||||
Check line voltage
|
||||
|
||||
Command used: /sbin/apcaccess status %(apchost):%(apcport) 2>&1
|
||||
|
||||
=over 8
|
||||
|
||||
@ -121,18 +119,6 @@ Warning Threshold
|
||||
|
||||
Critical Threshold
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,75 +24,71 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'apcaccess' },
|
||||
"command-path:s" => { name => 'command_path', default => '/sbin/' },
|
||||
"command-options:s" => { name => 'command_options', default => ' status ' },
|
||||
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||
"apchost:s" => { name => 'apchost', default => 'localhost' },
|
||||
"apcport:s" => { name => 'apcport', default => '3551' },
|
||||
"searchpattern:s" => { name => 'searchpattern', default => 'LOADPCT' },
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'apchost:s' => { name => 'apchost', default => 'localhost' },
|
||||
'apcport:s' => { name => 'apcport', default => '3551' },
|
||||
'searchpattern:s' => { name => 'searchpattern', default => 'LOADPCT' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{apchost})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{apcport})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$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();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
|
||||
my $result = $options{custom}->execute_command(
|
||||
command_path => '/sbin',
|
||||
command => 'apcaccess',
|
||||
command_options => 'status ' . $self->{option_results}->{apchost} . ':' . $self->{option_results}->{apcport} . ' 2>&1',
|
||||
searchpattern => $self->{option_results}->{searchpattern}
|
||||
);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -101,7 +97,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check apcupsd Status
|
||||
Check load percentage
|
||||
|
||||
Command used: /sbin/apcaccess status %(apchost):%(apcport) 2>&1
|
||||
|
||||
=over 8
|
||||
|
||||
@ -121,18 +119,6 @@ Warning Threshold
|
||||
|
||||
Critical Threshold
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,75 +24,71 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'apcaccess' },
|
||||
"command-path:s" => { name => 'command_path', default => '/sbin/' },
|
||||
"command-options:s" => { name => 'command_options', default => ' status ' },
|
||||
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||
"apchost:s" => { name => 'apchost', default => 'localhost' },
|
||||
"apcport:s" => { name => 'apcport', default => '3551' },
|
||||
"searchpattern:s" => { name => 'searchpattern', default => 'OUTPUTV' },
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'apchost:s' => { name => 'apchost', default => 'localhost' },
|
||||
'apcport:s' => { name => 'apcport', default => '3551' },
|
||||
'searchpattern:s' => { name => 'searchpattern', default => 'OUTPUTV' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{apchost})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{apcport})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$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();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
|
||||
my $result = $options{custom}->execute_command(
|
||||
command_path => '/sbin',
|
||||
command => 'apcaccess',
|
||||
command_options => 'status ' . $self->{option_results}->{apchost} . ':' . $self->{option_results}->{apcport} . ' 2>&1',
|
||||
searchpattern => $self->{option_results}->{searchpattern}
|
||||
);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -101,7 +97,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check apcupsd Status
|
||||
Check output voltage
|
||||
|
||||
Command used: /sbin/apcaccess status %(apchost):%(apcport) 2>&1
|
||||
|
||||
=over 8
|
||||
|
||||
@ -121,18 +119,6 @@ Warning Threshold
|
||||
|
||||
Critical Threshold
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,75 +24,71 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'apcaccess' },
|
||||
"command-path:s" => { name => 'command_path', default => '/sbin/' },
|
||||
"command-options:s" => { name => 'command_options', default => ' status ' },
|
||||
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||
"apchost:s" => { name => 'apchost', default => 'localhost' },
|
||||
"apcport:s" => { name => 'apcport', default => '3551' },
|
||||
"searchpattern:s" => { name => 'searchpattern', default => 'ITEMP' },
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'apchost:s' => { name => 'apchost', default => 'localhost' },
|
||||
'apcport:s' => { name => 'apcport', default => '3551' },
|
||||
'searchpattern:s' => { name => 'searchpattern', default => 'ITEMP' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{apchost})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{apcport})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$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();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
|
||||
my $result = $options{custom}->execute_command(
|
||||
command_path => '/sbin',
|
||||
command => 'apcaccess',
|
||||
command_options => 'status ' . $self->{option_results}->{apchost} . ':' . $self->{option_results}->{apcport} . ' 2>&1',
|
||||
searchpattern => $self->{option_results}->{searchpattern}
|
||||
);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -101,7 +97,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check apcupsd Status
|
||||
Check temperature
|
||||
|
||||
Command used: /sbin/apcaccess status %(apchost):%(apcport) 2>&1
|
||||
|
||||
=over 8
|
||||
|
||||
@ -121,18 +119,6 @@ Warning Threshold
|
||||
|
||||
Critical Threshold
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
@ -24,75 +24,71 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use apps::apcupsd::local::mode::libgetdata;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'apcaccess' },
|
||||
"command-path:s" => { name => 'command_path', default => '/sbin/' },
|
||||
"command-options:s" => { name => 'command_options', default => ' status ' },
|
||||
"command-options2:s" => { name => 'command_options2', default => ' 2>&1' },
|
||||
"apchost:s" => { name => 'apchost', default => 'localhost' },
|
||||
"apcport:s" => { name => 'apcport', default => '3551' },
|
||||
"searchpattern:s" => { name => 'searchpattern', default => 'TIMELEFT' },
|
||||
"warning:s" => { name => 'warning', default => '' },
|
||||
"critical:s" => { name => 'critical', default => '' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'apchost:s' => { name => 'apchost', default => 'localhost' },
|
||||
'apcport:s' => { name => 'apcport', default => '3551' },
|
||||
'searchpattern:s' => { name => 'searchpattern', default => 'TIMELEFT' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{apchost})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Host.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{apcport})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$self->{output}->option_exit();
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify an APC Port.");
|
||||
$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();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = apps::apcupsd::local::mode::libgetdata::getdata($self);
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result));
|
||||
my $result = $options{custom}->execute_command(
|
||||
command_path => '/sbin',
|
||||
command => 'apcaccess',
|
||||
command_options => 'status ' . $self->{option_results}->{apchost} . ':' . $self->{option_results}->{apcport} . ' 2>&1',
|
||||
searchpattern => $self->{option_results}->{searchpattern}
|
||||
);
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf($self->{option_results}->{searchpattern} . ": %f", $result)
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => $self->{option_results}->{searchpattern},
|
||||
value => $result,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@ -101,7 +97,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check apcupsd Status
|
||||
Check battery time left
|
||||
|
||||
Command used: /sbin/apcaccess status %(apchost):%(apcport) 2>&1
|
||||
|
||||
=over 8
|
||||
|
||||
@ -121,18 +119,6 @@ Warning Threshold
|
||||
|
||||
Critical Threshold
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
If you dont wanna install the apcupsd client on your local system you can run it remotely with 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=item B<--ssh-option>
|
||||
|
||||
Specify multiple options like the user (example: --ssh-option='-l=centreon-engine' --ssh-option='-p=52').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -76,24 +76,26 @@ package apps::apcupsd::local::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_simple);
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'batterycharge' => 'apps::apcupsd::local::mode::batterycharge', # BCHARGE
|
||||
'temperature' => 'apps::apcupsd::local::mode::temperature', # ITEMP
|
||||
'timeleft' => 'apps::apcupsd::local::mode::timeleft', # TIMELEFT MAXTIME MINTIMEL
|
||||
'linevoltage' => 'apps::apcupsd::local::mode::linevoltage', # LINEV
|
||||
'batteryvoltage' => 'apps::apcupsd::local::mode::batteryvoltage', # BATTV
|
||||
'outputvoltage' => 'apps::apcupsd::local::mode::outputvoltage', # OUTPUTV
|
||||
'linefrequency' => 'apps::apcupsd::local::mode::linefrequency', # LINEFREQ
|
||||
'loadpercentage' => 'apps::apcupsd::local::mode::loadpercentage', # LOADPCT
|
||||
);
|
||||
$self->{modes} = {
|
||||
'batterycharge' => 'apps::apcupsd::local::mode::batterycharge', # BCHARGE
|
||||
'temperature' => 'apps::apcupsd::local::mode::temperature', # ITEMP
|
||||
'timeleft' => 'apps::apcupsd::local::mode::timeleft', # TIMELEFT MAXTIME MINTIMEL
|
||||
'linevoltage' => 'apps::apcupsd::local::mode::linevoltage', # LINEV
|
||||
'batteryvoltage' => 'apps::apcupsd::local::mode::batteryvoltage', # BATTV
|
||||
'outputvoltage' => 'apps::apcupsd::local::mode::outputvoltage', # OUTPUTV
|
||||
'linefrequency' => 'apps::apcupsd::local::mode::linefrequency', # LINEFREQ
|
||||
'loadpercentage' => 'apps::apcupsd::local::mode::loadpercentage' # LOADPCT
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{cli} = 'apps::apcupsd::local::custom::cli';
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -20,81 +20,30 @@
|
||||
|
||||
package apps::automation::ansible::cli::custom::cli;
|
||||
|
||||
use base qw(centreon::plugins::script_custom::cli);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use JSON::XS;
|
||||
|
||||
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' },
|
||||
'remote' => { name => 'remote' },
|
||||
'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 => 50 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'CLI OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
sub execute_command {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $options{cmd_options} . "'", debug => 1);
|
||||
|
||||
my ($response) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $options{cmd_options},
|
||||
no_errors => { 4 => 1 }
|
||||
my ($stdout, $exit_code) = $self->SUPER::execute_command(
|
||||
%options,
|
||||
no_quit => 1
|
||||
);
|
||||
if ($exit_code != 0 && $exit_code != 4) {
|
||||
$self->{output}->add_option_msg(short_msg => "Command error: $stdout");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $raw_results;
|
||||
|
||||
eval {
|
||||
$raw_results = JSON::XS->new->utf8->decode($response);
|
||||
$raw_results = JSON::XS->new->utf8->decode($stdout);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->output_add(long_msg => $response, debug => 1);
|
||||
$self->{output}->output_add(long_msg => $stdout, debug => 1);
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
@ -102,25 +51,6 @@ sub execute {
|
||||
return $raw_results;
|
||||
}
|
||||
|
||||
sub ansible_list_hosts_set_cmd {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne '');
|
||||
|
||||
my $cmd_options = "$options{host_pattern} --module-name=setup";
|
||||
|
||||
return $cmd_options;
|
||||
}
|
||||
|
||||
sub ansible_list_hosts {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $cmd_options = $self->ansible_list_hosts_set_cmd(%options);
|
||||
my $raw_results = $self->execute(cmd_options => $cmd_options);
|
||||
|
||||
return $raw_results;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
@ -133,31 +63,6 @@ Ansible CLI
|
||||
|
||||
Ansible CLI
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout in seconds (Default: 50).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: none).
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
@ -52,7 +52,10 @@ sub run {
|
||||
|
||||
$disco_stats->{start_time} = time();
|
||||
|
||||
my $result = $options{custom}->ansible_list_hosts(host_pattern => $self->{option_results}->{host_pattern});
|
||||
my $result = $options{custom}->execute_command(
|
||||
command => 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible',
|
||||
command_options => "'" . $self->{option_results}->{host_pattern} . "' --module-name=setup",
|
||||
);
|
||||
|
||||
$disco_stats->{end_time} = time();
|
||||
$disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time};
|
||||
@ -100,6 +103,8 @@ __END__
|
||||
|
||||
Resources discovery.
|
||||
|
||||
Command used: ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible %(host_pattern) --module-name=setup
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--host-pattern>
|
||||
|
@ -45,9 +45,9 @@ sub new {
|
||||
'password:s' => { name => 'password' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'tower-cli' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'nossl' => { name => 'nossl' },
|
||||
'proxyurl:s' => { name => 'proxyurl' }
|
||||
});
|
||||
@ -91,13 +91,22 @@ sub check_options {
|
||||
sub execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $options{cmd_options} . "'", debug => 1);
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
my $command = defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : 'tower-cli';
|
||||
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $command . " " . $options{cmd_options} . "'", debug => 1);
|
||||
|
||||
my ($response) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command => $command,
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $options{cmd_options}
|
||||
);
|
||||
|
@ -101,9 +101,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -116,6 +116,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -135,9 +135,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -149,6 +149,24 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -121,9 +121,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -137,6 +137,24 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -36,9 +36,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -51,6 +51,18 @@ sub new {
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -182,47 +182,6 @@ Command used: vmquery -a -w
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'vmquery').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-a -w').
|
||||
|
||||
=item B<--exec-only>
|
||||
|
||||
Print command output
|
||||
|
@ -31,27 +31,40 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'vtconfig' },
|
||||
"command-path:s" => { name => 'command_path', default => '/quadstorvtl/bin' },
|
||||
"command-options:s" => { name => 'command_options', default => '-l' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options' },
|
||||
"filter-name:s" => { name => 'filter_name' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'vtconfig'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-l'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
$self->{option_results}->{command_path} = '/quadstorvtl/bin'
|
||||
if (!defined($self->{option_results}->{command_path}) || $self->{option_results}->{command_path} eq '');
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -109,6 +109,12 @@ sub custom_usage_calc {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_disk_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Disk '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
@ -141,24 +147,23 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'bdconfig' },
|
||||
"command-path:s" => { name => 'command_path', default => '/quadstorvtl/bin' },
|
||||
"command-options:s" => { name => 'command_options', default => '-l -c' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /active/i' },
|
||||
"units:s" => { name => 'units', default => '%' },
|
||||
"free" => { name => 'free' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /active/i' },
|
||||
"units:s" => { name => 'units', default => '%' },
|
||||
"free" => { name => 'free' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
@ -167,24 +172,35 @@ sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'bdconfig'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-l -c'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
$self->{option_results}->{command_path} = '/quadstorvtl/bin'
|
||||
if (!defined($self->{option_results}->{command_path}) || $self->{option_results}->{command_path} eq '');
|
||||
|
||||
$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 ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my ($stdout) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
);
|
||||
|
||||
$self->{disk} = {};
|
||||
#ID Vendor Model SerialNumber Name Pool Size Used Status
|
||||
#1 Msft Virtual /dev/sdb Default 1024.00 21.28 Active
|
||||
|
@ -123,14 +123,33 @@ sub new {
|
||||
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'impexp' },
|
||||
'command-path:s' => { name => 'command_path', default => '/quadstorvtl/bin' },
|
||||
'command-options:s' => { name => 'command_options', default => '-l' }
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'impexp'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-l'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
$self->{option_results}->{command_path} = '/quadstorvtl/bin'
|
||||
if (!defined($self->{option_results}->{command_path}) || $self->{option_results}->{command_path} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -162,9 +162,9 @@ sub new {
|
||||
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'vcconfig' },
|
||||
'command-path:s' => { name => 'command_path', default => '/quadstorvtl/bin' },
|
||||
'command-options:s' => { name => 'command_options', default => '-l -v %{vtl_name}' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'vtl-name:s' => { name => 'vtl_name' },
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
@ -185,6 +185,20 @@ sub check_options {
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'vcconfig'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-l -v %{vtl_name}'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
$self->{option_results}->{command_path} = '/quadstorvtl/bin'
|
||||
if (!defined($self->{option_results}->{command_path}) || $self->{option_results}->{command_path} eq '');
|
||||
|
||||
$self->{option_results}->{command_options} =~ s/%\{vtl_name\}/$self->{option_results}->{vtl_name}/;
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ sub new {
|
||||
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||
'timeout:s' => { name => 'timeout', default => 45 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'dsmadmc' },
|
||||
'command-path:s' => { name => 'command_path', default => '/opt/tivoli/tsm/client/ba/bin' },
|
||||
'command-options:s' => { name => 'command_options', default => '' }
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'TSM CLI OPTIONS', once => 1);
|
||||
@ -84,6 +84,18 @@ sub check_options {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to set tsm-password option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'dsmadmc'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_path} = '/opt/tivoli/tsm/client/ba/bin'
|
||||
if (!defined($self->{option_results}->{command_path}) || $self->{option_results}->{command_path} eq '');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -110,9 +110,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -135,6 +135,18 @@ sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros(macros => ['ok_status', 'warning_status', 'critical_status', 'warning_long', 'critical_long']);
|
||||
}
|
||||
|
||||
|
@ -159,9 +159,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -178,6 +178,18 @@ sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
if ($self->{option_results}->{unit} eq '' || !defined($unitdiv->{$self->{option_results}->{unit}})) {
|
||||
$self->{option_results}->{unit} = 's';
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -51,6 +51,18 @@ sub new {
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -36,9 +36,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' }
|
||||
@ -50,6 +50,18 @@ sub new {
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -136,9 +136,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -150,6 +150,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -88,9 +88,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -102,6 +102,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -120,9 +120,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -134,6 +134,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -78,6 +78,13 @@ sub check_options {
|
||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,8 @@ sub set_counters {
|
||||
threshold_use => $_->[0] ,
|
||||
closure_custom_output => $self->can('custom_' . $type . '_execution_time_output'),
|
||||
perfdatas => [
|
||||
{ value => $_->[0] , template => '%.3f', min => 0, unit => 's' },
|
||||
],
|
||||
{ value => $_->[0] , template => '%.3f', min => 0, unit => 's' }
|
||||
]
|
||||
}
|
||||
}
|
||||
;
|
||||
@ -183,8 +183,8 @@ sub set_counters {
|
||||
threshold_use => $_->[0] ,
|
||||
closure_custom_output => $self->can('custom_' . $type . '_checked_output'),
|
||||
perfdatas => [
|
||||
{ value => $_->[0] , template => '%d', min => 0 },
|
||||
],
|
||||
{ value => $_->[0] , template => '%d', min => 0 }
|
||||
]
|
||||
}
|
||||
}
|
||||
;
|
||||
@ -226,8 +226,8 @@ sub set_counters {
|
||||
threshold_use => $_->[0] ,
|
||||
closure_custom_output => $self->can('custom_hosts_status_output'),
|
||||
perfdatas => [
|
||||
{ value => $_->[0] , template => '%s', min => 0, max => 'total' },
|
||||
],
|
||||
{ value => $_->[0] , template => '%s', min => 0, max => 'total' }
|
||||
]
|
||||
}
|
||||
}
|
||||
;
|
||||
@ -247,8 +247,8 @@ sub set_counters {
|
||||
threshold_use => $_->[0] ,
|
||||
closure_custom_output => $self->can('custom_services_status_output'),
|
||||
perfdatas => [
|
||||
{ value => $_->[0] , template => '%s', min => 0, max => 'total' },
|
||||
],
|
||||
{ value => $_->[0] , template => '%s', min => 0, max => 'total' }
|
||||
]
|
||||
}
|
||||
}
|
||||
;
|
||||
@ -268,8 +268,8 @@ sub set_counters {
|
||||
threshold_use => $_->[0] ,
|
||||
closure_custom_output => $self->can('custom_commands_buffer_output'),
|
||||
perfdatas => [
|
||||
{ value => $_->[0] , template => '%s', min => 0, max => 'total' },
|
||||
],
|
||||
{ value => $_->[0] , template => '%s', min => 0, max => 'total' }
|
||||
]
|
||||
}
|
||||
}
|
||||
;
|
||||
@ -282,21 +282,40 @@ sub new {
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'command:s' => { name => 'command', default => 'centenginestats' },
|
||||
'command-path:s' => { name => 'command_path', default => '/usr/sbin' },
|
||||
'command-options:s' => { name => 'command_options', default => '2>&1' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'remote' => { name => 'remote' },
|
||||
'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 => 30 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'sudo' => { name => 'sudo' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'centenginestats'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '2>&1'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
$self->{option_results}->{command_path} = '/usr/sbin'
|
||||
if (!defined($self->{option_results}->{command_path}) || $self->{option_results}->{command_path} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -75,6 +75,20 @@ sub check_options {
|
||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command_drives},
|
||||
command_options => $self->{option_results}->{command_options_drives},
|
||||
command_path => $self->{option_results}->{command_path_drives}
|
||||
);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command_hddtemp},
|
||||
command_options => $self->{option_results}->{command_options_hddtemp},
|
||||
command_path => $self->{option_results}->{command_path_hddtemp}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
@ -75,6 +75,19 @@ sub check_options {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--password' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
|
@ -264,9 +264,9 @@ sub new {
|
||||
'no-mapi' => { name => 'no_mapi' },
|
||||
'no-copystatus' => { name => 'no_copystatus' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'ps-server-filter:s' => { name => 'ps_server_filter' },
|
||||
@ -277,6 +277,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -38,9 +38,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
@ -74,6 +74,19 @@ sub check_options {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--password' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'ps-database-filter:s' => { name => 'ps_database_filter' }
|
||||
@ -53,6 +53,18 @@ sub new {
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -115,9 +115,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'ps-server:s' => { name => 'ps_server' },
|
||||
@ -129,6 +129,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -38,9 +38,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
@ -69,6 +69,19 @@ sub check_options {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--mailbox' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'warning:s' => { name => 'warning', },
|
||||
@ -70,6 +70,19 @@ sub check_options {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--mailbox' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
@ -80,6 +80,19 @@ sub check_options {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify '--password' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' }
|
||||
});
|
||||
@ -94,6 +94,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -38,9 +38,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password', },
|
||||
'no-ps' => { name => 'no_ps', },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only', },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'warning:s' => { name => 'warning', },
|
||||
@ -64,6 +64,18 @@ sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,9 @@ sub new {
|
||||
'remote-password:s' => { name => 'remote_password' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
@ -64,6 +64,18 @@ sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' }
|
||||
@ -50,6 +50,18 @@ sub new {
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -103,9 +103,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -117,6 +117,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -72,9 +72,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -84,6 +84,24 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -77,9 +77,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -91,6 +91,24 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -66,9 +66,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -79,6 +79,24 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -48,9 +48,9 @@ sub new {
|
||||
'scvmm-password:s' => { name => 'scvmm_password' },
|
||||
'scvmm-port:s' => { name => 'scvmm_port', default => 8100 },
|
||||
'timeout:s' => { name => 'timeout', default => 90 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' }
|
||||
@ -79,6 +79,18 @@ sub check_options {
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub powershell_exec {
|
||||
|
@ -151,9 +151,9 @@ sub new {
|
||||
'scvmm-password:s' => { name => 'scvmm_password' },
|
||||
'scvmm-port:s' => { name => 'scvmm_port', default => 8100 },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -178,6 +178,18 @@ sub check_options {
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -68,9 +68,9 @@ sub new {
|
||||
'scvmm-password:s' => { name => 'scvmm_password' },
|
||||
'scvmm-port:s' => { name => 'scvmm_port', default => 8100 },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -95,6 +95,18 @@ sub check_options {
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -71,9 +71,9 @@ sub new {
|
||||
'scvmm-password:s' => { name => 'scvmm_password' },
|
||||
'scvmm-port:s' => { name => 'scvmm_port', default => 8100 },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -97,6 +97,18 @@ sub check_options {
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -147,9 +147,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -159,6 +159,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -115,9 +115,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' }
|
||||
@ -126,6 +126,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -92,9 +92,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -107,6 +107,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -110,9 +110,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -124,6 +124,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -218,9 +218,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -241,6 +241,18 @@ sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
|
||||
$self->change_macros(macros => [
|
||||
'warning_synchronisation_status', 'critical_synchronisation_status',
|
||||
'warning_last_synchronisation_status', 'critical_last_synchronisation_status']
|
||||
|
@ -92,9 +92,9 @@ sub new {
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'command:s' => { name => 'command', default => 'powershell.exe' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'no-ps' => { name => 'no_ps' },
|
||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||
'ps-display' => { name => 'ps_display' },
|
||||
@ -106,6 +106,23 @@ sub new {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'powershell.exe'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-InputFormat none -NoLogo -EncodedCommand'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -40,7 +40,7 @@ sub new {
|
||||
'subinstance:s' => { name => 'subinstance' },
|
||||
'filter-instance:s' => { name => 'filter_instance' },
|
||||
'filter-subinstance:s' => { name => 'filter_subinstance' },
|
||||
'new-perfdata' => { name => 'new_perfdata' },
|
||||
'new-perfdata' => { name => 'new_perfdata' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
@ -51,19 +51,19 @@ sub check_options {
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{metrics} = centreon::common::monitoring::openmetrics::scrape::parse(%options,strip_chars => "[\"']");
|
||||
$self->{metrics} = centreon::common::monitoring::openmetrics::scrape::parse(%options, strip_chars => "[\"']");
|
||||
|
||||
my @exits;
|
||||
my $short_msg = 'All metrics are ok';
|
||||
@ -100,8 +100,11 @@ sub run {
|
||||
|
||||
push @exits, $self->{perfdata}->threshold_check(
|
||||
value => $data->{value},
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' },
|
||||
{ label => 'warning', exit_litteral => 'warning' } ]);
|
||||
threshold => [
|
||||
{ label => 'critical', exit_litteral => 'critical' },
|
||||
{ label => 'warning', exit_litteral => 'warning' }
|
||||
]
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label,
|
||||
@ -110,11 +113,15 @@ sub run {
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||
);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Metric '%s' value is '%s' [Help: \"%s\"] [Type: '%s'] [Dimensions: \"%s\"]",
|
||||
$metric, $data->{value},
|
||||
(defined($self->{metrics}->{$metric}->{help})) ? $self->{metrics}->{$metric}->{help} : '-',
|
||||
(defined($self->{metrics}->{$metric}->{type})) ? $self->{metrics}->{$metric}->{type} : '-',
|
||||
$data->{dimensions_string}));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"Metric '%s' value is '%s' [Help: \"%s\"] [Type: '%s'] [Dimensions: \"%s\"]",
|
||||
$metric, $data->{value},
|
||||
(defined($self->{metrics}->{$metric}->{help})) ? $self->{metrics}->{$metric}->{help} : '-',
|
||||
(defined($self->{metrics}->{$metric}->{type})) ? $self->{metrics}->{$metric}->{type} : '-',
|
||||
$data->{dimensions_string}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +129,7 @@ sub run {
|
||||
$self->{output}->add_option_msg(short_msg => "No metrics found.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => \@exits);
|
||||
$short_msg = 'Some metrics are not ok' if ($exit !~ /OK/i);
|
||||
$self->{output}->output_add(severity => $exit, short_msg => $short_msg);
|
||||
@ -153,7 +160,7 @@ Examples:
|
||||
--custommode=file --command-options='/tmp/metrics' --filter-metrics='cpu' --verbose
|
||||
|
||||
# perl centreon_plugins.pl --plugin=apps::monitoring::openmetrics::plugin --mode=scrape-metrics
|
||||
--custommode=file --hostname=10.2.3.4 --ssh-option='-l=centreon-engine' --ssh-option='-p=52'
|
||||
--custommode=file --hostname=10.2.3.4 --ssh-username='centreon-engine' --ssh-port='52'
|
||||
--command-options='/my/app/path/metrics' --verbose
|
||||
|
||||
=over 8
|
||||
|
@ -29,12 +29,12 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'scrape-metrics' => 'apps::monitoring::openmetrics::mode::scrapemetrics',
|
||||
);
|
||||
$self->{custom_modes}{web} = 'centreon::common::monitoring::openmetrics::custom::web';
|
||||
$self->{custom_modes}{file} = 'centreon::common::monitoring::openmetrics::custom::file';
|
||||
$self->{modes} = {
|
||||
'scrape-metrics' => 'apps::monitoring::openmetrics::mode::scrapemetrics'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{web} = 'centreon::common::monitoring::openmetrics::custom::web';
|
||||
$self->{custom_modes}->{file} = 'centreon::common::monitoring::openmetrics::custom::file';
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,13 @@ sub check_options {
|
||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
package centreon::common::monitoring::openmetrics::custom::file;
|
||||
|
||||
use base qw(centreon::plugins::script_custom::cli);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
@ -27,51 +29,29 @@ use Digest::MD5 qw(md5_hex);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = {};
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, nohelp => 1);
|
||||
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 => 10 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'cat' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options' }
|
||||
});
|
||||
}
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'FILE OPTIONS', once => 1);
|
||||
|
||||
$self->{output} = $options{output};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||
$self->{option_results}->{remote} = 1;
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'cat'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
|
||||
if (defined($self->{option_results}->{command_options})) {
|
||||
# we remove illegal characters
|
||||
$self->{option_results}->{command_options} =~ s/[`;!&]//g;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -89,14 +69,8 @@ sub get_uuid {
|
||||
sub scrape {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
);
|
||||
my ($stdout) = $self->SUPER::execute_command(%options);
|
||||
return $stdout;
|
||||
}
|
||||
|
||||
1;
|
||||
@ -117,27 +91,7 @@ Openmetrics file custom mode
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Endpoint hostname (If remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
Hostname to query (with ssh).
|
||||
|
||||
=item B<--command>
|
||||
|
||||
@ -149,11 +103,7 @@ Command path.
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options).
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set SSH timeout (Default: 10).
|
||||
Command options.
|
||||
|
||||
=back
|
||||
|
||||
|
@ -28,7 +28,7 @@ sub parse {
|
||||
my (%options) = @_;
|
||||
|
||||
my $result;
|
||||
my $response = $options{custom}->scrape;
|
||||
my $response = $options{custom}->scrape();
|
||||
|
||||
foreach my $line (split /\n/, $response) {
|
||||
$result->{metrics}->{$1}->{type} = $2 if ($line =~ /^#\sTYPE\s(\w+)\s(.*)$/);
|
||||
|
@ -23,7 +23,7 @@ package centreon::common::powershell::backupexec::disks;
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::common::powershell::functions;
|
||||
use centreon::common::powershell::veeam::functions;
|
||||
use centreon::common::powershell::backupexec::functions;
|
||||
|
||||
sub get_powershell {
|
||||
my (%options) = @_;
|
||||
|
@ -31,7 +31,7 @@ sub new {
|
||||
|
||||
if (!defined($options{noptions}) || $options{noptions} != 1) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'plink-command:s' => { name => 'plink_command', default => 'plink' },
|
||||
'plink-command:s' => { name => 'plink_command' },
|
||||
'plink-path:s' => { name => 'plink_path' },
|
||||
'plink-option:s@' => { name => 'plink_option' }
|
||||
});
|
||||
@ -54,6 +54,13 @@ sub check_options {
|
||||
$self->{ssh_username} = $options{option_results}->{ssh_username};
|
||||
$self->{ssh_password} = $options{option_results}->{ssh_password};
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $options{option_results}->{plink_command},
|
||||
command_options => join('', @{$self->{ssh_option}}),
|
||||
command_path => $self->{ssh_path}
|
||||
);
|
||||
|
||||
push @{$self->{ssh_option}}, '-batch';
|
||||
push @{$self->{ssh_option}}, '-l=' . $self->{ssh_username} if (defined($self->{ssh_username}) && $self->{ssh_username} ne '');
|
||||
push @{$self->{ssh_option}}, '-pw=' . $self->{ssh_password} if (defined($self->{ssh_password}) && $self->{ssh_password} ne '');
|
||||
|
@ -31,7 +31,7 @@ sub new {
|
||||
|
||||
if (!defined($options{noptions}) || $options{noptions} != 1) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'sshcli-command:s' => { name => 'sshcli_command', default => 'ssh' },
|
||||
'sshcli-command:s' => { name => 'sshcli_command' },
|
||||
'sshcli-path:s' => { name => 'sshcli_path' },
|
||||
'sshcli-option:s@' => { name => 'sshcli_option' }
|
||||
});
|
||||
@ -57,6 +57,13 @@ sub check_options {
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $options{option_results}->{sshcli_command},
|
||||
command_options => join('', @{$self->{ssh_option}}),
|
||||
command_path => $self->{ssh_path}
|
||||
);
|
||||
|
||||
push @{$self->{ssh_option}}, '-o=BatchMode=yes';
|
||||
push @{$self->{ssh_option}}, '-l=' . $self->{ssh_username} if (defined($self->{ssh_username}) && $self->{ssh_username} ne '');
|
||||
push @{$self->{ssh_option}}, '-p=' . $self->{ssh_port} if (defined($self->{ssh_port}) && $self->{ssh_port} ne '');
|
||||
|
@ -23,6 +23,7 @@ package centreon::plugins::misc;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use JSON::XS;
|
||||
|
||||
sub execute {
|
||||
my (%options) = @_;
|
||||
@ -616,6 +617,56 @@ sub eval_ssl_options {
|
||||
return $ssl_context;
|
||||
}
|
||||
|
||||
sub slurp_file {
|
||||
my (%options) = @_;
|
||||
|
||||
my $content = do {
|
||||
local $/ = undef;
|
||||
if (!open my $fh, '<', $options{file}) {
|
||||
$options{output}->add_option_msg(short_msg => "Could not open file $options{file}: $!");
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
<$fh>;
|
||||
};
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
sub check_security_command {
|
||||
my (%options) = @_;
|
||||
|
||||
return 0 if (!(
|
||||
(defined($options{command}) && $options{command} ne '') ||
|
||||
(defined($options{command_options}) && $options{command_options} ne '') ||
|
||||
(defined($options{command_path}) && $options{command_path} ne ''))
|
||||
);
|
||||
|
||||
my $security_file = '/etc/centreon-plugins/security.json';
|
||||
if ($^O eq 'MSWin32') {
|
||||
$security_file = 'C:/Program Files/centreon-plugins/security.json';
|
||||
}
|
||||
|
||||
return 0 if (! -r "$security_file" || -z "$security_file");
|
||||
|
||||
my $content = slurp_file(output => $options{output}, file => $security_file);
|
||||
|
||||
my $security;
|
||||
eval {
|
||||
$security = JSON::XS->new->utf8->decode($content);
|
||||
};
|
||||
if ($@) {
|
||||
$options{output}->add_option_msg(short_msg => 'Cannot decode security file content');
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
if (defined($security->{block_command_overload}) && $security->{block_command_overload} == 1) {
|
||||
$options{output}->add_option_msg(short_msg => 'Cannot overload command (security)');
|
||||
$options{output}->option_exit();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
@ -50,7 +50,8 @@ sub new {
|
||||
});
|
||||
}
|
||||
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'CLI OPTIONS', once => 1);
|
||||
$options{options}->add_help(package => __PACKAGE__, sections => 'CLI OPTIONS', once => 1)
|
||||
if (!defined($options{nohelp}));
|
||||
|
||||
$self->{output} = $options{output};
|
||||
$self->{ssh} = centreon::plugins::ssh->new(%options);
|
||||
@ -76,6 +77,13 @@ sub check_options {
|
||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -92,6 +100,7 @@ sub get_identifier {
|
||||
sub execute_command {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
my $timeout = $self->{timeout};
|
||||
if (!defined($timeout)) {
|
||||
$timeout = defined($options{timeout}) ? $options{timeout} : 45;
|
||||
|
@ -22,6 +22,7 @@ package cloud::aws::custom::awscli;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use DateTime;
|
||||
use JSON::XS;
|
||||
|
||||
@ -54,9 +55,9 @@ sub new {
|
||||
'zeroed' => { name => 'zeroed' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'aws' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'skip-ssl-check' => { name => 'skip_ssl_check' },
|
||||
'proxyurl:s' => { name => 'proxyurl' }
|
||||
});
|
||||
@ -148,22 +149,31 @@ sub check_options {
|
||||
|
||||
$self->{endpoint_url} = (defined($self->{option_results}->{endpoint_url})) ? $self->{option_results}->{endpoint_url} : undef;
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $command = defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : 'aws';
|
||||
|
||||
my $cmd_options = $options{cmd_options};
|
||||
$cmd_options .= " --debug" if ($self->{output}->is_debug());
|
||||
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $cmd_options . "'", debug => 1);
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $command . " " . $cmd_options . "'", debug => 1);
|
||||
|
||||
my ($response) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command => $command,
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $cmd_options,
|
||||
redirect_stderr => ($self->{output}->is_debug()) ? 0 : 1
|
||||
|
@ -22,6 +22,7 @@ package cloud::azure::custom::azcli;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use DateTime;
|
||||
use JSON::XS;
|
||||
|
||||
@ -51,9 +52,9 @@ sub new {
|
||||
'zeroed' => { name => 'zeroed' },
|
||||
'timeout:s' => { name => 'timeout', default => 50 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'az' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'proxyurl:s' => { name => 'proxyurl' }
|
||||
});
|
||||
}
|
||||
@ -91,21 +92,31 @@ sub check_options {
|
||||
|
||||
$self->{subscription} = (defined($self->{option_results}->{subscription})) ? $self->{option_results}->{subscription} : undef;
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $options{cmd_options} . "'", debug => 1);
|
||||
my $command = defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : 'az';
|
||||
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $command . " " . $options{cmd_options} . "'", debug => 1);
|
||||
|
||||
my ($response) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command => $command,
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $options{cmd_options});
|
||||
command_options => $options{cmd_options}
|
||||
);
|
||||
|
||||
my $raw_results;
|
||||
|
||||
|
@ -22,6 +22,7 @@ package cloud::kubernetes::custom::kubectl;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
@ -48,9 +49,9 @@ sub new {
|
||||
'config-file:s' => { name => 'config_file', default => '~/.kube/config' },
|
||||
'context:s' => { name => 'context' },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'kubectl' },
|
||||
'command:s' => { name => 'command', default => '' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '' },
|
||||
'command-options:s' => { name => 'command_options' },
|
||||
'proxyurl:s' => { name => 'proxyurl' },
|
||||
});
|
||||
}
|
||||
@ -95,13 +96,22 @@ sub check_options {
|
||||
$ENV{HTTP_PROXY} = $self->{option_results}->{proxyurl};
|
||||
$ENV{HTTPS_PROXY} = $self->{option_results}->{proxyurl};
|
||||
}
|
||||
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $command = defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '' ? $self->{option_results}->{command} : 'kubectl';
|
||||
|
||||
my $cmd_options = $options{cmd_options};
|
||||
# See https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-output-verbosity-and-debugging
|
||||
$cmd_options .= " --v='9'" if ($self->{output}->is_debug());
|
||||
@ -110,13 +120,13 @@ sub execute {
|
||||
$cmd_options = $self->{option_results}->{command_options};
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $self->{option_results}->{command} . " " . $cmd_options . "'", debug => 1);
|
||||
$self->{output}->output_add(long_msg => "Command line: '" . $command . " " . $cmd_options . "'", debug => 1);
|
||||
|
||||
my ($response, $exit_code) = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command => $command,
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $cmd_options,
|
||||
redirect_stderr => ($self->{output}->is_debug()) ? 0 : 1,
|
||||
|
@ -77,6 +77,13 @@ sub check_options {
|
||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -90,14 +90,31 @@ sub new {
|
||||
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'ctconf' },
|
||||
'command:s' => { name => 'command' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-v' }
|
||||
'command-options:s' => { name => 'command_options' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'ctconf'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_options} = '-v'
|
||||
if (!defined($self->{option_results}->{command_options}) || $self->{option_results}->{command_options} eq '');
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
@ -26,6 +26,12 @@ use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub prefix_device_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "'" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
@ -78,38 +84,51 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'tempered' },
|
||||
"command-path:s" => { name => 'command_path', default => '/opt/PCsensor/TEMPered/utils/' },
|
||||
"command-options:s" => { name => 'command_options' },
|
||||
"filter-drive:s" => { name => 'filter_drive', default => '.*' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options' },
|
||||
"filter-drive:s" => { name => 'filter_drive', default => '.*' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub prefix_device_output {
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
return "'" . $options{instance_value}->{display} . "' ";
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'tempered'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
$self->{option_results}->{command_path} = '/opt/PCsensor/TEMPered/utils/'
|
||||
if (!defined($self->{option_results}->{command_path}) || $self->{option_results}->{command_path} eq '');
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{drive} = {};
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my $stdout = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
);
|
||||
|
||||
foreach (split(/\n/, $stdout)) {
|
||||
next if !/(\/dev\/[a-z0-9]+).*temperature\s(\d*\.?\d+).*relative\shumidity\s(\d*\.?\d+).*dew\spoint\s(\d*\.?\d+)/;
|
||||
|
@ -32,14 +32,14 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', default => 23 },
|
||||
"username:s" => { name => 'username' },
|
||||
"password:s" => { name => 'password' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', default => 23 },
|
||||
"username:s" => { name => 'username' },
|
||||
"password:s" => { name => 'password' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -33,19 +33,19 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', default => 23 },
|
||||
"username:s" => { name => 'username' },
|
||||
"password:s" => { name => 'password' },
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
"memory" => { name => 'memory' },
|
||||
"command-plink:s" => { name => 'command_plink', default => 'plink' },
|
||||
"ssh" => { name => 'ssh' },
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"no-component:s" => { name => 'no_component' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', default => 23 },
|
||||
"username:s" => { name => 'username' },
|
||||
"password:s" => { name => 'password' },
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
"memory" => { name => 'memory' },
|
||||
"command-plink:s" => { name => 'command_plink' },
|
||||
"ssh" => { name => 'ssh' },
|
||||
"exclude:s" => { name => 'exclude' },
|
||||
"no-component:s" => { name => 'no_component' }
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
$self->{components} = {};
|
||||
$self->{no_components} = undef;
|
||||
@ -77,7 +77,7 @@ sub check_options {
|
||||
if (!defined($self->{option_results}->{ssh})) {
|
||||
require hardware::server::sun::mgmt_cards::lib::telnet;
|
||||
}
|
||||
|
||||
|
||||
if (defined($self->{option_results}->{no_component})) {
|
||||
if ($self->{option_results}->{no_component} ne '') {
|
||||
$self->{no_components} = $self->{option_results}->{no_component};
|
||||
@ -85,6 +85,14 @@ sub check_options {
|
||||
$self->{no_components} = 'critical';
|
||||
}
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command_plink}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'plink'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
}
|
||||
|
||||
sub telnet_shell_plateform {
|
||||
@ -114,10 +122,11 @@ sub ssh_command {
|
||||
my $cmd_in = "0" . $username . $self->{option_results}->{password} . '\nshowboards\ndisconnect\n';
|
||||
my $cmd = "echo -e '$cmd_in' | " . $self->{option_results}->{command_plink} . " -batch " . $self->{option_results}->{hostname} . " 2>&1";
|
||||
my ($lerror, $stdout, $exit_code) = centreon::plugins::misc::backtick(
|
||||
command => $cmd,
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
wait_exit => 1
|
||||
);
|
||||
command => $cmd,
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
wait_exit => 1
|
||||
);
|
||||
|
||||
$stdout =~ s/\r//g;
|
||||
if ($lerror <= -1000) {
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
|
@ -79,7 +79,7 @@ sub new {
|
||||
'username:s' => { name => 'username' },
|
||||
'password:s' => { name => 'password' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'command-plink:s' => { name => 'command_plink', default => 'plink' },
|
||||
'command-plink:s' => { name => 'command_plink' },
|
||||
'ssh' => { name => 'ssh' }
|
||||
});
|
||||
|
||||
@ -106,6 +106,14 @@ sub check_options {
|
||||
if (!defined($self->{option_results}->{ssh})) {
|
||||
require hardware::server::sun::mgmt_cards::lib::telnet;
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command_plink}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'plink'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
}
|
||||
|
||||
sub ssh_command {
|
||||
|
@ -31,14 +31,14 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"username:s" => { name => 'username' },
|
||||
"password:s" => { name => 'password' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"command-plink:s" => { name => 'command_plink', default => 'plink' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"username:s" => { name => 'username' },
|
||||
"password:s" => { name => 'password' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"command-plink:s" => { name => 'command_plink' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -58,6 +58,14 @@ sub check_options {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify a password.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command_plink}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'plink'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
}
|
||||
|
||||
sub run {
|
||||
@ -68,10 +76,11 @@ sub run {
|
||||
######
|
||||
my $cmd = "echo -e '" . $self->{option_results}->{username} . "\n" . $self->{option_results}->{password} . "\nshowfaults\nlogout\n' | " . $self->{option_results}->{command_plink} . ' -T -batch ' . $self->{option_results}->{hostname} . " 2>&1";
|
||||
my ($lerror, $stdout, $exit_code) = centreon::plugins::misc::backtick(
|
||||
command => $cmd,
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
wait_exit => 1
|
||||
);
|
||||
command => $cmd,
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
wait_exit => 1
|
||||
);
|
||||
|
||||
$stdout =~ s/\r//g;
|
||||
if ($lerror <= -1000) {
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
|
@ -38,7 +38,7 @@ sub new {
|
||||
'password:s' => { name => 'password' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
'memory' => { name => 'memory' },
|
||||
'command-plink:s' => { name => 'command_plink', default => 'plink' },
|
||||
'command-plink:s' => { name => 'command_plink' }
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
@ -65,6 +65,14 @@ sub check_options {
|
||||
if (defined($self->{option_results}->{memory})) {
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command_plink}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'plink'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -39,16 +39,16 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"username:s" => { name => 'username' },
|
||||
"password:s" => { name => 'password' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"command-plink:s" => { name => 'command_plink', default => 'plink' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"exclude:s@" => { name => 'exclude' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"username:s" => { name => 'username' },
|
||||
"password:s" => { name => 'password' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
"command-plink:s" => { name => 'command_plink' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
"exclude:s@" => { name => 'exclude' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -82,6 +82,14 @@ sub check_options {
|
||||
}
|
||||
push @{$self->{overload_th}}, {filter => $filter, status => $status};
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command_plink}
|
||||
);
|
||||
|
||||
$self->{option_results}->{command} = 'plink'
|
||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '');
|
||||
}
|
||||
|
||||
sub get_severity {
|
||||
@ -109,8 +117,12 @@ sub check_exclude {
|
||||
|
||||
foreach (@{$self->{option_results}->{exclude}}) {
|
||||
if ($options{value} =~ /$_/i) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Skip Component '%s'",
|
||||
$options{value}));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"Skip Component '%s'",
|
||||
$options{value}
|
||||
)
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -134,29 +146,42 @@ sub check_tree {
|
||||
$long_instance = $stack[$#stack]->{long_instance} . '>' . $unit_number;
|
||||
$long_status = $stack[$#stack]->{long_status} . ' > ' . $unit_number . ' Status:' . $status;
|
||||
if ($indent > $stack[$#stack]->{indent}) {
|
||||
push @stack, { indent => $indent,
|
||||
long_instance => $stack[$#stack]->{long_instance} . '>' . $unit_number,
|
||||
long_status => $stack[$#stack]->{long_status} . ' > ' . $unit_number . ' Status:' . $status };
|
||||
push @stack, {
|
||||
indent => $indent,
|
||||
long_instance => $stack[$#stack]->{long_instance} . '>' . $unit_number,
|
||||
long_status => $stack[$#stack]->{long_status} . ' > ' . $unit_number . ' Status:' . $status
|
||||
};
|
||||
}
|
||||
|
||||
next if ($self->check_exclude(value => $long_instance));
|
||||
|
||||
my $exit = $self->get_severity(value => $status);
|
||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => sprintf("Component '%s' status is '%s'",
|
||||
$unit_number, $status));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit,
|
||||
short_msg => sprintf(
|
||||
"Component '%s' status is '%s'",
|
||||
$unit_number, $status
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("Component '%s' status is '%s' [%s] [%s]",
|
||||
$unit_number, $status, $long_instance, $long_status));
|
||||
$self->{output}->output_add(
|
||||
long_msg => sprintf(
|
||||
"Component '%s' status is '%s' [%s] [%s]",
|
||||
$unit_number, $status, $long_instance, $long_status
|
||||
)
|
||||
);
|
||||
$total_components++;
|
||||
}
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => sprintf("All %s components are ok.",
|
||||
$total_components)
|
||||
);
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => sprintf(
|
||||
"All %s components are ok.",
|
||||
$total_components
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
sub run {
|
||||
@ -167,31 +192,38 @@ sub run {
|
||||
# Command execution
|
||||
######
|
||||
($lerror, $self->{stdout}, $exit_code) = centreon::plugins::misc::backtick(
|
||||
command => $self->{option_results}->{command_plink},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
arguments => ['-batch', '-l', $self->{option_results}->{username},
|
||||
'-pw', $self->{option_results}->{password},
|
||||
$self->{option_results}->{hostname}, 'showhardconf'],
|
||||
wait_exit => 1,
|
||||
redirect_stderr => 1
|
||||
);
|
||||
command => $self->{option_results}->{command_plink},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
arguments => [
|
||||
'-batch', '-l', $self->{option_results}->{username},
|
||||
'-pw', $self->{option_results}->{password},
|
||||
$self->{option_results}->{hostname}, 'showhardconf'
|
||||
],
|
||||
wait_exit => 1,
|
||||
redirect_stderr => 1
|
||||
);
|
||||
|
||||
$self->{stdout} =~ s/\r//g;
|
||||
if ($lerror <= -1000) {
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
short_msg => $self->{stdout});
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => $self->{stdout}
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
if ($exit_code != 0) {
|
||||
$self->{stdout} =~ s/\n/ - /g;
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
short_msg => "Command error: $self->{stdout}");
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Command error: $self->{stdout}"
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
|
||||
$self->check_tree();
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
@ -31,24 +31,8 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote:s" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo-pasv" => { name => 'sudo_pasv' },
|
||||
"command-pasv:s" => { name => 'command_pasv', default => 'showfailover' },
|
||||
"command-path-pasv:s" => { name => 'command_path_pasv', default => '/opt/SUNWSMS/bin' },
|
||||
"command-options-pasv:s" => { name => 'command_options_pasv', default => '-r 2>&1' },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'showboards' },
|
||||
"command-path:s" => { name => 'command_path', default => '/opt/SUNWSMS/bin' },
|
||||
"command-options:s" => { name => 'command_options', default => '2>&1' },
|
||||
"show-output:s" => { name => 'show_output' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -59,36 +43,40 @@ sub check_options {
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($stdout, $exit_code) = centreon::plugins::misc::execute(label => 'pasv', output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo_pasv},
|
||||
command => $self->{option_results}->{command_pasv},
|
||||
command_path => $self->{option_results}->{command_path_pasv},
|
||||
command_options => $self->{option_results}->{command_options_pasv});
|
||||
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'showfailover',
|
||||
command_options => '-r 2>&1',
|
||||
command_path => '/opt/SUNWSMS/bin'
|
||||
);
|
||||
|
||||
if ($stdout =~ /SPARE/i) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "System Controller is in spare mode.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "System Controller is in spare mode."
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
} elsif ($stdout !~ /MAIN/i) {
|
||||
$self->{output}->output_add(long_msg => $stdout);
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
short_msg => "Command problems (see additional info).");
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Command problems (see additional info)."
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
$stdout = centreon::plugins::misc::execute(label => 'showboards', output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
($stdout) = $options{custom}->execute_command(
|
||||
command => 'showboards',
|
||||
command_options => '2>&1',
|
||||
command_path => '/opt/SUNWSMS/bin'
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No problems detected.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "No problems detected."
|
||||
);
|
||||
if ($stdout =~ /^Location(.*)/ims) {
|
||||
#Location Pwr Type of Board Board Status Test Status Domain
|
||||
#-------- --- ------------- ------------ ----------- ------
|
||||
@ -105,8 +93,10 @@ sub run {
|
||||
my ($location, $pwr, $type_board, $board_status, $test_status, $domain) = ($1, $2, $3, $4, $5, $6);
|
||||
|
||||
if ($test_status =~ /Failed|Degraded/i) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => "Error on board '$location' ($type_board) with test status '$test_status'");
|
||||
$self->{output}->output_add(
|
||||
severity => 'CRITICAL',
|
||||
short_msg => "Error on board '$location' ($type_board) with test status '$test_status'"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -125,68 +115,6 @@ Check Sun 'sfxxk' boards.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo-pasv>
|
||||
|
||||
Use 'sudo' to execute the command pasv.
|
||||
|
||||
=item B<--command-pasv>
|
||||
|
||||
Command to know if system controller is 'active' (Default: 'showfailover').
|
||||
|
||||
=item B<--command-path-pasv>
|
||||
|
||||
Command pasv path (Default: '/opt/SUNWSMS/bin').
|
||||
|
||||
=item B<--command-options-pasv>
|
||||
|
||||
Command pasv options (Default: '-r 2>&1').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'showboards').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: '/opt/SUNWSMS/bin').
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '2>&1').
|
||||
|
||||
=item B<--show-output>
|
||||
|
||||
Display command output (for debugging or saving in a file).
|
||||
A mode can have multiple (can specify the label for the command).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -31,24 +31,8 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote:s" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo-pasv" => { name => 'sudo_pasv' },
|
||||
"command-pasv:s" => { name => 'command_pasv', default => 'showfailover' },
|
||||
"command-path-pasv:s" => { name => 'command_path_pasv', default => '/opt/SUNWSMS/bin' },
|
||||
"command-options-pasv:s" => { name => 'command_options_pasv', default => '-r 2>&1' },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'showenvironment' },
|
||||
"command-path:s" => { name => 'command_path', default => '/opt/SUNWSMS/bin' },
|
||||
"command-options:s" => { name => 'command_options', default => '2>&1' },
|
||||
"show-output:s" => { name => 'show_output' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -59,36 +43,40 @@ sub check_options {
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $stdout;
|
||||
|
||||
$stdout = centreon::plugins::misc::execute(label => 'pasv', output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo_pasv},
|
||||
command => $self->{option_results}->{command_pasv},
|
||||
command_path => $self->{option_results}->{command_path_pasv},
|
||||
command_options => $self->{option_results}->{command_options_pasv});
|
||||
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'showfailover',
|
||||
command_options => '-r 2>&1',
|
||||
command_path => '/opt/SUNWSMS/bin'
|
||||
);
|
||||
|
||||
if ($stdout =~ /SPARE/i) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "System Controller is in spare mode.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "System Controller is in spare mode."
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
} elsif ($stdout !~ /MAIN/i) {
|
||||
$self->{output}->output_add(long_msg => $stdout);
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
short_msg => "Command problems (see additional info).");
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Command problems (see additional info)."
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
$stdout = centreon::plugins::misc::execute(label => 'showenvironment', output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
($stdout) = $options{custom}->execute_command(
|
||||
command => 'showenvironment',
|
||||
command_options => '2>&1',
|
||||
command_path => '/opt/SUNWSMS/bin'
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No problems detected.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "No problems detected."
|
||||
);
|
||||
if ($stdout =~ /^LOCATION(.*?)\n\n/ims) {
|
||||
#LOCATION SENSOR VALUE UNIT AGE STATUS
|
||||
#---------- ------------ ----- ---- ------ ------
|
||||
@ -108,8 +96,10 @@ sub run {
|
||||
my $sensor = $2;
|
||||
$sensor = centreon::plugins::misc::trim($sensor);
|
||||
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => "Sensor '$location/$sensor' status is '" . $sensor_status . "'");
|
||||
$self->{output}->output_add(
|
||||
severity => 'CRITICAL',
|
||||
short_msg => "Sensor '$location/$sensor' status is '" . $sensor_status . "'"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,8 +121,10 @@ sub run {
|
||||
my $fanspeed = $3;
|
||||
|
||||
if ($fanspeed !~ /^NORMAL$/i) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => "FanTray '$fantray' speed status is '" . $fanspeed . "'");
|
||||
$self->{output}->output_add(
|
||||
severity => 'CRITICAL',
|
||||
short_msg => "FanTray '$fantray' speed status is '" . $fanspeed . "'"
|
||||
);
|
||||
}
|
||||
|
||||
my $fan_num = 0;
|
||||
@ -143,8 +135,10 @@ sub run {
|
||||
next if ($status eq '');
|
||||
|
||||
if ($status !~ /^OK$/i) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => "FanTray '$fantray' fan '$fan_num' status is '" . $status . "'");
|
||||
$self->{output}->output_add(
|
||||
severity => 'CRITICAL',
|
||||
short_msg => "FanTray '$fantray' fan '$fan_num' status is '" . $status . "'"
|
||||
);
|
||||
}
|
||||
$fan_num++;
|
||||
}
|
||||
@ -172,8 +166,10 @@ sub run {
|
||||
$errors .= ' [DC1=' . centreon::plugins::misc::trim($fan0) . ']' if ($fan0 !~ /OK/i);
|
||||
$errors .= ' [DC1=' . centreon::plugins::misc::trim($fan1) . ']' if ($fan1 !~ /OK/i);
|
||||
if ($errors ne '') {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => "Some errors on power '$power_name':" . $errors);
|
||||
$self->{output}->output_add(
|
||||
severity => 'CRITICAL',
|
||||
short_msg => "Some errors on power '$power_name':" . $errors
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -208,68 +204,6 @@ Check Sun 'sfxxk' environment.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo-pasv>
|
||||
|
||||
Use 'sudo' to execute the command pasv.
|
||||
|
||||
=item B<--command-pasv>
|
||||
|
||||
Command to know if system controller is 'active' (Default: 'showfailover').
|
||||
|
||||
=item B<--command-path-pasv>
|
||||
|
||||
Command pasv path (Default: '/opt/SUNWSMS/bin').
|
||||
|
||||
=item B<--command-options-pasv>
|
||||
|
||||
Command pasv options (Default: '-r 2>&1').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'showenvironment').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: '/opt/SUNWSMS/bin').
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '2>&1').
|
||||
|
||||
=item B<--show-output>
|
||||
|
||||
Display command output (for debugging or saving in a file).
|
||||
A mode can have multiple (can specify the label for the command).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -31,23 +31,8 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo-pasv" => { name => 'sudo_pasv' },
|
||||
"command-pasv:s" => { name => 'command_pasv', default => 'showfailover' },
|
||||
"command-path-pasv:s" => { name => 'command_path_pasv', default => '/opt/SUNWSMS/bin' },
|
||||
"command-options-pasv:s" => { name => 'command_options_pasv', default => '-r 2>&1' },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'showfailover' },
|
||||
"command-path:s" => { name => 'command_path', default => '/opt/SUNWSMS/bin' },
|
||||
"command-options:s" => { name => 'command_options', default => '2>&1' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -58,44 +43,50 @@ sub check_options {
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
my $stdout;
|
||||
|
||||
$stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo_pasv},
|
||||
command => $self->{option_results}->{command_pasv},
|
||||
command_path => $self->{option_results}->{command_path_pasv},
|
||||
command_options => $self->{option_results}->{command_options_pasv});
|
||||
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'showfailover',
|
||||
command_options => '-r 2>&1',
|
||||
command_path => '/opt/SUNWSMS/bin'
|
||||
);
|
||||
|
||||
if ($stdout =~ /SPARE/i) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "System Controller is in spare mode.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "System Controller is in spare mode."
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
} elsif ($stdout !~ /MAIN/i) {
|
||||
$self->{output}->output_add(long_msg => $stdout);
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
short_msg => "Command problems (see additional info).");
|
||||
$self->{output}->output_add(
|
||||
severity => 'UNKNOWN',
|
||||
short_msg => "Command problems (see additional info)."
|
||||
);
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
$stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
|
||||
($stdout) = $options{custom}->execute_command(
|
||||
command => 'showfailover',
|
||||
command_options => '2>&1',
|
||||
command_path => '/opt/SUNWSMS/bin'
|
||||
);
|
||||
|
||||
# 'ACTIVITING' is like 'ACTIVE' for us.
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "System Controller Failover Status is ACTIVE.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "System Controller Failover Status is ACTIVE."
|
||||
);
|
||||
if ($stdout =~ /^SC Failover Status:(.*?)($|\n)/ims) {
|
||||
my $failover_status = $1;
|
||||
$failover_status = centreon::plugins::misc::trim($failover_status);
|
||||
# Can be FAILED or DISABLED
|
||||
if ($failover_status !~ /ACTIVE/i) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => "System Controller Failover Status is " . $failover_status . ".");
|
||||
$self->{output}->output_add(
|
||||
severity => 'CRITICAL',
|
||||
short_msg => "System Controller Failover Status is " . $failover_status . "."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,63 +104,6 @@ Check Sun 'sfxxk' system controller failover status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo-pasv>
|
||||
|
||||
Use 'sudo' to execute the command pasv.
|
||||
|
||||
=item B<--command-pasv>
|
||||
|
||||
Command to know if system controller is 'active' (Default: 'showfailover').
|
||||
|
||||
=item B<--command-path-pasv>
|
||||
|
||||
Command pasv path (Default: '/opt/SUNWSMS/bin').
|
||||
|
||||
=item B<--command-options-pasv>
|
||||
|
||||
Command pasv options (Default: '-r 2>&1').
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'showfailover').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: '/opt/SUNWSMS/bin').
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '2>&1').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -22,19 +22,20 @@ package hardware::server::sun::sfxxk::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_simple);
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
$self->{modes} = {
|
||||
'boards' => 'hardware::server::sun::sfxxk::mode::boards',
|
||||
'environment' => 'hardware::server::sun::sfxxk::mode::environment',
|
||||
'failover' => 'hardware::server::sun::sfxxk::mode::failover',
|
||||
);
|
||||
'failover' => 'hardware::server::sun::sfxxk::mode::failover'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{cli} = 'centreon::plugins::script_custom::cli';
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -20,89 +20,24 @@
|
||||
|
||||
package network::cisco::standard::ssh::custom::custom;
|
||||
|
||||
use base qw(centreon::plugins::script_custom::cli);
|
||||
|
||||
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};
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub set_options {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results} = $options{option_results};
|
||||
}
|
||||
|
||||
sub set_defaults {}
|
||||
|
||||
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 . " $_";
|
||||
$options{command} .= $append . " $_";
|
||||
$append = "\n";
|
||||
}
|
||||
|
||||
my ($content) = centreon::plugins::misc::execute(
|
||||
ssh_pipe => 1,
|
||||
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},
|
||||
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
|
||||
);
|
||||
my ($stdout) = $self->SUPER::execute_command(%options, ssh_pipe => 1,);
|
||||
$stdout =~ s/\r//mg;
|
||||
|
||||
$content =~ s/\r//mg;
|
||||
return $content;
|
||||
return $stdout;
|
||||
}
|
||||
|
||||
1;
|
||||
@ -117,7 +52,7 @@ ssh
|
||||
|
||||
my ssh
|
||||
|
||||
=head1 SSH OPTIONS
|
||||
=head1 CLI OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
@ -125,21 +60,9 @@ my ssh
|
||||
|
||||
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).
|
||||
Timeout in seconds for the command (Default: 45). Default value can be override by the mode.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
@ -153,6 +76,10 @@ Command path.
|
||||
|
||||
Command options.
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
sudo command.
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
@ -29,13 +29,12 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::cisco::standard::ssh::mode::cpu',
|
||||
'voice-dial-peer' => 'network::cisco::standard::ssh::mode::voicedialpeer',
|
||||
);
|
||||
$self->{modes} = {
|
||||
'cpu' => 'network::cisco::standard::ssh::mode::cpu',
|
||||
'voice-dial-peer' => 'network::cisco::standard::ssh::mode::voicedialpeer'
|
||||
};
|
||||
|
||||
$self->{custom_modes}{ssh} = 'network::cisco::standard::ssh::custom::custom';
|
||||
$self->{custom_modes}->{ssh} = 'network::cisco::standard::ssh::custom::custom';
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,13 @@ sub check_options {
|
||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -25,53 +25,6 @@ use base qw(centreon::plugins::templates::counter);
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'qos', type => 1, cb_prefix_output => 'prefix_qos_output', message_multiple => 'All QoS are ok', skipped_code => { -10 => 1 } },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{qos} = [
|
||||
{ label => 'in', set => {
|
||||
key_values => [ { name => 'in' }, { name => 'display' }, { name => 'speed_in' } ],
|
||||
closure_custom_calc => $self->can('custom_qos_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
|
||||
closure_custom_output => $self->can('custom_qos_output'),
|
||||
closure_custom_perfdata => $self->can('custom_qos_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_qos_threshold'),
|
||||
}
|
||||
},
|
||||
{ label => 'in-peak', set => {
|
||||
key_values => [ { name => 'in_peak' }, { name => 'display' } ],
|
||||
output_template => 'In Peak : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'traffic_in_peak', value => 'in_peak', template => '%.2f',
|
||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'out', set => {
|
||||
key_values => [ { name => 'out' }, { name => 'display' }, { name => 'speed_out' } ],
|
||||
closure_custom_calc => $self->can('custom_qos_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
|
||||
closure_custom_output => $self->can('custom_qos_output'),
|
||||
closure_custom_perfdata => $self->can('custom_qos_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_qos_threshold'),
|
||||
}
|
||||
},
|
||||
{ label => 'out-peak', set => {
|
||||
key_values => [ { name => 'out_peak' }, { name => 'display' } ],
|
||||
output_template => 'Out Peak : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'traffic_out_peak', value => 'out_peak', template => '%.2f',
|
||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub custom_qos_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
@ -138,6 +91,59 @@ sub custom_qos_calc {
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub prefix_qos_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "QoS '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'qos', type => 1, cb_prefix_output => 'prefix_qos_output', message_multiple => 'All QoS are ok', skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{qos} = [
|
||||
{ label => 'in', set => {
|
||||
key_values => [ { name => 'in' }, { name => 'display' }, { name => 'speed_in' } ],
|
||||
closure_custom_calc => $self->can('custom_qos_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
|
||||
closure_custom_output => $self->can('custom_qos_output'),
|
||||
closure_custom_perfdata => $self->can('custom_qos_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_qos_threshold')
|
||||
}
|
||||
},
|
||||
{ label => 'in-peak', set => {
|
||||
key_values => [ { name => 'in_peak' }, { name => 'display' } ],
|
||||
output_template => 'In Peak : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'traffic_in_peak', template => '%.2f',
|
||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'out', set => {
|
||||
key_values => [ { name => 'out' }, { name => 'display' }, { name => 'speed_out' } ],
|
||||
closure_custom_calc => $self->can('custom_qos_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
|
||||
closure_custom_output => $self->can('custom_qos_output'),
|
||||
closure_custom_perfdata => $self->can('custom_qos_perfdata'),
|
||||
closure_custom_threshold_check => $self->can('custom_qos_threshold')
|
||||
}
|
||||
},
|
||||
{ label => 'out-peak', set => {
|
||||
key_values => [ { name => 'out_peak' }, { name => 'display' } ],
|
||||
output_template => 'Out Peak : %s %s/s',
|
||||
output_change_bytes => 2,
|
||||
perfdatas => [
|
||||
{ label => 'traffic_out_peak', template => '%.2f',
|
||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display' }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
@ -149,40 +155,12 @@ sub new {
|
||||
"speed-in:s" => { name => 'speed_in' },
|
||||
"speed-out:s" => { name => 'speed_out' },
|
||||
"units-traffic:s" => { name => 'units_traffic', default => '%' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'tail' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options', default => '-1 /log/l_monitor' },
|
||||
"config-speed-file:s" => { name => 'config_speed_file' },
|
||||
"config-speed-file:s" => { name => 'config_speed_file' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||
$self->{option_results}->{remote} = 1;
|
||||
}
|
||||
$self->{hostname} = $self->{option_results}->{hostname};
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{hostname} = 'me';
|
||||
}
|
||||
}
|
||||
|
||||
sub prefix_qos_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "QoS '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub load_speed_config {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
@ -215,14 +193,12 @@ sub load_speed_config {
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
#id=firewall time="2017-01-31 16:56:36" fw="XXXX" tz=+0100 startime="2017-01-31 16:56:36" security=70 system=1 CPU=3,2,1 Pvm=0,0,0,0,0,0,0,0,0,0,0 Vlan96=VLAN-XXX-DMZ,15140,17768,21952,28280 Vlan76=dmz-xxx-xxx,769592,948320,591584,795856
|
||||
my $content = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my ($content) = $options{custom}->execute_command(
|
||||
command => 'tail',
|
||||
command_options => "-1 /log/l_monitor"
|
||||
);
|
||||
|
||||
$self->load_speed_config();
|
||||
$self->{qos} = {};
|
||||
@ -232,7 +208,7 @@ sub manage_selection {
|
||||
if ($content !~ /$pattern/) {
|
||||
$pattern = '(\S+?)=([^,]+?),(\d+),(\d+),(\d+),(\d+),\d+,\d+(?:\s|\Z)';
|
||||
}
|
||||
|
||||
|
||||
while ($content =~ /$pattern/msg) {
|
||||
my ($vlan, $name, $in, $in_max, $out, $out_max) = ($1, $2, $3, $4, $5, $6);
|
||||
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||
@ -245,15 +221,16 @@ sub manage_selection {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $vlan . "': no matching filter.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
$self->{qos}->{$name} = {
|
||||
display => $name,
|
||||
in => $in, in_peak => $in_max,
|
||||
out => $out, out_peak => $out_max,
|
||||
speed_in => defined($self->{config_speeds}->{$name}->{speed_in}) ? $self->{config_speeds}->{$name}->{speed_in} : 0,
|
||||
speed_out => defined($self->{config_speeds}->{$name}->{speed_out}) ? $self->{config_speeds}->{$name}->{speed_out} : 0};
|
||||
speed_out => defined($self->{config_speeds}->{$name}->{speed_out}) ? $self->{config_speeds}->{$name}->{speed_out} : 0
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (scalar(keys %{$self->{qos}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No QoS found.");
|
||||
$self->{output}->option_exit();
|
||||
@ -268,6 +245,8 @@ __END__
|
||||
|
||||
Check QoS usage.
|
||||
|
||||
Command used: 'tail -1 /log/l_monitor'
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
@ -278,43 +257,6 @@ Filter by QoS name (can be a regexp).
|
||||
|
||||
Filter by vlan name (can be a regexp).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'tail').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-1 /log/l_monitor').
|
||||
|
||||
=item B<--speed-in>
|
||||
|
||||
Set interface speed for incoming traffic (in Mb).
|
||||
@ -331,15 +273,9 @@ File with speed configurations.
|
||||
|
||||
Units of thresholds for the traffic (Default: '%') ('%', 'b/s').
|
||||
|
||||
=item B<--warning-*>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Threshold warning.
|
||||
Can be: 'in', 'in-peak', 'out', 'out-peak'.
|
||||
|
||||
=item B<--critical-*>
|
||||
|
||||
Threshold critical.
|
||||
Threshold warning.
|
||||
Thresholds.
|
||||
Can be: 'in', 'in-peak', 'out', 'out-peak'.
|
||||
|
||||
=back
|
||||
|
@ -22,17 +22,18 @@ package network::stormshield::local::plugin;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(centreon::plugins::script_simple);
|
||||
use base qw(centreon::plugins::script_custom);
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'qos-usage' => 'network::stormshield::local::mode::qosusage',
|
||||
);
|
||||
$self->{modes} = {
|
||||
'qos-usage' => 'network::stormshield::local::mode::qosusage'
|
||||
};
|
||||
|
||||
$self->{custom_modes}->{cli} = 'centreon::plugins::script_custom::cli';
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -73,6 +73,13 @@ sub check_options {
|
||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,13 @@ sub check_options {
|
||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -98,6 +105,13 @@ sub get_identifier {
|
||||
sub execute_command {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
centreon::plugins::misc::check_security_command(
|
||||
output => $self->{output},
|
||||
command => $self->{option_results}->{command},
|
||||
command_options => $self->{option_results}->{command_options},
|
||||
command_path => $self->{option_results}->{command_path}
|
||||
);
|
||||
|
||||
my $timeout = $self->{timeout};
|
||||
if (!defined($timeout)) {
|
||||
$timeout = defined($options{timeout}) ? $options{timeout} : 45;
|
||||
|
@ -24,29 +24,15 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'remote' => { name => 'remote' },
|
||||
'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 => 30 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'format' },
|
||||
'command-path:s' => { name => 'command_path', default => '/usr/sbin' },
|
||||
'command-options:s' => { name => 'command_options', default => '2>&1 << EOF
|
||||
0
|
||||
quit
|
||||
EOF' },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
@ -69,18 +55,19 @@ sub check_options {
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'format',
|
||||
command_options => '2>&1 << EOF
|
||||
0
|
||||
quit
|
||||
EOF',
|
||||
command_path => '/usr/sbin'
|
||||
);
|
||||
|
||||
my $long_msg = $stdout;
|
||||
$long_msg =~ s/\|/~/mg;
|
||||
$self->{output}->output_add(long_msg => $long_msg);
|
||||
|
||||
|
||||
my $num_errors = 0;
|
||||
my $disks_name = '';
|
||||
foreach (split /\n/, $stdout) {
|
||||
@ -90,14 +77,20 @@ sub run {
|
||||
}
|
||||
}
|
||||
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_errors,
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(
|
||||
value => $num_errors,
|
||||
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]
|
||||
);
|
||||
if ($num_errors > 0) {
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("Disks$disks_name are on errors."));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf("Disks$disks_name are on errors.")
|
||||
);
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No problems on disks.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "No problems on disks."
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
@ -112,6 +105,11 @@ __END__
|
||||
|
||||
Check disk status (need 'format' command).
|
||||
|
||||
Command used: '/usr/sbin/format 2>&1 << EOF
|
||||
0
|
||||
quit
|
||||
EOF'
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
@ -122,50 +120,6 @@ Threshold warning.
|
||||
|
||||
Threshold critical.
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'format').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: '/usr/sbin').
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '2>&1 << EOF
|
||||
0
|
||||
quit
|
||||
EOF').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,7 +24,6 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::plugins::statefile;
|
||||
|
||||
sub new {
|
||||
@ -33,22 +32,11 @@ sub new {
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'hostname:s' => { name => 'hostname' },
|
||||
'remote' => { name => 'remote' },
|
||||
'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 => 30 },
|
||||
'sudo' => { name => 'sudo' },
|
||||
'command:s' => { name => 'command', default => 'kstat' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-n sys 2>&1' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' },
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
|
||||
$self->{hostname} = undef;
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -66,30 +54,25 @@ sub check_options {
|
||||
}
|
||||
|
||||
$self->{statefile_cache}->check_options(%options);
|
||||
$self->{hostname} = $self->{option_results}->{hostname};
|
||||
if (!defined($self->{hostname})) {
|
||||
$self->{hostname} = 'me';
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(
|
||||
output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options}
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'kstat',
|
||||
command_options => '-n sys 2>&1'
|
||||
);
|
||||
$self->{statefile_cache}->read(statefile => 'cache_solaris_local_' . $self->{hostname} . '_' . $self->{mode});
|
||||
|
||||
$self->{statefile_cache}->read(statefile => 'cache_solaris_local_' . $options{custom}->get_identifier() . '_' . $self->{mode});
|
||||
my $old_timestamp = $self->{statefile_cache}->get(name => 'last_timestamp');
|
||||
my $datas = {};
|
||||
$datas->{last_timestamp} = time();
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "CPUs usages are ok.");
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "CPUs usages are ok."
|
||||
);
|
||||
my @output_cpu_instance = split("instance", $stdout);
|
||||
shift @output_cpu_instance;
|
||||
foreach (@output_cpu_instance) {
|
||||
@ -109,7 +92,7 @@ sub run {
|
||||
if (!defined($old_cpu_system) || !defined($old_cpu_idle) || !defined($old_cpu_user)) {
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
if ($datas->{'cpu_idle_' . $cpu_number} < $old_cpu_idle) {
|
||||
# We set 0. Has reboot.
|
||||
$old_cpu_user = 0;
|
||||
@ -121,14 +104,18 @@ sub run {
|
||||
my $idle_elapsed = $datas->{'cpu_idle_' . $cpu_number} - $old_cpu_idle;
|
||||
my $cpu_ratio_usetime = 100 * $idle_elapsed / $total_elapsed;
|
||||
$cpu_ratio_usetime = 100 - $cpu_ratio_usetime;
|
||||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(value => $cpu_ratio_usetime,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
|
||||
my $exit_code = $self->{perfdata}->threshold_check(
|
||||
value => $cpu_ratio_usetime,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]
|
||||
);
|
||||
|
||||
$self->{output}->output_add(long_msg => sprintf("CPU %d %.2f%%", $cpu_number, $cpu_ratio_usetime));
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit_code, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("CPU %d %.2f%%", $cpu_number, $cpu_ratio_usetime));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf("CPU %d %.2f%%", $cpu_number, $cpu_ratio_usetime)
|
||||
);
|
||||
}
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'cpu_' . $cpu_number, unit => '%',
|
||||
@ -141,8 +128,10 @@ sub run {
|
||||
|
||||
$self->{statefile_cache}->write(data => $datas);
|
||||
if (!defined($old_timestamp)) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "Buffer creation...");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "Buffer creation..."
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
@ -155,7 +144,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check system CPUs (need 'kstat' command).
|
||||
Check system CPUs
|
||||
|
||||
Command used: 'kstat -n sys 2>&1'
|
||||
|
||||
=over 8
|
||||
|
||||
@ -167,47 +158,6 @@ Threshold warning in percent.
|
||||
|
||||
Threshold critical in percent.
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'kstat').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-n sys 2>&1').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,28 +24,17 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'luxadm' },
|
||||
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
|
||||
"command-options:s" => { name => 'command_options', default => '-e port 2>&1' },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -54,27 +43,28 @@ sub check_options {
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'luxadm',
|
||||
command_options => '-e port 2>&1',
|
||||
command_path => '/usr/sbin'
|
||||
);
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "Fc connections are ok.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "Fc connections are ok."
|
||||
);
|
||||
my $num_connected = 0;
|
||||
foreach (split /\n/, $stdout) {
|
||||
$self->{output}->output_add(long_msg => $_);
|
||||
@ -82,12 +72,16 @@ sub run {
|
||||
$num_connected++;
|
||||
}
|
||||
}
|
||||
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_connected,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(
|
||||
value => $num_connected,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]
|
||||
);
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit_code, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("Some cards are not connected (see additionnal info for more details)"));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf("Some cards are not connected (see additionnal info for more details)")
|
||||
);
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
@ -102,6 +96,8 @@ __END__
|
||||
|
||||
Check number of fiber channel connected (need sun/oracle driver and not Emulex/Qlogic).
|
||||
|
||||
Command used: '/usr/sbin/luxadm -e port 2>&1'
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
@ -112,47 +108,6 @@ Threshold warning.
|
||||
|
||||
Threshold critical.
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'luxadm').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: '/usr/sbin').
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-e port 2>&1').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,28 +24,17 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'fmadm' },
|
||||
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
|
||||
"command-options:s" => { name => 'command_options', default => 'faulty -r 2>&1' },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -54,40 +43,46 @@ sub check_options {
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'fmadm',
|
||||
command_options => 'faulty -r 2>&1',
|
||||
command_path => '/usr/sbin'
|
||||
);
|
||||
|
||||
my $num_errors = 0;
|
||||
foreach (split /\n/, $stdout) {
|
||||
$self->{output}->output_add(long_msg => $_);
|
||||
$num_errors++;
|
||||
}
|
||||
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(value => $num_errors,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(
|
||||
value => $num_errors,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]
|
||||
);
|
||||
if ($num_errors > 0) {
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("The Fault Manager reports some hardware problems (see additionnal info for more details)"));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf("The Fault Manager reports some hardware problems (see additionnal info for more details)")
|
||||
);
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "The Fault Manager does not report any hardware problem.");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "The Fault Manager does not report any hardware problem."
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
@ -98,7 +93,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Hardware Faults (need at least Solaris 10 and 'fmadm' command).
|
||||
Check Hardware Faults (need at least Solaris 10)
|
||||
|
||||
Command used: '/usr/sbin/fmadm faulty -r 2>&1'
|
||||
|
||||
=over 8
|
||||
|
||||
@ -110,47 +107,6 @@ Threshold warning.
|
||||
|
||||
Threshold critical.
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'fmadm').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: '/usr/sbin').
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: 'faulty -r 2>&1').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -24,28 +24,17 @@ use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo" => { name => 'sudo' },
|
||||
"command:s" => { name => 'command', default => 'raidctl' },
|
||||
"command-path:s" => { name => 'command_path', default => '/usr/sbin' },
|
||||
"command-options:s" => { name => 'command_options', default => '-S 2>&1' },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning:s' => { name => 'warning' },
|
||||
'critical:s' => { name => 'critical' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -54,24 +43,24 @@ sub check_options {
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
$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();
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo},
|
||||
command => $self->{option_results}->{command},
|
||||
command_path => $self->{option_results}->{command_path},
|
||||
command_options => $self->{option_results}->{command_options});
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'raidctl',
|
||||
command_options => '-S 2>&1',
|
||||
command_path => '/usr/sbin'
|
||||
);
|
||||
|
||||
my $long_msg = $stdout;
|
||||
$long_msg =~ s/\|/~/mg;
|
||||
$self->{output}->output_add(long_msg => $long_msg);
|
||||
@ -88,11 +77,11 @@ sub run {
|
||||
#0.2.0 GOOD
|
||||
#0.3.0 GOOD
|
||||
#4 "LSI_1030"
|
||||
|
||||
|
||||
# For Disk
|
||||
if (/^\s*(\S+)\s+(FAILED)$/i ) {
|
||||
my $disk = $1;
|
||||
|
||||
|
||||
$disks_errors++;
|
||||
$disks .= ' [' . $disk . '/FAILED' . ']';
|
||||
} elsif (/^\s*(\S+).*?(DEGRADED|FAILED)$/i) {
|
||||
@ -101,26 +90,38 @@ sub run {
|
||||
}
|
||||
}
|
||||
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(value => $volumes_errors,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
my ($exit_code) = $self->{perfdata}->threshold_check(
|
||||
value => $volumes_errors,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]
|
||||
);
|
||||
if ($volumes_errors > 0) {
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("Some volumes problems:" . $volumes));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf("Some volumes problems:" . $volumes)
|
||||
);
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No problems on volumes");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "No problems on volumes"
|
||||
);
|
||||
}
|
||||
|
||||
($exit_code) = $self->{perfdata}->threshold_check(value => $disks_errors,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
|
||||
($exit_code) = $self->{perfdata}->threshold_check(
|
||||
value => $disks_errors,
|
||||
threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]
|
||||
);
|
||||
if ($disks_errors > 0) {
|
||||
$self->{output}->output_add(severity => $exit_code,
|
||||
short_msg => sprintf("Some disks problems:" . $disks));
|
||||
$self->{output}->output_add(
|
||||
severity => $exit_code,
|
||||
short_msg => sprintf("Some disks problems:" . $disks)
|
||||
);
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No problems on disks");
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "No problems on disks"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
@ -131,7 +132,9 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Hardware Raid Status (use 'raidctl' command).
|
||||
Check hardware raid status
|
||||
|
||||
Command used: '/usr/sbin/raidctl -S 2>&1'
|
||||
|
||||
=over 8
|
||||
|
||||
@ -143,47 +146,6 @@ Threshold warning.
|
||||
|
||||
Threshold critical.
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'raidctl').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: '/usr/sbin').
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-S 2>&1').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -31,23 +31,8 @@ sub new {
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
"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 => 30 },
|
||||
"sudo1" => { name => 'sudo1' },
|
||||
"command1:s" => { name => 'command1', default => 'metastat' },
|
||||
"command1-path:s" => { name => 'command1_path', default => '/usr/sbin' },
|
||||
"command1-options:s" => { name => 'command1_options', default => '-c 2>&1' },
|
||||
"sudo2" => { name => 'sudo2' },
|
||||
"command2:s" => { name => 'command2', default => 'metadb' },
|
||||
"command2-path:s" => { name => 'command2_path', default => '/usr/sbin' },
|
||||
"command2-options:s" => { name => 'command2_options', default => '2>&1' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -59,14 +44,16 @@ sub check_options {
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo1},
|
||||
command => $self->{option_results}->{command1},
|
||||
command_path => $self->{option_results}->{command1_path},
|
||||
command_options => $self->{option_results}->{command1_options});
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "No problems on volumes");
|
||||
my ($stdout) = $options{custom}->execute_command(
|
||||
command => 'sas2ircu',
|
||||
command_options => 'LIST 2>&1',
|
||||
command_path => '/usr/bin'
|
||||
);
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => 'OK',
|
||||
short_msg => "No problems on volumes"
|
||||
);
|
||||
|
||||
while (($stdout =~ /^\s*Index.*?\n.*?\n\s+(\d+)\s+/imsg)) {
|
||||
# Index Type ID ID Pci Address Ven ID Dev ID
|
||||
@ -79,12 +66,12 @@ sub run {
|
||||
# 1 SAS2008 1000h 72h 00h:0bh:00h:00h 1000h 0072h
|
||||
#SAS2IRCU: Utility Completed Successfully.
|
||||
my $index = $1;
|
||||
my $stdout2 = centreon::plugins::misc::execute(output => $self->{output},
|
||||
options => $self->{option_results},
|
||||
sudo => $self->{option_results}->{sudo2},
|
||||
command => $self->{option_results}->{command2},
|
||||
command_path => $self->{option_results}->{command2_path},
|
||||
command_options => sprintf($self->{option_results}->{command2_options}, $index));
|
||||
|
||||
my ($stdout2) = $options{custom}->execute_command(
|
||||
command => 'sas2ircu',
|
||||
command_options => sprintf('%s DISPLAY 2>&1', $index),
|
||||
command_path => '/usr/bin'
|
||||
);
|
||||
|
||||
#IR Volume information
|
||||
#------------------------------------------------------------------------
|
||||
@ -99,33 +86,35 @@ sub run {
|
||||
# PHY[1] Enclosure#/Slot# : 1:3
|
||||
#------------------------------------------------------------------------
|
||||
#Physical device information
|
||||
|
||||
|
||||
if ($stdout2 =~ /^IR Volume information(.*)Physical device information/ims) {
|
||||
my @content = split(/\n/, $1);
|
||||
shift @content;
|
||||
my $volume_name = '';
|
||||
foreach my $line (@content) {
|
||||
|
||||
|
||||
next if ($line =~ /^---/);
|
||||
|
||||
|
||||
if ($line =~ /Volume Name\s+:\s+(.*)/i) {
|
||||
$volume_name = $1;
|
||||
$volume_name = centreon::plugins::misc::trim($volume_name);
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
if ($line =~ /Status of volume\s+:\s+(.*)(\n|\()/i) {
|
||||
my $status_volume = $1;
|
||||
$status_volume = centreon::plugins::misc::trim($status_volume);
|
||||
if ($status_volume !~ /Okay/i) {
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => "Volume 'volume_name' status is '$status_volume'");
|
||||
$self->{output}->output_add(
|
||||
severity => 'CRITICAL',
|
||||
short_msg => "Volume 'volume_name' status is '$status_volume'"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
@ -136,69 +125,12 @@ __END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Hardware Raid Status (use 'sas2ircu' command).
|
||||
Check hardware raid status (use 'sas2ircu' command).
|
||||
|
||||
Command used: '/usr/bin/sas2ircu LIST 2>&1' and '/usr/bin/sas2ircu %(index) DISPLAY 2>&1'
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--remote>
|
||||
|
||||
Execute command remotely in 'ssh'.
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Hostname to query (need --remote).
|
||||
|
||||
=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: 30).
|
||||
|
||||
=item B<--sudo1>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command1>
|
||||
|
||||
Command to get information (Default: 'sas2ircu').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command1-path>
|
||||
|
||||
Command path (Default: '/usr/bin').
|
||||
|
||||
=item B<--command1-options>
|
||||
|
||||
Command options (Default: 'LIST 2>&1').
|
||||
|
||||
=item B<--sudo2>
|
||||
|
||||
Use 'sudo' to execute the command.
|
||||
|
||||
=item B<--command2>
|
||||
|
||||
Command to get information (Default: 'sas2ircu').
|
||||
Can be changed if you have output in a file.
|
||||
|
||||
=item B<--command2-path>
|
||||
|
||||
Command path (Default: '/usr/bin').
|
||||
|
||||
=item B<--command2-options>
|
||||
|
||||
Command options (Default: '%s DISPLAY 2>&1').
|
||||
!!! Modify it if you know what you do ;) !!!
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user