enhance mode outllok-webservices
This commit is contained in:
parent
9bf8cf5fa5
commit
ac6e872d73
|
@ -33,22 +33,22 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$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', },
|
||||||
"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', },
|
});
|
||||||
});
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,21 +33,22 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$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', },
|
||||||
"warning:s" => { name => 'warning', },
|
"critical:s" => { name => 'critical', default => '%{type} !~ /Success|Information/i' },
|
||||||
"critical:s" => { name => 'critical', default => '%{type} !~ /Success|Information/i' },
|
"mailbox:s" => { name => 'mailbox', },
|
||||||
"mailbox:s" => { name => 'mailbox', },
|
"password:s" => { name => 'password', },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +82,7 @@ sub run {
|
||||||
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},
|
||||||
mailbox => $self->{option_results}->{mailbox},
|
mailbox => $self->{option_results}->{mailbox},
|
||||||
|
password => $self->{option_results}->{password},
|
||||||
);
|
);
|
||||||
$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},
|
||||||
|
@ -161,6 +163,10 @@ Can used special variables like: %{type}, %{id}, %{message}
|
||||||
|
|
||||||
Set the mailbox to check (Required).
|
Set the mailbox to check (Required).
|
||||||
|
|
||||||
|
=item B<--password>
|
||||||
|
|
||||||
|
Set the password for the mailbox.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
|
@ -37,7 +37,22 @@ sub get_powershell {
|
||||||
$ps .= '
|
$ps .= '
|
||||||
try {
|
try {
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
';
|
||||||
|
if (defined($options{password}) && $options{password} ne '') {
|
||||||
|
$ps .= '
|
||||||
|
$username = "' . $options{mailbox} . '"
|
||||||
|
$password = "' . $options{password} . '"
|
||||||
|
$secstr = New-Object -TypeName System.Security.SecureString
|
||||||
|
$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}
|
||||||
|
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $secstr
|
||||||
|
$results = Test-OutlookWebServices -WarningAction:SilentlyContinue -MailboxCredential $cred
|
||||||
|
';
|
||||||
|
} else {
|
||||||
|
$ps .= '
|
||||||
$results = Test-OutlookWebServices -WarningAction:SilentlyContinue -Identity "' . $options{mailbox} . '"
|
$results = Test-OutlookWebServices -WarningAction:SilentlyContinue -Identity "' . $options{mailbox} . '"
|
||||||
|
';
|
||||||
|
}
|
||||||
|
$ps .= '
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host $Error[0].Exception
|
Write-Host $Error[0].Exception
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue