add ps-display option for powershell modes

This commit is contained in:
garnier-quentin 2020-01-27 14:46:36 +01:00
parent 036ef13b11
commit 3a64ae0e7c
44 changed files with 1181 additions and 822 deletions

View File

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

View File

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

View File

@ -56,25 +56,42 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
my $ps = centreon::common::powershell::exchange::2010::listdatabases::get_powershell( if (!defined($self->{option_results}->{no_ps})) {
remote_host => $self->{option_results}->{remote_host}, my $ps = centreon::common::powershell::exchange::2010::listdatabases::get_powershell(
remote_user => $self->{option_results}->{remote_user}, remote_host => $self->{option_results}->{remote_host},
remote_password => $self->{option_results}->{remote_password}, remote_user => $self->{option_results}->{remote_user},
no_ps => $self->{option_results}->{no_ps}, remote_password => $self->{option_results}->{remote_password},
filter_database => $self->{option_results}->{ps_database_filter} filter_database => $self->{option_results}->{ps_database_filter}
);
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}
); );
$self->{option_results}->{command_options} .= " " . $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});
if (defined($self->{option_results}->{ps_exec_only})) { if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => $stdout); severity => 'OK',
short_msg => $stdout
);
} else { } else {
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => 'List databases:'); severity => 'OK',
short_msg => 'List databases:'
);
centreon::common::powershell::exchange::2010::listdatabases::list($self, stdout => $stdout); centreon::common::powershell::exchange::2010::listdatabases::list($self, stdout => $stdout);
} }
@ -91,17 +108,22 @@ sub disco_format {
sub disco_show { sub disco_show {
my ($self, %options) = @_; 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})) {
remote_user => $self->{option_results}->{remote_user}, my $ps = centreon::common::powershell::exchange::2010::listdatabases::get_powershell(
remote_password => $self->{option_results}->{remote_password}, remote_host => $self->{option_results}->{remote_host},
no_ps => $self->{option_results}->{no_ps}, remote_user => $self->{option_results}->{remote_user},
filter_database => $self->{option_results}->{ps_database_filter}); remote_password => $self->{option_results}->{remote_password},
$self->{option_results}->{command_options} .= " " . $ps; filter_database => $self->{option_results}->{ps_database_filter}
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, );
timeout => $self->{option_results}->{timeout}, $self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
command => $self->{option_results}->{command}, }
command_path => $self->{option_results}->{command_path}, my ($stdout) = centreon::plugins::misc::windows_execute(
command_options => $self->{option_results}->{command_options}); 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}
);
centreon::common::powershell::exchange::2010::listdatabases::disco_show($self, stdout => $stdout); 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); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ 'timeout:s' => { name => 'timeout', default => 50 },
"timeout:s" => { name => 'timeout', default => 50 }, 'command:s' => { name => 'command', default => 'powershell.exe' },
"command:s" => { name => 'command', default => 'powershell.exe' }, 'command-path:s' => { name => 'command_path' },
"command-path:s" => { name => 'command_path' }, 'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, 'no-ps' => { name => 'no_ps' },
"no-ps" => { name => 'no_ps', }, 'ps-exec-only' => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-display' => { name => 'ps_display' },
}); });
return $self; return $self;
} }
@ -52,20 +53,37 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; 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; $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}, my ($stdout) = centreon::plugins::misc::execute(
command_path => $self->{option_results}->{command_path}, output => $self->{output},
command_options => $self->{option_results}->{command_options}); options => $self->{option_results},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => $stdout); severity => 'OK',
short_msg => $stdout
);
} else { } else {
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => 'List Virtual Machines:'); severity => 'OK',
short_msg => 'List Virtual Machines:'
);
centreon::common::powershell::hyperv::2012::listnodevms::list($self, stdout => $stdout); centreon::common::powershell::hyperv::2012::listnodevms::list($self, stdout => $stdout);
} }
@ -82,13 +100,18 @@ sub disco_format {
sub disco_show { sub disco_show {
my ($self, %options) = @_; 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})) {
$self->{option_results}->{command_options} .= " " . $ps; my $ps = centreon::common::powershell::hyperv::2012::listnodevms::get_powershell();
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output}, $self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
options => $self->{option_results}, }
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, my ($stdout) = centreon::plugins::misc::execute(
command_options => $self->{option_results}->{command_options}); 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}
);
centreon::common::powershell::hyperv::2012::listnodevms::disco_show($self, stdout => $stdout); 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'). Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only> =item B<--ps-exec-only>
Print powershell output. Print powershell output.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,14 +31,14 @@ sub new {
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'list-node-vms' => 'apps::hyperv::2012::local::mode::listnodevms', 'list-node-vms' => 'apps::hyperv::2012::local::mode::listnodevms',
'node-integration-service' => 'apps::hyperv::2012::local::mode::nodeintegrationservice', 'node-integration-service' => 'apps::hyperv::2012::local::mode::nodeintegrationservice',
'node-replication' => 'apps::hyperv::2012::local::mode::nodereplication', 'node-replication' => 'apps::hyperv::2012::local::mode::nodereplication',
'node-snapshot' => 'apps::hyperv::2012::local::mode::nodesnapshot', 'node-snapshot' => 'apps::hyperv::2012::local::mode::nodesnapshot',
'node-vm-status' => 'apps::hyperv::2012::local::mode::nodevmstatus', 'node-vm-status' => 'apps::hyperv::2012::local::mode::nodevmstatus',
'scvmm-integration-service' => 'apps::hyperv::2012::local::mode::scvmmintegrationservice', 'scvmm-integration-service' => 'apps::hyperv::2012::local::mode::scvmmintegrationservice',
'scvmm-snapshot' => 'apps::hyperv::2012::local::mode::scvmmsnapshot', 'scvmm-snapshot' => 'apps::hyperv::2012::local::mode::scvmmsnapshot',
'scvmm-vm-status' => 'apps::hyperv::2012::local::mode::scvmmvmstatus', 'scvmm-vm-status' => 'apps::hyperv::2012::local::mode::scvmmvmstatus',
); );
return $self; return $self;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '0.1'; $self->{version} = '0.1';
%{$self->{modes}} = ( %{$self->{modes}} = (
'computers-status' => 'apps::wsus::local::mode::computersstatus', 'computers-status' => 'apps::wsus::local::mode::computersstatus',
'server-statistics' => 'apps::wsus::local::mode::serverstatistics', 'server-statistics' => 'apps::wsus::local::mode::serverstatistics',
'synchronisation-status' => 'apps::wsus::local::mode::synchronisationstatus', 'synchronisation-status' => 'apps::wsus::local::mode::synchronisationstatus',
'updates-status' => 'apps::wsus::local::mode::updatesstatus', 'updates-status' => 'apps::wsus::local::mode::updatesstatus',
); );
return $self; return $self;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -107,21 +107,22 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'cem-host:s' => { name => 'cem_host' }, 'cem-host:s' => { name => 'cem_host' },
'cem-user:s' => { name => 'cem_user' }, 'cem-user:s' => { name => 'cem_user' },
'cem-password:s' => { name => 'cem_password' }, 'cem-password:s' => { name => 'cem_password' },
'cem-port:s' => { name => 'cem_port', default => 3033 }, 'cem-port:s' => { name => 'cem_port', default => 3033 },
'sdk-path-dll:s' => { name => 'sdk_path_dll' }, 'sdk-path-dll:s' => { name => 'sdk_path_dll' },
'timeout:s' => { name => 'timeout', default => 50 }, 'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' }, 'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' }, 'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, 'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' }, 'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' }, 'ps-exec-only' => { name => 'ps_exec_only' },
'ps-sc-filter:s' => { name => 'ps_sc_filter' }, 'ps-display' => { name => 'ps_display' },
'start-time:s' => { name => 'start_time' }, 'ps-sc-filter:s' => { name => 'ps_sc_filter' },
'end-time:s' => { name => 'end_time' }, 'start-time:s' => { name => 'start_time' },
'timezone:s' => { name => 'timezone' }, 'end-time:s' => { name => 'end_time' },
'timezone:s' => { name => 'timezone' },
}); });
return $self; return $self;
@ -189,18 +190,28 @@ sub check_options {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $ps = centreon::common::powershell::dell::compellent::hbausage::get_powershell( if (!defined($self->{option_results}->{no_ps})) {
cem_host => $self->{option_results}->{cem_host}, my $ps = centreon::common::powershell::dell::compellent::hbausage::get_powershell(
cem_user => $self->{option_results}->{cem_user}, cem_host => $self->{option_results}->{cem_host},
cem_password => $self->{option_results}->{cem_password}, cem_user => $self->{option_results}->{cem_user},
cem_port => $self->{option_results}->{cem_port}, cem_password => $self->{option_results}->{cem_password},
sdk_path_dll => $self->{option_results}->{sdk_path_dll}, cem_port => $self->{option_results}->{cem_port},
no_ps => $self->{option_results}->{no_ps}, sdk_path_dll => $self->{option_results}->{sdk_path_dll},
filter_sc => $self->{option_results}->{ps_sc_filter}, filter_sc => $self->{option_results}->{ps_sc_filter},
end_time => $self->{end_time}, start_time => $self->{start_time} 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( my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output}, output => $self->{output},
timeout => $self->{option_results}->{timeout}, timeout => $self->{option_results}->{timeout},
@ -209,8 +220,10 @@ sub manage_selection {
command_options => $self->{option_results}->{command_options} command_options => $self->{option_results}->{command_options}
); );
if (defined($self->{option_results}->{ps_exec_only})) { if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => $stdout); severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit(); $self->{output}->exit();
} }
@ -282,6 +295,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand'). Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only> =item B<--ps-exec-only>
Print powershell output. 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 => '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' } { name => 'volume', type => 1, cb_prefix_output => 'prefix_volume_output', message_multiple => 'All volumes are ok' }
]; ];
$self->{maps_counters}->{sc} = [ $self->{maps_counters}->{sc} = [
{ label => 'sc-total', set => { { label => 'sc-total', set => {
key_values => [ { name => 'display' }, { name => 'used' }, { name => 'total' }, { name => 'type' } ], 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_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_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 ($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_size_value . " " . $total_size_unit, "Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used}, $total_size_value . " " . $total_size_unit,
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}); $total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free}
);
return $msg; return $msg;
} }
@ -177,21 +180,22 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'cem-host:s' => { name => 'cem_host' }, 'cem-host:s' => { name => 'cem_host' },
'cem-user:s' => { name => 'cem_user' }, 'cem-user:s' => { name => 'cem_user' },
'cem-password:s' => { name => 'cem_password' }, 'cem-password:s' => { name => 'cem_password' },
'cem-port:s' => { name => 'cem_port', default => 3033 }, 'cem-port:s' => { name => 'cem_port', default => 3033 },
'sdk-path-dll:s' => { name => 'sdk_path_dll' }, 'sdk-path-dll:s' => { name => 'sdk_path_dll' },
'timeout:s' => { name => 'timeout', default => 50 }, 'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' }, 'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' }, 'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' }, 'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' }, 'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' }, 'ps-exec-only' => { name => 'ps_exec_only' },
'ps-sc-filter:s' => { name => 'ps_sc_filter' }, 'ps-display' => { name => 'ps_display' },
'ps-sc-volume:s' => { name => 'ps_sc_volume' }, 'ps-sc-filter:s' => { name => 'ps_sc_filter' },
'units:s' => { name => 'units', default => '%' }, 'ps-sc-volume:s' => { name => 'ps_sc_volume' },
'free' => { name => 'free' }, 'units:s' => { name => 'units', default => '%' },
'free' => { name => 'free' },
}); });
return $self; return $self;
@ -214,18 +218,28 @@ sub check_options {
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
my $ps = centreon::common::powershell::dell::compellent::volumeusage::get_powershell( if (!defined($self->{option_results}->{no_ps})) {
cem_host => $self->{option_results}->{cem_host}, my $ps = centreon::common::powershell::dell::compellent::volumeusage::get_powershell(
cem_user => $self->{option_results}->{cem_user}, cem_host => $self->{option_results}->{cem_host},
cem_password => $self->{option_results}->{cem_password}, cem_user => $self->{option_results}->{cem_user},
cem_port => $self->{option_results}->{cem_port}, cem_password => $self->{option_results}->{cem_password},
sdk_path_dll => $self->{option_results}->{sdk_path_dll}, cem_port => $self->{option_results}->{cem_port},
no_ps => $self->{option_results}->{no_ps}, sdk_path_dll => $self->{option_results}->{sdk_path_dll},
filter_sc => $self->{option_results}->{ps_sc_filter}, filter_sc => $self->{option_results}->{ps_sc_filter},
filter_vol => $self->{option_results}->{ps_sc_volume} 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( my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output}, output => $self->{output},
timeout => $self->{option_results}->{timeout}, timeout => $self->{option_results}->{timeout},
@ -234,8 +248,10 @@ sub manage_selection {
command_options => $self->{option_results}->{command_options} command_options => $self->{option_results}->{command_options}
); );
if (defined($self->{option_results}->{ps_exec_only})) { if (defined($self->{option_results}->{ps_exec_only})) {
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => $stdout); severity => 'OK',
short_msg => $stdout
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit(); $self->{output}->exit();
} }
@ -316,6 +332,10 @@ Command path (Default: none).
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand'). Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
=item B<--ps-display>
Display powershell script.
=item B<--ps-exec-only> =item B<--ps-exec-only>
Print powershell output. Print powershell output.