wip: add an option to display powershell

This commit is contained in:
garnier-quentin 2020-01-27 11:07:46 +01:00
parent f023213020
commit 7315fe1dda
23 changed files with 568 additions and 420 deletions

View File

@ -32,23 +32,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 => {
{ 'remote-host:s' => { name => 'remote_host' },
"remote-host:s" => { name => 'remote_host', }, 'remote-user:s' => { name => 'remote_user' },
"remote-user:s" => { name => 'remote_user', }, 'remote-password:s' => { name => 'remote_password' },
"remote-password:s" => { name => 'remote_password', }, 'no-ps' => { name => 'no_ps' },
"no-ps" => { name => 'no_ps', }, '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' }, 'ps-exec-only' => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-display' => { name => 'ps_display' },
"warning:s" => { name => 'warning', }, 'warning:s' => { name => 'warning' },
"critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' }, 'critical:s' => { name => 'critical', default => '%{result} !~ /Success/i' },
"mailbox:s" => { name => 'mailbox', }, 'mailbox:s' => { name => 'mailbox' },
"password:s" => { name => 'password', }, 'password:s' => { name => 'password' },
"no-trust-ssl" => { name => 'no_trust_ssl', }, 'no-trust-ssl' => { name => 'no_trust_ssl' },
}); });
return $self; return $self;
} }
@ -80,23 +81,39 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
my $ps = centreon::common::powershell::exchange::2010::activesyncmailbox::get_powershell(remote_host => $self->{option_results}->{remote_host}, if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::activesyncmailbox::get_powershell(
remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password},
mailbox => $self->{option_results}->{mailbox}, mailbox => $self->{option_results}->{mailbox},
password => $self->{option_results}->{password}, password => $self->{option_results}->{password},
no_ps => $self->{option_results}->{no_ps},
no_trust_ssl => $self->{option_results}->{no_trust_ssl} no_trust_ssl => $self->{option_results}->{no_trust_ssl}
); );
$self->{option_results}->{command_options} .= " " . $ps; if (defined($self->{option_results}->{ps_display})) {
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, $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}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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 +166,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,29 +32,30 @@ 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 => {
{ 'remote-host:s' => { name => 'remote_host' },
"remote-host:s" => { name => 'remote_host', }, 'remote-user:s' => { name => 'remote_user' },
"remote-user:s" => { name => 'remote_user', }, 'remote-password:s' => { name => 'remote_password' },
"remote-password:s" => { name => 'remote_password', }, 'no-ps' => { name => 'no_ps' },
"no-ps" => { name => 'no_ps', }, 'no-mailflow' => { name => 'no_mailflow' },
"no-mailflow" => { name => 'no_mailflow', }, 'no-mapi' => { name => 'no_mapi' },
"no-mapi" => { name => 'no_mapi', }, 'no-copystatus' => { name => 'no_copystatus' },
"no-copystatus" => { name => 'no_copystatus', }, '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' }, 'ps-exec-only' => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-display' => { name => 'ps_display' },
"ps-database-filter:s" => { name => 'ps_database_filter', }, 'ps-database-filter:s' => { name => 'ps_database_filter' },
"ps-database-test-filter:s" => { name => 'ps_database_test_filter', }, 'ps-database-test-filter:s' => { name => 'ps_database_test_filter' },
"warning-mapi:s" => { name => 'warning_mapi', }, 'warning-mapi:s' => { name => 'warning_mapi' },
"critical-mapi:s" => { name => 'critical_mapi', default => '%{mapi_result} !~ /Success/i' }, 'critical-mapi:s' => { name => 'critical_mapi', default => '%{mapi_result} !~ /Success/i' },
"warning-mailflow:s" => { name => 'warning_mailflow', }, 'warning-mailflow:s' => { name => 'warning_mailflow' },
"critical-mailflow:s" => { name => 'critical_mailflow', default => '%{mailflow_result} !~ /Success/i' }, 'critical-mailflow:s' => { name => 'critical_mailflow', default => '%{mailflow_result} !~ /Success/i' },
"warning-copystatus:s" => { name => 'warning_copystatus', }, 'warning-copystatus:s' => { name => 'warning_copystatus' },
"critical-copystatus:s" => { name => 'critical_copystatus', default => '%{copystatus_indexstate} !~ /Healthy/i' }, 'critical-copystatus:s' => { name => 'critical_copystatus', default => '%{copystatus_indexstate} !~ /Healthy/i' },
}); });
return $self; return $self;
} }
@ -78,24 +79,41 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
my $ps = centreon::common::powershell::exchange::2010::databases::get_powershell(remote_host => $self->{option_results}->{remote_host}, if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::databases::get_powershell(
remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password},
no_mailflow => $self->{option_results}->{no_mailflow}, no_mailflow => $self->{option_results}->{no_mailflow},
no_ps => $self->{option_results}->{no_ps},
no_mapi => $self->{option_results}->{no_mapi}, no_mapi => $self->{option_results}->{no_mapi},
no_copystatus => $self->{option_results}->{no_copystatus}, no_copystatus => $self->{option_results}->{no_copystatus},
filter_database => $self->{option_results}->{ps_database_filter}, filter_database => $self->{option_results}->{ps_database_filter},
filter_database_test => $self->{option_results}->{ps_database_test_filter}); filter_database_test => $self->{option_results}->{ps_database_test_filter}
$self->{option_results}->{command_options} .= " " . $ps; );
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, if (defined($self->{option_results}->{ps_display})) {
$self->{output}->output_add(
severity => 'OK',
short_msg => $ps
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{option_results}->{command_options} .= " " . centreon::plugins::misc::powershell_encoded($ps);
}
my ($stdout) = centreon::plugins::misc::windows_execute(
output => $self->{output},
timeout => $self->{option_results}->{timeout}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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 +182,10 @@ Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
Print powershell output. Print powershell output.
=item B<--ps-display>
Display powershell script.
=item B<--ps-database-filter> =item B<--ps-database-filter>
Filter database (only wilcard '*' can be used. In Powershell). Filter database (only wilcard '*' can be used. In Powershell).

View File

@ -33,19 +33,20 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"remote-host:s" => { name => 'remote_host', }, 'remote-host:s' => { name => 'remote_host' },
"remote-user:s" => { name => 'remote_user', }, 'remote-user:s' => { name => 'remote_user' },
"remote-password:s" => { name => 'remote_password', }, 'remote-password:s' => { name => 'remote_password' },
"no-ps" => { name => 'no_ps', }, 'no-ps' => { name => 'no_ps' },
"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' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-exec-only' => { name => 'ps_exec_only' },
"warning:s" => { name => 'warning', }, 'ps-display' => { name => 'ps_display' },
"critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' }, 'warning:s' => { name => 'warning' },
"mailbox:s" => { name => 'mailbox', }, 'critical:s' => { name => 'critical', default => '%{result} !~ /Success/i' },
"password:s" => { name => 'password', }, 'mailbox:s' => { name => 'mailbox' },
'password:s' => { name => 'password' },
}); });
return $self; return $self;
@ -79,23 +80,38 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::imapmailbox::get_powershell( my $ps = centreon::common::powershell::exchange::2010::imapmailbox::get_powershell(
remote_host => $self->{option_results}->{remote_host}, remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password},
mailbox => $self->{option_results}->{mailbox}, mailbox => $self->{option_results}->{mailbox},
password => $self->{option_results}->{password}, password => $self->{option_results}->{password}
no_ps => $self->{option_results}->{no_ps},
); );
$self->{option_results}->{command_options} .= " " . $ps; if (defined($self->{option_results}->{ps_display})) {
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, $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}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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();
} }
@ -148,6 +164,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,19 +32,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 => {
{ 'remote-host:s' => { name => 'remote_host' },
"remote-host:s" => { name => 'remote_host', }, 'remote-user:s' => { name => 'remote_user' },
"remote-user:s" => { name => 'remote_user', }, 'remote-password:s' => { name => 'remote_password' },
"remote-password:s" => { name => 'remote_password', }, 'no-ps' => { name => 'no_ps' },
"no-ps" => { name => 'no_ps', }, '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' }, 'ps-exec-only' => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-database-filter:s' => { name => 'ps_database_filter' },
"ps-database-filter:s" => { name => 'ps_database_filter', },
}); });
return $self; return $self;
} }
@ -56,11 +56,13 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
my $ps = centreon::common::powershell::exchange::2010::listdatabases::get_powershell(remote_host => $self->{option_results}->{remote_host}, my $ps = centreon::common::powershell::exchange::2010::listdatabases::get_powershell(
remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password},
no_ps => $self->{option_results}->{no_ps}, no_ps => $self->{option_results}->{no_ps},
filter_database => $self->{option_results}->{ps_database_filter}); filter_database => $self->{option_results}->{ps_database_filter}
);
$self->{option_results}->{command_options} .= " " . $ps; $self->{option_results}->{command_options} .= " " . $ps;
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output},
timeout => $self->{option_results}->{timeout}, timeout => $self->{option_results}->{timeout},
@ -146,6 +148,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,21 +32,22 @@ 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 => {
{ 'remote-host:s' => { name => 'remote_host' },
"remote-host:s" => { name => 'remote_host', }, 'remote-user:s' => { name => 'remote_user' },
"remote-user:s" => { name => 'remote_user', }, 'remote-password:s' => { name => 'remote_password' },
"remote-password:s" => { name => 'remote_password', }, 'no-ps' => { name => 'no_ps' },
"no-ps" => { name => 'no_ps', }, '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' }, 'ps-exec-only' => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-display' => { name => 'ps_display' },
"warning:s" => { name => 'warning', }, 'warning:s' => { name => 'warning' },
"critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' }, 'critical:s' => { name => 'critical', default => '%{result} !~ /Success/i' },
"mailbox:s" => { name => 'mailbox', }, 'mailbox:s' => { name => 'mailbox' },
}); });
return $self; return $self;
} }
@ -74,22 +75,37 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::mapimailbox::get_powershell( my $ps = centreon::common::powershell::exchange::2010::mapimailbox::get_powershell(
remote_host => $self->{option_results}->{remote_host}, remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password},
mailbox => $self->{option_results}->{mailbox}, mailbox => $self->{option_results}->{mailbox}
no_ps => $self->{option_results}->{no_ps},
); );
$self->{option_results}->{command_options} .= " " . $ps; if (defined($self->{option_results}->{ps_display})) {
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, $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}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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();
} }
@ -142,6 +158,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

@ -33,19 +33,20 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"remote-host:s" => { name => 'remote_host', }, 'remote-host:s' => { name => 'remote_host' },
"remote-user:s" => { name => 'remote_user', }, 'remote-user:s' => { name => 'remote_user' },
"remote-password:s" => { name => 'remote_password', }, 'remote-password:s' => { name => 'remote_password' },
"no-ps" => { name => 'no_ps', }, 'no-ps' => { name => 'no_ps' },
"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' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-exec-only' => { name => 'ps_exec_only' },
"warning:s" => { name => 'warning', }, 'ps-display' => { name => 'ps_display' },
"critical:s" => { name => 'critical', default => '%{type} !~ /Success|Information/i' }, 'warning:s' => { name => 'warning', },
"mailbox:s" => { name => 'mailbox', }, 'critical:s' => { name => 'critical', default => '%{type} !~ /Success|Information/i' },
"password:s" => { name => 'password', }, 'mailbox:s' => { name => 'mailbox' },
'password:s' => { name => 'password' },
}); });
return $self; return $self;
@ -75,23 +76,38 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::outlookwebservices::get_powershell( my $ps = centreon::common::powershell::exchange::2010::outlookwebservices::get_powershell(
remote_host => $self->{option_results}->{remote_host}, remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password},
no_ps => $self->{option_results}->{no_ps},
mailbox => $self->{option_results}->{mailbox}, mailbox => $self->{option_results}->{mailbox},
password => $self->{option_results}->{password}, password => $self->{option_results}->{password}
); );
$self->{option_results}->{command_options} .= " " . $ps; if (defined($self->{option_results}->{ps_display})) {
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, $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}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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();
} }
@ -144,6 +160,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,24 +32,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 => {
{ 'remote-host:s' => { name => 'remote_host' },
"remote-host:s" => { name => 'remote_host', }, 'remote-user:s' => { name => 'remote_user' },
"remote-user:s" => { name => 'remote_user', }, 'remote-password:s' => { name => 'remote_password' },
"remote-password:s" => { name => 'remote_password', }, 'no-ps' => { name => 'no_ps' },
"no-ps" => { name => 'no_ps', }, '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' }, 'ps-exec-only' => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-display' => { name => 'ps_display' },
"warning:s" => { name => 'warning', }, 'warning:s' => { name => 'warning' },
"critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' }, 'critical:s' => { name => 'critical', default => '%{result} !~ /Success/i' },
"url:s" => { name => 'url', }, 'url:s' => { name => 'url' },
"mailbox:s" => { name => 'mailbox', }, 'mailbox:s' => { name => 'mailbox' },
"password:s" => { name => 'password', }, 'password:s' => { name => 'password' },
"no-trust-ssl" => { name => 'no_trust_ssl', }, 'no-trust-ssl' => { name => 'no_trust_ssl' },
}); });
return $self; return $self;
} }
@ -85,24 +86,40 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
my $ps = centreon::common::powershell::exchange::2010::owamailbox::get_powershell(remote_host => $self->{option_results}->{remote_host}, if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::owamailbox::get_powershell(
remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password},
url => $self->{option_results}->{url}, url => $self->{option_results}->{url},
mailbox => $self->{option_results}->{mailbox}, mailbox => $self->{option_results}->{mailbox},
password => $self->{option_results}->{password}, password => $self->{option_results}->{password},
no_ps => $self->{option_results}->{no_ps},
no_trust_ssl => $self->{option_results}->{no_trust_ssl} no_trust_ssl => $self->{option_results}->{no_trust_ssl}
); );
$self->{option_results}->{command_options} .= " " . $ps; if (defined($self->{option_results}->{ps_display})) {
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, $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}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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();
} }
@ -155,6 +172,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,20 +32,21 @@ 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 => {
{ 'remote-host:s' => { name => 'remote_host' },
"remote-host:s" => { name => 'remote_host', }, 'remote-user:s' => { name => 'remote_user' },
"remote-user:s" => { name => 'remote_user', }, 'remote-password:s' => { name => 'remote_password' },
"remote-password:s" => { name => 'remote_password', }, 'no-ps' => { name => 'no_ps' },
"no-ps" => { name => 'no_ps', }, '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' }, 'ps-exec-only' => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-display' => { name => 'ps_display' },
"warning:s" => { name => 'warning', }, 'warning:s' => { name => 'warning' },
"critical:s" => { name => 'critical', default => '%{status} !~ /Ready|Active/i' }, 'critical:s' => { name => 'critical', default => '%{status} !~ /Ready|Active/i' },
}); });
return $self; return $self;
} }
@ -69,21 +70,36 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::queues::get_powershell( my $ps = centreon::common::powershell::exchange::2010::queues::get_powershell(
remote_host => $self->{option_results}->{remote_host}, remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password}
no_ps => $self->{option_results}->{no_ps},
); );
$self->{option_results}->{command_options} .= " " . $ps; if (defined($self->{option_results}->{ps_display})) {
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, $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}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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();
} }
@ -136,6 +152,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,20 +32,21 @@ 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 => {
{ 'remote-host:s' => { name => 'remote_host', },
"remote-host:s" => { name => 'remote_host', }, 'remote-user:s' => { name => 'remote_user', },
"remote-user:s" => { name => 'remote_user', }, 'remote-password:s' => { name => 'remote_password', },
"remote-password:s" => { name => 'remote_password', }, 'no-ps' => { name => 'no_ps', },
"no-ps" => { name => 'no_ps', }, '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' }, 'ps-exec-only' => { name => 'ps_exec_only', },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-display' => { name => 'ps_display' },
"warning:s" => { name => 'warning', }, 'warning:s' => { name => 'warning', },
"critical:s" => { name => 'critical', default => '%{result} !~ /Passed/i' }, 'critical:s' => { name => 'critical', default => '%{result} !~ /Passed/i' },
}); });
return $self; return $self;
} }
@ -69,21 +70,36 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::replicationhealth::get_powershell( my $ps = centreon::common::powershell::exchange::2010::replicationhealth::get_powershell(
remote_host => $self->{option_results}->{remote_host}, remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password}
no_ps => $self->{option_results}->{no_ps},
); );
$self->{option_results}->{command_options} .= " " . $ps; if (defined($self->{option_results}->{ps_display})) {
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, $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}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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();
} }
@ -136,6 +152,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,20 +32,21 @@ 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 => {
{ 'remote-host:s' => { name => 'remote_host' },
"remote-host:s" => { name => 'remote_host', }, 'remote-user:s' => { name => 'remote_user' },
"remote-user:s" => { name => 'remote_user', }, 'remote-password:s' => { name => 'remote_password' },
"remote-password:s" => { name => 'remote_password', }, 'no-ps' => { name => 'no_ps' },
"no-ps" => { name => 'no_ps', }, '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' }, 'ps-exec-only' => { name => 'ps_exec_only' },
"ps-exec-only" => { name => 'ps_exec_only', }, 'ps-display' => { name => 'ps_display' },
"warning:s" => { name => 'warning', }, 'warning:s' => { name => 'warning' },
"critical:s" => { name => 'critical', default => '%{requiredservicesrunning} =~ /True/i and %{servicesnotrunning} ne ""' }, 'critical:s' => { name => 'critical', default => '%{requiredservicesrunning} =~ /True/i and %{servicesnotrunning} ne ""' },
}); });
return $self; return $self;
} }
@ -69,21 +70,36 @@ sub check_options {
sub run { sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
if (!defined($self->{option_results}->{no_ps})) {
my $ps = centreon::common::powershell::exchange::2010::services::get_powershell( my $ps = centreon::common::powershell::exchange::2010::services::get_powershell(
remote_host => $self->{option_results}->{remote_host}, remote_host => $self->{option_results}->{remote_host},
remote_user => $self->{option_results}->{remote_user}, remote_user => $self->{option_results}->{remote_user},
remote_password => $self->{option_results}->{remote_password}, remote_password => $self->{option_results}->{remote_password}
no_ps => $self->{option_results}->{no_ps},
); );
$self->{option_results}->{command_options} .= " " . $ps; if (defined($self->{option_results}->{ps_display})) {
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output}, $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}, timeout => $self->{option_results}->{timeout},
command => $self->{option_results}->{command}, command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path}, command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}); command_options => $self->{option_results}->{command_options}
);
if (defined($self->{option_results}->{ps_exec_only})) { 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();
} }
@ -136,6 +152,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

@ -27,12 +27,8 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
my $no_trust_ssl = (defined($options{no_trust_ssl})) ? '' : '-TrustAnySSLCertificate'; my $no_trust_ssl = (defined($options{no_trust_ssl})) ? '' : '-TrustAnySSLCertificate';
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
$ps .= ' $ps .= '
@ -56,7 +52,7 @@ Foreach ($result in $results) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check { sub check {
@ -65,8 +61,10 @@ sub check {
# Following output: # Following output:
#[scenario= Options ][result= Failure ][latency= 52,00 ][[error=...]] #[scenario= Options ][result= Failure ][latency= 52,00 ][[error=...]]
$self->{output}->output_add(severity => 'OK', $self->{output}->output_add(
short_msg => "ActiveSync to '" . $options{mailbox} . "' is ok."); severity => 'OK',
short_msg => "ActiveSync to '" . $options{mailbox} . "' is ok."
);
my $checked = 0; my $checked = 0;
$self->{output}->output_add(long_msg => $options{stdout}); $self->{output}->output_add(long_msg => $options{stdout});

View File

@ -27,14 +27,11 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps, no_mailflow, no_mapi # options: no_mailflow, no_mapi
my $no_mailflow = (defined($options{no_mailflow})) ? 1 : 0; my $no_mailflow = (defined($options{no_mailflow})) ? 1 : 0;
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
my $no_mapi = (defined($options{no_mapi})) ? 1 : 0; my $no_mapi = (defined($options{no_mapi})) ? 1 : 0;
my $no_copystatus = (defined($options{no_copystatus})) ? 1 : 0; my $no_copystatus = (defined($options{no_copystatus})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
$ps .= ' $ps .= '
@ -108,7 +105,7 @@ Foreach ($DB in $MountedDB) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check_mapi { sub check_mapi {

View File

@ -27,10 +27,6 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
@ -55,7 +51,7 @@ Foreach ($result in $results) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check { sub check {

View File

@ -27,10 +27,6 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps, no_mailflow, no_mapi
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
@ -65,7 +61,7 @@ Foreach ($DB in $MountedDB) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub list { sub list {

View File

@ -27,10 +27,6 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
@ -48,7 +44,7 @@ Write-Host "[name=" $mapi.Database "][server=" $mapi.Server "][result=" $mapi.Re
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check { sub check {

View File

@ -27,10 +27,6 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
@ -64,7 +60,7 @@ Foreach ($result in $results) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check { sub check {

View File

@ -27,12 +27,8 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
my $no_trust_ssl = (defined($options{no_trust_ssl})) ? '' : '-TrustAnySSLCertificate'; my $no_trust_ssl = (defined($options{no_trust_ssl})) ? '' : '-TrustAnySSLCertificate';
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
$ps .= ' $ps .= '
@ -56,7 +52,7 @@ Foreach ($result in $results) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check { sub check {

View File

@ -28,10 +28,6 @@ use centreon::plugins::misc;
#--remote-host --remote-user --remote-password #--remote-host --remote-user --remote-password
sub powershell_init { sub powershell_init {
my (%options) = @_; my (%options) = @_;
# options: no_ps
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"

View File

@ -27,10 +27,6 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
@ -49,7 +45,7 @@ Foreach ($result in $results) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check { sub check {

View File

@ -27,10 +27,6 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
@ -49,7 +45,7 @@ Foreach ($result in $results) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check { sub check {

View File

@ -27,10 +27,6 @@ use centreon::common::powershell::exchange::2010::powershell;
sub get_powershell { sub get_powershell {
my (%options) = @_; my (%options) = @_;
# options: no_ps
my $no_ps = (defined($options{no_ps})) ? 1 : 0;
return '' if ($no_ps == 1);
my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options); my $ps = centreon::common::powershell::exchange::2010::powershell::powershell_init(%options);
@ -51,7 +47,7 @@ Foreach ($result in $results) {
exit 0 exit 0
'; ';
return centreon::plugins::misc::powershell_encoded($ps); return $ps;
} }
sub check { sub check {

View File

@ -316,14 +316,10 @@ sub trim {
} }
sub powershell_encoded { sub powershell_encoded {
my ($value) = $_[0];
require Encode; require Encode;
require MIME::Base64; require MIME::Base64;
my $bytes = Encode::encode('utf16LE', $value); my $bytes = Encode::encode('utf16LE', $_[0]);
my $script = MIME::Base64::encode_base64($bytes, "\n"); return MIME::Base64::encode_base64($bytes, '');
$script =~ s/\n//g;
return $script;
} }
sub powershell_escape { sub powershell_escape {
@ -338,8 +334,10 @@ sub powershell_escape {
sub powershell_json_sanitizer { sub powershell_json_sanitizer {
my (%options) = @_; my (%options) = @_;
centreon::plugins::misc::mymodule_load(output => $options{output}, module => 'JSON::XS', centreon::plugins::misc::mymodule_load(
error_msg => "Cannot load module 'JSON::XS'."); output => $options{output}, module => 'JSON::XS',
error_msg => "Cannot load module 'JSON::XS'."
);
foreach my $line (split /\n/, $options{string}) { foreach my $line (split /\n/, $options{string}) {
eval { JSON::XS->new->utf8->decode($line) }; eval { JSON::XS->new->utf8->decode($line) };
return $line if (!$@); return $line if (!$@);
@ -522,8 +520,10 @@ sub set_timezone {
return {} if (!defined($options{name}) || $options{name} eq ''); return {} if (!defined($options{name}) || $options{name} eq '');
centreon::plugins::misc::mymodule_load(output => $options{output}, module => 'DateTime::TimeZone', centreon::plugins::misc::mymodule_load(
error_msg => "Cannot load module 'DateTime::TimeZone'."); output => $options{output}, module => 'DateTime::TimeZone',
error_msg => "Cannot load module 'DateTime::TimeZone'."
);
if (DateTime::TimeZone->is_valid_name($options{name})) { if (DateTime::TimeZone->is_valid_name($options{name})) {
return { time_zone => DateTime::TimeZone->new(name => $options{name}) }; return { time_zone => DateTime::TimeZone->new(name => $options{name}) };
} }
@ -545,4 +545,3 @@ sub uniq {
1; 1;
__END__ __END__