add ps-display option for powershell modes

This commit is contained in:
garnier-quentin 2020-01-27 14:46:36 +01:00
parent 7315fe1dda
commit f8a51568c5
44 changed files with 1181 additions and 822 deletions

View File

@ -58,9 +58,8 @@ sub custom_status_threshold {
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status} . ' [type: ' . $self->{result_values}->{type} . ']';
return $msg;
return 'status : ' . $self->{result_values}->{status} . ' [type: ' . $self->{result_values}->{type} . ']';
}
sub custom_status_calc {
@ -75,9 +74,8 @@ sub custom_status_calc {
sub custom_long_output {
my ($self, %options) = @_;
my $msg = 'started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{elapsed});
return $msg;
return 'started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{elapsed});
}
sub custom_long_calc {
@ -138,23 +136,23 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-name:s" => { name => 'filter_name' },
"filter-type:s" => { name => 'filter_type' },
"filter-end-time:s" => { name => 'filter_end_time', default => 86400 },
"filter-start-time:s" => { name => 'filter_start_time' },
"ok-status:s" => { name => 'ok_status', default => '' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{is_running} == 0 and not %{status} =~ /Success/i' },
"warning-long:s" => { name => 'warning_long' },
"critical-long:s" => { name => 'critical_long' },
$options{options}->add_options(arguments => {
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-name:s' => { name => 'filter_name' },
'filter-type:s' => { name => 'filter_type' },
'filter-end-time:s' => { name => 'filter_end_time', default => 86400 },
'filter-start-time:s' => { name => 'filter_start_time' },
'ok-status:s' => { name => 'ok_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{is_running} == 0 and not %{status} =~ /Success/i' },
'warning-long:s' => { name => 'warning_long' },
'critical-long:s' => { name => 'critical_long' },
});
return $self;
@ -176,18 +174,32 @@ sub prefix_job_output {
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::veeam::jobstatus::get_powershell(
no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::veeam::jobstatus::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -203,9 +215,10 @@ sub manage_selection {
foreach my $line (split /\n/, $stdout) {
next if ($line !~ /^\[name\s*=(.*?)\]\[type\s*=(.*?)\]\[isrunning\s*=(.*?)\]\[result\s*=(.*?)\]\[creationTimeUTC\s*=(.*?)\]\[endTimeUTC\s*=(.*?)\]/i);
my ($name, $type, $is_running, $result, $start_time, $end_time) = (centreon::plugins::misc::trim($1),
centreon::plugins::misc::trim($2), centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4),
centreon::plugins::misc::trim($5), centreon::plugins::misc::trim($6));
my ($name, $type, $is_running, $result, $start_time, $end_time) = (
centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2), centreon::plugins::misc::trim($3),
centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5), centreon::plugins::misc::trim($6)
);
$start_time =~ s/,/\./;
$end_time =~ s/,/\./;
@ -274,6 +287,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -32,15 +32,15 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-name:s" => { name => 'filter_name' },
$options{options}->add_options(arguments => {
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-name:s' => { name => 'filter_name' },
});
return $self;
@ -59,8 +59,10 @@ sub run {
$self->{output}->output_add(long_msg => "'" . $_ . "' [type = " . $self->{jobs}->{$_}->{type} . "]");
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List jobs:');
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List jobs:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -86,18 +88,32 @@ sub disco_show {
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::veeam::listjobs::get_powershell(
no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::veeam::listjobs::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -149,6 +165,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -56,25 +56,42 @@ sub check_options {
sub run {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::listdatabases::get_powershell(
remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password},
no_ps => $self->{option_results}->{no_ps},
filter_database => $self->{option_results}->{ps_database_filter}
);
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output},
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output},
timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => 'List databases:');
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List databases:'
);
centreon::common::powershell::exchange::2010::listdatabases::list($self, stdout => $stdout);
}
@ -91,17 +108,22 @@ sub disco_format {
sub disco_show {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::exchange::2010::listdatabases::get_powershell(remote_host => $self->{option_results}->{remote_host},
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::listdatabases::get_powershell(
remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password},
no_ps => $self->{option_results}->{no_ps},
filter_database => $self->{option_results}->{ps_database_filter});
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output},
filter_database => $self->{option_results}->{ps_database_filter}
);
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output},
timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
centreon::common::powershell::exchange::2010::listdatabases::disco_show($self, stdout => $stdout);
}

View File

@ -32,15 +32,16 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps', },
"ps-exec-only" => { name => 'ps_exec_only', },
$options{options}->add_options(arguments => {
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
});
return $self;
}
@ -52,20 +53,37 @@ sub check_options {
sub run {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::listnodevms::get_powershell(no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::listnodevms::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => 'List Virtual Machines:');
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List Virtual Machines:'
);
centreon::common::powershell::hyperv::2012::listnodevms::list($self, stdout => $stdout);
}
@ -82,13 +100,18 @@ sub disco_format {
sub disco_show {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::listnodevms::get_powershell(no_ps => $self->{option_results}->{no_ps});
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::listnodevms::get_powershell();
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
centreon::common::powershell::hyperv::2012::listnodevms::disco_show($self, stdout => $stdout);
}
@ -123,6 +146,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -123,22 +123,23 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-note:s" => { name => 'filter_note' },
"filter-status:s" => { name => 'filter_status', default => 'running' },
"warning-global-status:s" => { name => 'warning_global_status', default => '%{integration_service_state} =~ /Update required/i' },
"critical-global-status:s" => { name => 'critical_global_status', default => '' },
"warning-service-status:s" => { name => 'warning_service_status', default => '' },
"critical-service-status:s" => { name => 'critical_service_status', default => '%{primary_status} !~ /Ok/i' },
$options{options}->add_options(arguments => {
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-vm:s' => { name => 'filter_vm' },
'filter-note:s' => { name => 'filter_note' },
'filter-status:s' => { name => 'filter_status', default => 'running' },
'warning-global-status:s' => { name => 'warning_global_status', default => '%{integration_service_state} =~ /Update required/i' },
'critical-global-status:s' => { name => 'critical_global_status', default => '' },
'warning-service-status:s' => { name => 'warning_service_status', default => '' },
'critical-service-status:s' => { name => 'critical_service_status', default => '%{primary_status} !~ /Ok/i' },
});
return $self;
}
@ -152,17 +153,32 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::nodeintegrationservice::get_powershell(no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::nodeintegrationservice::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -246,6 +262,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -73,18 +73,19 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"warning-status:s" => { name => 'warning_status', default => '%{health} =~ /Warning/i' },
"critical-status:s" => { name => 'critical_status', default => '%{health} =~ /Critical/i' },
$options{options}->add_options(arguments => {
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-vm:s' => { name => 'filter_vm' },
'warning-status:s' => { name => 'warning_status', default => '%{health} =~ /Warning/i' },
'critical-status:s' => { name => 'critical_status', default => '%{health} =~ /Critical/i' },
});
return $self;
}
@ -98,17 +99,32 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::nodereplication::get_powershell(no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::nodereplication::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -164,6 +180,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -51,16 +51,14 @@ sub set_counters {
sub custom_snapshot_output {
my ($self, %options) = @_;
my $msg = "[status = " . $self->{result_values}->{status_absolute} . "] checkpoint started '" . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{snapshot_absolute}) . "' ago";
return $msg;
return "[status = " . $self->{result_values}->{status_absolute} . "] checkpoint started '" . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{snapshot_absolute}) . "' ago";
}
sub custom_backing_output {
my ($self, %options) = @_;
my $msg = "[status = " . $self->{result_values}->{status_absolute} . "] backing started '" . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{backing_absolute}) . "' ago";
return $msg;
return "[status = " . $self->{result_values}->{status_absolute} . "] backing started '" . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{backing_absolute}) . "' ago";
}
sub prefix_vm_output {
@ -74,35 +72,51 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-note:s" => { name => 'filter_note' },
"filter-status:s" => { name => 'filter_status', default => 'running' },
$options{options}->add_options(arguments => {
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-vm:s' => { name => 'filter_vm' },
'filter-note:s' => { name => 'filter_note' },
'filter-status:s' => { name => 'filter_status', default => 'running' },
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::nodesnapshot::get_powershell(no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::nodesnapshot::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -180,6 +194,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -74,19 +74,20 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"timeout:s" => { name => 'timeout', default => 50 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-note:s" => { name => 'filter_note' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Operating normally/i' },
$options{options}->add_options(arguments => {
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-vm:s' => { name => 'filter_vm' },
'filter-note:s' => { name => 'filter_note' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /Operating normally/i' },
});
return $self;
}
@ -100,17 +101,32 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::nodevmstatus::get_powershell(no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::nodevmstatus::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -176,6 +192,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -142,35 +142,36 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"scvmm-hostname:s" => { name => 'scvmm_hostname' },
"scvmm-username:s" => { name => 'scvmm_username' },
"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-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-description:s" => { name => 'filter_description' },
"filter-hostgroup:s" => { name => 'filter_hostgroup' },
"filter-status:s" => { name => 'filter_status' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{vmaddition} =~ /not detected/i' },
"warning-osshutdown-status:s" => { name => 'warning_osshutdown_status', default => '' },
"critical-osshutdown-status:s" => { name => 'critical_osshutdown_status', default => '' },
"warning-timesync-status:s" => { name => 'warning_timesync_status', default => '' },
"critical-timesync-status:s" => { name => 'critical_timesync_status', default => '' },
"warning-dataexchange-status:s" => { name => 'warning_dataexchange_status', default => '' },
"critical-dataexchange-status:s" => { name => 'critical_dataexchange_status', default => '' },
"warning-heartbeat-status:s" => { name => 'warning_heartbeat_status', default => '' },
"critical-heartbeat-status:s" => { name => 'critical_heartbeat_status', default => '' },
"warning-backup-status:s" => { name => 'warning_backup_status', default => '' },
"critical-backup-status:s" => { name => 'critical_backup_status', default => '' },
$options{options}->add_options(arguments => {
'scvmm-hostname:s' => { name => 'scvmm_hostname' },
'scvmm-username:s' => { name => 'scvmm_username' },
'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-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-vm:s' => { name => 'filter_vm' },
'filter-description:s' => { name => 'filter_description' },
'filter-hostgroup:s' => { name => 'filter_hostgroup' },
'filter-status:s' => { name => 'filter_status' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{vmaddition} =~ /not detected/i' },
'warning-osshutdown-status:s' => { name => 'warning_osshutdown_status', default => '' },
'critical-osshutdown-status:s' => { name => 'critical_osshutdown_status', default => '' },
'warning-timesync-status:s' => { name => 'warning_timesync_status', default => '' },
'critical-timesync-status:s' => { name => 'critical_timesync_status', default => '' },
'warning-dataexchange-status:s' => { name => 'warning_dataexchange_status', default => '' },
'critical-dataexchange-status:s' => { name => 'critical_dataexchange_status', default => '' },
'warning-heartbeat-status:s' => { name => 'warning_heartbeat_status', default => '' },
'critical-heartbeat-status:s' => { name => 'critical_heartbeat_status', default => '' },
'warning-backup-status:s' => { name => 'warning_backup_status', default => '' },
'critical-backup-status:s' => { name => 'critical_backup_status', default => '' },
});
return $self;
}
@ -187,30 +188,47 @@ sub check_options {
}
}
$self->change_macros(macros => ['warning_status', 'critical_status', 'warning_osshutdown_status', 'critical_osshutdown_status',
$self->change_macros(macros => [
'warning_status', 'critical_status', 'warning_osshutdown_status', 'critical_osshutdown_status',
'warning_timesync_status', 'critical_timesync_status', 'warning_dataexchange_status', 'critical_dataexchange_status',
'warning_heartbeat_status', 'critical_heartbeat_status', 'warning_backup_status', 'critical_backup_status']);
'warning_heartbeat_status', 'critical_heartbeat_status', 'warning_backup_status', 'critical_backup_status'
]);
}
sub manage_selection {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::scvmmintegrationservice::get_powershell(
scvmm_hostname => $self->{option_results}->{scvmm_hostname},
scvmm_username => $self->{option_results}->{scvmm_username},
scvmm_password => $self->{option_results}->{scvmm_password},
scvmm_port => $self->{option_results}->{scvmm_port},
no_ps => $self->{option_results}->{no_ps});
scvmm_port => $self->{option_results}->{scvmm_port}
);
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -292,6 +310,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -45,9 +45,8 @@ sub set_counters {
sub custom_vm_output {
my ($self, %options) = @_;
my $msg = 'checkpoint started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{snapshot_absolute});
return $msg;
return 'checkpoint started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{snapshot_absolute});
}
sub prefix_vm_output {
@ -61,23 +60,24 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"scvmm-hostname:s" => { name => 'scvmm_hostname' },
"scvmm-username:s" => { name => 'scvmm_username' },
"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-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-description:s"=> { name => 'filter_description' },
"filter-hostgroup:s" => { name => 'filter_hostgroup' },
"filter-status:s" => { name => 'filter_status', default => 'running' },
$options{options}->add_options(arguments => {
'scvmm-hostname:s' => { name => 'scvmm_hostname' },
'scvmm-username:s' => { name => 'scvmm_username' },
'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-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-vm:s' => { name => 'filter_vm' },
'filter-description:s' => { name => 'filter_description' },
'filter-hostgroup:s' => { name => 'filter_hostgroup' },
'filter-status:s' => { name => 'filter_status', default => 'running' },
});
return $self;
}
@ -98,21 +98,37 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::hyperv::2012::scvmmsnapshot::get_powershell(scvmm_hostname => $self->{option_results}->{scvmm_hostname},
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::scvmmsnapshot::get_powershell(
scvmm_hostname => $self->{option_results}->{scvmm_hostname},
scvmm_username => $self->{option_results}->{scvmm_username},
scvmm_password => $self->{option_results}->{scvmm_password},
scvmm_port => $self->{option_results}->{scvmm_port},
no_ps => $self->{option_results}->{no_ps});
);
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -196,6 +212,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -31,8 +31,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status};
return $msg;
return 'status : ' . $self->{result_values}->{status};
}
sub custom_status_calc {
@ -73,24 +72,25 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"scvmm-hostname:s" => { name => 'scvmm_hostname' },
"scvmm-username:s" => { name => 'scvmm_username' },
"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-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"filter-vm:s" => { name => 'filter_vm' },
"filter-description:s"=> { name => 'filter_description' },
"filter-hostgroup:s" => { name => 'filter_hostgroup' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /Running|Stopped/i' },
$options{options}->add_options(arguments => {
'scvmm-hostname:s' => { name => 'scvmm_hostname' },
'scvmm-username:s' => { name => 'scvmm_username' },
'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-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-vm:s' => { name => 'filter_vm' },
'filter-description:s' => { name => 'filter_description' },
'filter-hostgroup:s' => { name => 'filter_hostgroup' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /Running|Stopped/i' },
});
return $self;
}
@ -112,22 +112,37 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::hyperv::2012::scvmmvmstatus::get_powershell(
scvmm_hostname => $self->{option_results}->{scvmm_hostname},
scvmm_username => $self->{option_results}->{scvmm_username},
scvmm_password => $self->{option_results}->{scvmm_password},
scvmm_port => $self->{option_results}->{scvmm_port},
no_ps => $self->{option_results}->{no_ps});
scvmm_port => $self->{option_results}->{scvmm_port}
);
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -209,6 +224,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -27,6 +27,7 @@ use warnings;
use JSON::XS;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::common::powershell::sccm::databasereplicationstatus;
use centreon::plugins::misc;
use DateTime;
my %map_link_status = (
@ -64,8 +65,7 @@ my %map_type = (
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf("Overall Link status is '%s'", $self->{result_values}->{status});
return $msg;
return sprintf("Overall Link status is '%s'", $self->{result_values}->{status});
}
sub custom_status_calc {
@ -78,12 +78,12 @@ sub custom_status_calc {
sub custom_site_status_output {
my ($self, %options) = @_;
my $msg = sprintf("status is '%s', Site-to-Site state is '%s' [Type: %s] [Last sync: %s]",
return sprintf("status is '%s', Site-to-Site state is '%s' [Type: %s] [Last sync: %s]",
$self->{result_values}->{status},
$self->{result_values}->{site_to_site_state},
$self->{result_values}->{type},
centreon::plugins::misc::change_seconds(value => $self->{result_values}->{last_sync_time}));
return $msg;
centreon::plugins::misc::change_seconds(value => $self->{result_values}->{last_sync_time})
);
}
sub custom_site_status_calc {
@ -151,6 +151,7 @@ sub new {
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'warning-link-status:s' => { name => 'warning_link_status', default => '' },
'critical-link-status:s' => { name => 'critical_link_status', default => '' },
'warning-site-status:s' => { name => 'warning_site_status', default => '' },
@ -165,18 +166,29 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_link_status', 'critical_link_status',
'warning_site_status', 'critical_site_status']);
$self->change_macros(macros => [
'warning_link_status', 'critical_link_status',
'warning_site_status', 'critical_site_status'
]);
}
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::sccm::databasereplicationstatus::get_powershell(
no_ps => $self->{option_results}->{no_ps},
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::sccm::databasereplicationstatus::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
@ -185,8 +197,10 @@ sub manage_selection {
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -253,6 +267,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -26,6 +26,7 @@ use strict;
use warnings;
use JSON::XS;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::misc;
use centreon::common::powershell::sccm::sitestatus;
my %map_mode = (
@ -60,11 +61,11 @@ my %map_type = (
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf("status is '%s' [Type: %s] [Mode: '%s']",
return sprintf("status is '%s' [Type: %s] [Mode: '%s']",
$self->{result_values}->{status},
$self->{result_values}->{type},
$self->{result_values}->{mode});
return $msg;
$self->{result_values}->{mode}
);
}
sub custom_status_calc {
@ -117,6 +118,7 @@ sub new {
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '' },
});
@ -134,11 +136,20 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::sccm::sitestatus::get_powershell(
no_ps => $self->{option_results}->{no_ps},
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::sccm::sitestatus::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
@ -147,8 +158,10 @@ sub manage_selection {
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -221,6 +234,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use JSON::XS;
use centreon::plugins::misc;
use centreon::common::powershell::wsus::computersstatus;
sub set_counters {
@ -95,17 +96,17 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"timeout:s" => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"wsus-server:s" => { name => 'wsus_server', default => 'localhost' },
"wsus-port:s" => { name => 'wsus_port', default => 8530 },
"not-updated-since:s" => { name => 'not_updated_since', default => 10 },
"use-ssl" => { name => 'use_ssl' },
"filter-counters:s" => { name => 'filter_counters' },
'timeout:s' => { name => 'timeout', default => 30 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'wsus-server:s' => { name => 'wsus_server', default => 'localhost' },
'wsus-port:s' => { name => 'wsus_port', default => 8530 },
'not-updated-since:s' => { name => 'not_updated_since', default => 10 },
'use-ssl' => { name => 'use_ssl' },
});
return $self;
@ -122,23 +123,38 @@ sub manage_selection {
my $use_ssl = "\$false";
$use_ssl = "\$true" if (defined($self->{option_results}->{use_ssl}));
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::wsus::computersstatus::get_powershell(
no_ps => $self->{option_results}->{no_ps},
wsus_server => $self->{option_results}->{wsus_server},
wsus_port => $self->{option_results}->{wsus_port},
not_updated_since => $self->{option_results}->{not_updated_since},
use_ssl => $use_ssl
);
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -186,6 +202,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use JSON::XS;
use centreon::plugins::misc;
use centreon::common::powershell::wsus::serverstatistics;
sub set_counters {
@ -116,16 +117,16 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"timeout:s" => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"wsus-server:s" => { name => 'wsus_server', default => 'localhost' },
"wsus-port:s" => { name => 'wsus_port', default => 8530 },
"use-ssl" => { name => 'use_ssl' },
"filter-counters:s" => { name => 'filter_counters' },
'timeout:s' => { name => 'timeout', default => 30 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'wsus-server:s' => { name => 'wsus_server', default => 'localhost' },
'wsus-port:s' => { name => 'wsus_port', default => 8530 },
'use-ssl' => { name => 'use_ssl' },
});
return $self;
@ -142,22 +143,36 @@ sub manage_selection {
my $use_ssl = "\$false";
$use_ssl = "\$true" if (defined($self->{option_results}->{use_ssl}));
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::wsus::serverstatistics::get_powershell(
no_ps => $self->{option_results}->{no_ps},
wsus_server => $self->{option_results}->{wsus_server},
wsus_port => $self->{option_results}->{wsus_port},
use_ssl => $use_ssl
);
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -205,6 +220,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -26,6 +26,7 @@ use strict;
use warnings;
use JSON::XS;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::misc;
use centreon::common::powershell::wsus::synchronisationstatus;
use DateTime;
@ -60,11 +61,13 @@ sub custom_last_status_calc {
sub custom_progress_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(label => 'synchronisation_progress',
$self->{output}->perfdata_add(
label => 'synchronisation_progress',
value => $self->{result_values}->{progress},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}),
min => 0, max => 100);
min => 0, max => 100
);
}
sub custom_progress_threshold {
@ -79,11 +82,11 @@ sub custom_progress_threshold {
sub custom_progress_output {
my ($self, %options) = @_;
my $msg = sprintf("Progress: %.2f%% (%d/%d items)",
return sprintf("Progress: %.2f%% (%d/%d items)",
$self->{result_values}->{progress},
$self->{result_values}->{processed},
$self->{result_values}->{total});
return $msg;
$self->{result_values}->{total}
);
}
sub custom_progress_calc {
@ -102,11 +105,13 @@ sub custom_progress_calc {
sub custom_duration_perfdata {
my ($self, %options) = @_;
$self->{output}->perfdata_add(label => 'last_synchronisation_duration',
$self->{output}->perfdata_add(
label => 'last_synchronisation_duration',
value => $self->{result_values}->{duration},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}),
min => 0, unit => 's');
min => 0, unit => 's'
);
}
sub custom_duration_threshold {
@ -121,8 +126,7 @@ sub custom_duration_threshold {
sub custom_duration_output {
my ($self, %options) = @_;
my $msg = sprintf("Duration: %s", centreon::plugins::misc::change_seconds(value => $self->{result_values}->{duration}));
return $msg;
return sprintf('Duration: %s', centreon::plugins::misc::change_seconds(value => $self->{result_values}->{duration}));
}
sub custom_duration_calc {
@ -206,20 +210,21 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"timeout:s" => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"wsus-server:s" => { name => 'wsus_server', default => 'localhost' },
"wsus-port:s" => { name => 'wsus_port', default => 8530 },
"use-ssl" => { name => 'use_ssl' },
"warning-synchronisation-status:s" => { name => 'warning_synchronisation_status', default => '' },
"critical-synchronisation-status:s" => { name => 'critical_synchronisation_status', default => '' },
"warning-last-synchronisation-status:s" => { name => 'warning_last_synchronisation_status', default => '' },
"critical-last-synchronisation-status:s" => { name => 'critical_last_synchronisation_status', default => '%{status} !~ /Succeeded/' },
"timezone:s" => { name => 'timezone', default => 'UTC' },
'timeout:s' => { name => 'timeout', default => 30 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'wsus-server:s' => { name => 'wsus_server', default => 'localhost' },
'wsus-port:s' => { name => 'wsus_port', default => 8530 },
'use-ssl' => { name => 'use_ssl' },
'timezone:s' => { name => 'timezone', default => 'UTC' },
'warning-synchronisation-status:s' => { name => 'warning_synchronisation_status', default => '' },
'critical-synchronisation-status:s' => { name => 'critical_synchronisation_status', default => '' },
'warning-last-synchronisation-status:s' => { name => 'warning_last_synchronisation_status', default => '' },
'critical-last-synchronisation-status:s' => { name => 'critical_last_synchronisation_status', default => '%{status} !~ /Succeeded/' },
});
return $self;
@ -229,8 +234,10 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_synchronisation_status', 'critical_synchronisation_status',
'warning_last_synchronisation_status', 'critical_last_synchronisation_status']);
$self->change_macros(macros => [
'warning_synchronisation_status', 'critical_synchronisation_status',
'warning_last_synchronisation_status', 'critical_last_synchronisation_status']
);
}
sub manage_selection {
@ -239,22 +246,36 @@ sub manage_selection {
my $use_ssl = "\$false";
$use_ssl = "\$true" if (defined($self->{option_results}->{use_ssl}));
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::wsus::synchronisationstatus::get_powershell(
no_ps => $self->{option_results}->{no_ps},
wsus_server => $self->{option_results}->{wsus_server},
wsus_port => $self->{option_results}->{wsus_port},
use_ssl => $use_ssl
);
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -311,6 +332,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use JSON::XS;
use centreon::plugins::misc;
use centreon::common::powershell::wsus::updatesstatus;
sub set_counters {
@ -95,16 +96,16 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"timeout:s" => { name => 'timeout', default => 30 },
"command:s" => { name => 'command', default => 'powershell.exe' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"no-ps" => { name => 'no_ps' },
"ps-exec-only" => { name => 'ps_exec_only' },
"wsus-server:s" => { name => 'wsus_server', default => 'localhost' },
"wsus-port:s" => { name => 'wsus_port', default => 8530 },
"use-ssl" => { name => 'use_ssl' },
"filter-counters:s" => { name => 'filter_counters' },
'timeout:s' => { name => 'timeout', default => 30 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'wsus-server:s' => { name => 'wsus_server', default => 'localhost' },
'wsus-port:s' => { name => 'wsus_port', default => 8530 },
'use-ssl' => { name => 'use_ssl' },
});
return $self;
@ -121,22 +122,36 @@ sub manage_selection {
my $use_ssl = "\$false";
$use_ssl = "\$true" if (defined($self->{option_results}->{use_ssl}));
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::wsus::updatesstatus::get_powershell(
no_ps => $self->{option_results}->{no_ps},
wsus_server => $self->{option_results}->{wsus_server},
wsus_port => $self->{option_results}->{wsus_port},
use_ssl => $use_ssl
);
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -184,6 +199,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::dell::compellent::hbausage;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -94,7 +90,7 @@ $ret = Remove-DellSavedApiConnection -Name $connName
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::dell::compellent::volumeusage;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -107,7 +103,7 @@ $ret = Remove-DellSavedApiConnection -Name $connName
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -26,9 +26,6 @@ use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -52,7 +49,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
@ -65,8 +62,10 @@ sub list {
foreach my $line (split /\n/, $options{stdout}) {
next if ($line !~ /^\[name=(.*?)\]\[state=(.*?)\]\[status=(.*?)\]\[IsClustered=(.*?)\]\[note=(.*?)\]/);
my ($name, $state, $status, $IsClustered, $note) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
my ($name, $state, $status, $IsClustered, $note) = (
centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5)
);
$self->{output}->output_add(long_msg => "'" . $name . "' [state = $state, status = " . $status . ']');
}
@ -81,12 +80,18 @@ sub disco_show {
foreach my $line (split /\n/, $options{stdout}) {
next if ($line !~ /^\[name=(.*?)\]\[state=(.*?)\]\[status=(.*?)\]\[IsClustered=(.*?)\]\[note=(.*?)\]/);
my ($name, $state, $status, $IsClustered, $note) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
my ($name, $state, $status, $IsClustered, $note) = (
centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5)
);
$self->{output}->add_disco_entry(name => $name,
$self->{output}->add_disco_entry(
name => $name,
state => $state,
status => $status, is_clustered => $IsClustered, note => $note);
status => $status,
is_clustered => $IsClustered,
note => $note
);
}
}

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::hyperv::2012::nodeintegrationservice;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -55,7 +51,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::hyperv::2012::nodereplication;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -50,7 +46,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::hyperv::2012::nodesnapshot;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -78,7 +74,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::hyperv::2012::nodevmstatus;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -63,7 +59,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::hyperv::2012::scvmmintegrationservice;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -69,7 +65,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::hyperv::2012::scvmmsnapshot;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -67,7 +63,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::hyperv::2012::scvmmvmstatus;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -59,7 +55,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -26,9 +26,6 @@ use centreon::common::powershell::functions;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -83,7 +80,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -26,9 +26,6 @@ use centreon::common::powershell::functions;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -78,7 +75,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::veeam::jobstatus;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -75,7 +71,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::veeam::listjobs;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -66,7 +62,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -26,9 +26,6 @@ use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -50,8 +47,9 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;
sub list {
@ -62,11 +60,12 @@ sub list {
#...
foreach my $line (split /\n/, $options{stdout}) {
next if ($line !~ /^\[name=(.*?)\]\[type=(.*?)\]\[providername=.*?\]\[desc=(.*?)\]\[size=(.*?)\]\[freespace=(.*?)\]/);
my ($disk, $type, $desc, $size, $free) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
my ($disk, $type, $desc, $size, $free) = (
centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5)
);
$self->{output}->output_add(long_msg => "'" . $disk . "' [size = $size, free = $free, desc = $desc, type = $map_type{$type}]");
}
}
1;
@ -81,14 +80,18 @@ sub disco_show {
#...
foreach my $line (split /\n/, $options{stdout}) {
next if ($line !~ /^\[name=(.*?)\]\[type=(.*?)\]\[providername=.*?\]\[desc=(.*?)\]\[size=(.*?)\]\[freespace=(.*?)\]/);
my ($disk, $type, $desc, $size, $free) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
my ($disk, $type, $desc, $size, $free) = (
centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5)
);
$self->{output}->add_disco_entry(name => $disk,
$self->{output}->add_disco_entry(
name => $disk,
size => $size,
free => $free,
type => $map_type{$type},
desc => $desc);
desc => $desc
);
}
}

View File

@ -22,13 +22,9 @@ package centreon::common::powershell::windows::pendingreboot;
use strict;
use warnings;
use centreon::plugins::misc;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -126,7 +122,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -26,9 +26,6 @@ use centreon::common::powershell::functions;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -83,7 +80,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -26,9 +26,6 @@ use centreon::common::powershell::functions;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -79,7 +76,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -26,9 +26,6 @@ use centreon::common::powershell::functions;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -79,7 +76,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -26,9 +26,6 @@ use centreon::common::powershell::functions;
sub get_powershell {
my (%options) = @_;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = '
$culture = new-object "System.Globalization.CultureInfo" "en-us"
@ -76,7 +73,7 @@ Try {
exit 0
';
return centreon::plugins::misc::powershell_encoded($ps);
return $ps;
}
1;

View File

@ -38,7 +38,8 @@ sub new {
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'ps-exec-only' => { name => 'ps_exec_only', }
'ps-exec-only' => { name => 'ps_exec_only', },
'ps-display' => { name => 'ps_display' }
});
return $self;
@ -52,9 +53,19 @@ sub check_options {
sub run {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::windows::liststorages::get_powershell(no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::windows::liststorages::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . $ps;
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output},
@ -64,11 +75,15 @@ sub run {
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
} else {
$self->{output}->output_add(severity => 'OK',
short_msg => 'List disk:');
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List disk:'
);
centreon::common::powershell::windows::liststorages::list($self, stdout => $stdout);
}
@ -85,9 +100,11 @@ sub disco_format {
sub disco_show {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::windows::liststorages::get_powershell(no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::windows::liststorages::get_powershell();
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output},
timeout => $self->{option_results}->{timeout},
@ -129,6 +146,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -31,7 +31,7 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold)
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf(
return sprintf(
'Reboot Pending: %s [Windows Update: %s][Component Based Servicing: %s][SCCM Client: %s][File Rename Operations: %s][Computer Name Change: %s]',
$self->{result_values}->{RebootPending},
$self->{result_values}->{WindowsUpdate},
@ -40,7 +40,6 @@ sub custom_status_output {
$self->{result_values}->{PendFileRename},
$self->{result_values}->{PendComputerRename}
);
return $msg;
}
sub custom_status_calc {
@ -86,8 +85,9 @@ sub new {
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'warning-status:s' => { name => 'warning_status', default => '%{RebootPending} =~ /true/i' },
'critical-status:s' => { name => 'critical_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '' }
});
return $self;
@ -103,10 +103,20 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
my $ps = centreon::common::powershell::windows::pendingreboot::get_powershell(
no_ps => $self->{option_results}->{no_ps});
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::windows::pendingreboot::get_powershell();
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
@ -115,8 +125,10 @@ sub manage_selection {
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -159,6 +171,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -118,6 +118,7 @@ sub new {
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'ps-sc-filter:s' => { name => 'ps_sc_filter' },
'start-time:s' => { name => 'start_time' },
'end-time:s' => { name => 'end_time' },
@ -189,18 +190,28 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::dell::compellent::hbausage::get_powershell(
cem_host => $self->{option_results}->{cem_host},
cem_user => $self->{option_results}->{cem_user},
cem_password => $self->{option_results}->{cem_password},
cem_port => $self->{option_results}->{cem_port},
sdk_path_dll => $self->{option_results}->{sdk_path_dll},
no_ps => $self->{option_results}->{no_ps},
filter_sc => $self->{option_results}->{ps_sc_filter},
end_time => $self->{end_time}, start_time => $self->{start_time}
);
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output},
timeout => $self->{option_results}->{timeout},
@ -209,8 +220,10 @@ sub manage_selection {
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -282,6 +295,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.

View File

@ -34,6 +34,7 @@ sub set_counters {
{ name => 'sc', type => 1, cb_prefix_output => 'prefix_sc_output', message_multiple => 'All storage centers are ok', cb_init => 'sc_init' },
{ name => 'volume', type => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'All volumes are ok' }
];
$self->{maps_counters}->{sc} = [
{ label => 'sc-total', set => {
key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' }, { name => 'type' } ],
@ -144,10 +145,12 @@ sub custom_usage_output {
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
my $msg = sprintf(
"Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
);
return $msg;
}
@ -188,6 +191,7 @@ sub new {
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'ps-sc-filter:s' => { name => 'ps_sc_filter' },
'ps-sc-volume:s' => { name => 'ps_sc_volume' },
'units:s' => { name => 'units', default => '%' },
@ -214,18 +218,28 @@ sub check_options {
sub manage_selection {
my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::dell::compellent::volumeusage::get_powershell(
cem_host => $self->{option_results}->{cem_host},
cem_user => $self->{option_results}->{cem_user},
cem_password => $self->{option_results}->{cem_password},
cem_port => $self->{option_results}->{cem_port},
sdk_path_dll => $self->{option_results}->{sdk_path_dll},
no_ps => $self->{option_results}->{no_ps},
filter_sc => $self->{option_results}->{ps_sc_filter},
filter_vol => $self->{option_results}->{ps_sc_volume}
);
if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
$self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output},
timeout => $self->{option_results}->{timeout},
@ -234,8 +248,10 @@ sub manage_selection {
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->output_add(
severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -316,6 +332,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only>
Print powershell output.