+ add mode for exchange: 'services', 'queues'
+ enhance mode to manage errors
This commit is contained in:
parent
cf0157c066
commit
7607ad507c
|
@ -27,8 +27,6 @@ use warnings;
|
|||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::activesyncmailbox;
|
||||
|
||||
my %threshold = ('warning' => 'warning', 'critical' => 'critical');
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -47,7 +45,7 @@ sub new {
|
|||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only', },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
"critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' },
|
||||
"mailbox:s" => { name => 'mailbox', },
|
||||
"password:s" => { name => 'password', },
|
||||
"no-trust-ssl" => { name => 'no_trust_ssl', },
|
||||
|
@ -56,6 +54,16 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning', 'critical')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
@ -68,17 +76,7 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "Need to specify '--password' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
foreach my $th (keys %threshold) {
|
||||
next if (!defined($self->{option_results}->{$th}));
|
||||
if ($self->{option_results}->{$th} !~ /^(\!=|=){0,1}(.*){0,1}/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold for option '--" . $th . "': " . $self->{option_results}->{$th});
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $operator = defined($1) && $1 ne '' ? $1 : '!=';
|
||||
my $state = defined($2) && $2 ne '' ? $2 : 'Success';
|
||||
$self->{thresholds}->{$th} = { state => $state, operator => $operator, out => $threshold{$th} };
|
||||
}
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -159,15 +157,13 @@ Print powershell output.
|
|||
|
||||
=item B<--warning>
|
||||
|
||||
Warning threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set warning threshold.
|
||||
Can used special variables like: %{result}, %{scenario}
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set critical threshold (Default: '%{result} !~ /Success/i').
|
||||
Can used special variables like: %{result}, %{scenario}
|
||||
|
||||
=item B<--mailbox>
|
||||
|
||||
|
|
|
@ -27,9 +27,6 @@ use warnings;
|
|||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::databases;
|
||||
|
||||
my %threshold = ('warning_mapi' => 'warning', 'critical_mapi' => 'critical',
|
||||
'warning_mailflow' => 'warning', 'critical_mailflow' => 'critical');
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -52,30 +49,29 @@ sub new {
|
|||
"ps-database-filter:s" => { name => 'ps_database_filter', },
|
||||
"ps-database-test-filter:s" => { name => 'ps_database_test_filter', },
|
||||
"warning-mapi:s" => { name => 'warning_mapi', },
|
||||
"critical-mapi:s" => { name => 'critical_mapi', },
|
||||
"critical-mapi:s" => { name => 'critical_mapi', default => '%{mapi_result} !~ /Success/i' },
|
||||
"warning-mailflow:s" => { name => 'warning_mailflow', },
|
||||
"critical-mailflow:s" => { name => 'critical_mailflow', },
|
||||
"critical-mailflow:s" => { name => 'critical_mailflow', default => '%{mailflow_result} !~ /Success/i' },
|
||||
});
|
||||
$self->{thresholds} = {};
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning_mapi', 'critical_mapi', 'warning_mailflow', 'critical_mailflow')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
foreach my $th (keys %threshold) {
|
||||
next if (!defined($self->{option_results}->{$th}));
|
||||
if ($self->{option_results}->{$th} !~ /^(\!=|=){0,1}(.*){0,1}/) {
|
||||
$th =~ s/_/-/;
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold for option '--" . $th . "': " . $self->{option_results}->{$th});
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $operator = defined($1) && $1 ne '' ? $1 : '!=';
|
||||
my $state = defined($2) && $2 ne '' ? $2 : 'Success';
|
||||
$self->{thresholds}->{$th} = { state => $state, operator => $operator, out => $threshold{$th} };
|
||||
}
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -172,27 +168,23 @@ Skip mapi/mailflow test (regexp can be used. In Powershell).
|
|||
|
||||
=item B<--warning-mapi>
|
||||
|
||||
Warning threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set warning threshold.
|
||||
Can used special variables like: %{mapi_result}, %{database}, %{server}
|
||||
|
||||
=item B<--critical-mapi>
|
||||
|
||||
Critical threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set critical threshold (Default: '%{mapi_result} !~ /Success/i').
|
||||
Can used special variables like: %{mapi_result}, %{database}, %{server}
|
||||
|
||||
=item B<--warning-mailflow>
|
||||
|
||||
Warning threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set warning threshold.
|
||||
Can used special variables like: %{mailflow_result}, %{database}, %{server}
|
||||
|
||||
=item B<--critical-mailflow>
|
||||
|
||||
Critical threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set critical threshold (Default: '%{mailflow_result} !~ /Success/i').
|
||||
Can used special variables like: %{mailflow_result}, %{database}, %{server}
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ use warnings;
|
|||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::imapmailbox;
|
||||
|
||||
my %threshold = ('warning' => 'warning', 'critical' => 'critical');
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -47,7 +45,7 @@ sub new {
|
|||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only', },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
"critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' },
|
||||
"mailbox:s" => { name => 'mailbox', },
|
||||
"password:s" => { name => 'password', },
|
||||
});
|
||||
|
@ -55,6 +53,16 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning', 'critical')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
@ -67,17 +75,7 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "Need to specify '--password' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
foreach my $th (keys %threshold) {
|
||||
next if (!defined($self->{option_results}->{$th}));
|
||||
if ($self->{option_results}->{$th} !~ /^(\!=|=){0,1}(.*){0,1}/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold for option '--" . $th . "': " . $self->{option_results}->{$th});
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $operator = defined($1) && $1 ne '' ? $1 : '!=';
|
||||
my $state = defined($2) && $2 ne '' ? $2 : 'Success';
|
||||
$self->{thresholds}->{$th} = { state => $state, operator => $operator, out => $threshold{$th} };
|
||||
}
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -158,15 +156,13 @@ Print powershell output.
|
|||
|
||||
=item B<--warning>
|
||||
|
||||
Warning threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set warning threshold.
|
||||
Can used special variables like: %{result}, %{scenario}
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set critical threshold (Default: '%{result} !~ /Success/i').
|
||||
Can used special variables like: %{result}, %{scenario}
|
||||
|
||||
=item B<--mailbox>
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ use warnings;
|
|||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::mapimailbox;
|
||||
|
||||
my %threshold = ('warning_mapi' => 'warning', 'critical_mapi' => 'critical');
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -47,13 +45,23 @@ sub new {
|
|||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only', },
|
||||
"warning-mapi:s" => { name => 'warning_mapi', },
|
||||
"critical-mapi:s" => { name => 'critical_mapi', },
|
||||
"critical-mapi:s" => { name => 'critical_mapi', default => '%{result} !~ /Success/i' },
|
||||
"mailbox:s" => { name => 'mailbox', },
|
||||
});
|
||||
$self->{thresholds} = {};
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning', 'critical')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
@ -62,18 +70,7 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "Need to specify '--mailbox' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
foreach my $th (keys %threshold) {
|
||||
next if (!defined($self->{option_results}->{$th}));
|
||||
if ($self->{option_results}->{$th} !~ /^(\!=|=){0,1}(.*){0,1}/) {
|
||||
$th =~ s/_/-/;
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold for option '--" . $th . "': " . $self->{option_results}->{$th});
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $operator = defined($1) && $1 ne '' ? $1 : '!=';
|
||||
my $state = defined($2) && $2 ne '' ? $2 : 'Success';
|
||||
$self->{thresholds}->{$th} = { state => $state, operator => $operator, out => $threshold{$th} };
|
||||
}
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -151,17 +148,15 @@ Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
|
|||
|
||||
Print powershell output.
|
||||
|
||||
=item B<--warning-mapi>
|
||||
=item B<--warning>
|
||||
|
||||
Warning threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set warning threshold.
|
||||
Can used special variables like: %{result}, %{scenario}
|
||||
|
||||
=item B<--critical-mapi>
|
||||
=item B<--critical>
|
||||
|
||||
Critical threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set critical threshold (Default: '%{result} !~ /Success/i').
|
||||
Can used special variables like: %{result}, %{scenario}
|
||||
|
||||
=item B<--mailbox>
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ use warnings;
|
|||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::owamailbox;
|
||||
|
||||
my %threshold = ('warning' => 'warning', 'critical' => 'critical');
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
|
@ -47,7 +45,7 @@ sub new {
|
|||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only', },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
"critical:s" => { name => 'critical', default => '%{result} !~ /Success/i' },
|
||||
"url:s" => { name => 'url', },
|
||||
"mailbox:s" => { name => 'mailbox', },
|
||||
"password:s" => { name => 'password', },
|
||||
|
@ -57,6 +55,16 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning', 'critical')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
@ -73,17 +81,7 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "Need to specify '--password' option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
foreach my $th (keys %threshold) {
|
||||
next if (!defined($self->{option_results}->{$th}));
|
||||
if ($self->{option_results}->{$th} !~ /^(\!=|=){0,1}(.*){0,1}/) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong threshold for option '--" . $th . "': " . $self->{option_results}->{$th});
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $operator = defined($1) && $1 ne '' ? $1 : '!=';
|
||||
my $state = defined($2) && $2 ne '' ? $2 : 'Success';
|
||||
$self->{thresholds}->{$th} = { state => $state, operator => $operator, out => $threshold{$th} };
|
||||
}
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -165,15 +163,13 @@ Print powershell output.
|
|||
|
||||
=item B<--warning>
|
||||
|
||||
Warning threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set warning threshold.
|
||||
Can used special variables like: %{result}, %{scenario}
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Critical threshold
|
||||
(If set without value, it's: "!=Success". Need to change if your not US language.
|
||||
Regexp can be used)
|
||||
Set critical threshold (Default: '%{result} !~ /Success/i').
|
||||
Can used special variables like: %{result}, %{scenario}
|
||||
|
||||
=item B<--url>
|
||||
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
#
|
||||
# Copyright 2015 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::exchange::2010::local::mode::queues;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::queues;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"remote-host:s" => { name => 'remote_host', },
|
||||
"remote-user:s" => { name => 'remote_user', },
|
||||
"remote-password:s" => { name => 'remote_password', },
|
||||
"no-ps" => { name => 'no_ps', },
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
"command:s" => { name => 'command', default => 'powershell.exe' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only', },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', default => '%{status} !~ /Ready|Active/i' },
|
||||
});
|
||||
$self->{thresholds} = {};
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning', 'critical')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $ps = centreon::common::powershell::exchange::2010::queues::get_powershell(
|
||||
remote_host => $self->{option_results}->{remote_host},
|
||||
remote_user => $self->{option_results}->{remote_user},
|
||||
remote_password => $self->{option_results}->{remote_password},
|
||||
no_ps => $self->{option_results}->{no_ps},
|
||||
);
|
||||
$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})) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => $stdout);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
centreon::common::powershell::exchange::2010::queues::check($self, stdout => $stdout);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check queues status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--remote-host>
|
||||
|
||||
Open a session to the remote-host (fully qualified host name). --remote-user and --remote-password are optional
|
||||
|
||||
=item B<--remote-user>
|
||||
|
||||
Open a session to the remote-host with authentication. This also needs --remote-host and --remote-password.
|
||||
|
||||
=item B<--remote-password>
|
||||
|
||||
Open a session to the remote-host with authentication. This also needs --remote-user and --remote-host.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout time for command execution (Default: 50 sec)
|
||||
|
||||
=item B<--no-ps>
|
||||
|
||||
Don't encode powershell. To be used with --command and 'type' command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'powershell.exe').
|
||||
Can be changed if you have output in a file. To be used with --no-ps option!!!
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
|
||||
|
||||
=item B<--ps-exec-only>
|
||||
|
||||
Print powershell output.
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold.
|
||||
Can used special variables like: %{status}, %{identity}, %{isvalid}, %{deliverytype}
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold (Default: '%{status} !~ /Ready|Active/i').
|
||||
Can used special variables like: %{status}, %{identity}, %{isvalid}, %{deliverytype}
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,157 @@
|
|||
#
|
||||
# Copyright 2015 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::exchange::2010::local::mode::services;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::services;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"remote-host:s" => { name => 'remote_host', },
|
||||
"remote-user:s" => { name => 'remote_user', },
|
||||
"remote-password:s" => { name => 'remote_password', },
|
||||
"no-ps" => { name => 'no_ps', },
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
"command:s" => { name => 'command', default => 'powershell.exe' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
|
||||
"ps-exec-only" => { name => 'ps_exec_only', },
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', default => '%{requiredservicesrunning} =~ /True/i and %{servicesnotrunning} ne ""' },
|
||||
});
|
||||
$self->{thresholds} = {};
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub change_macros {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
foreach (('warning', 'critical')) {
|
||||
if (defined($self->{option_results}->{$_})) {
|
||||
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{data}->{$1}/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
$self->change_macros();
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $ps = centreon::common::powershell::exchange::2010::services::get_powershell(
|
||||
remote_host => $self->{option_results}->{remote_host},
|
||||
remote_user => $self->{option_results}->{remote_user},
|
||||
remote_password => $self->{option_results}->{remote_password},
|
||||
no_ps => $self->{option_results}->{no_ps},
|
||||
);
|
||||
$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})) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => $stdout);
|
||||
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
centreon::common::powershell::exchange::2010::services::check($self, stdout => $stdout);
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check exchange services.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--remote-host>
|
||||
|
||||
Open a session to the remote-host (fully qualified host name). --remote-user and --remote-password are optional
|
||||
|
||||
=item B<--remote-user>
|
||||
|
||||
Open a session to the remote-host with authentication. This also needs --remote-host and --remote-password.
|
||||
|
||||
=item B<--remote-password>
|
||||
|
||||
Open a session to the remote-host with authentication. This also needs --remote-user and --remote-host.
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set timeout time for command execution (Default: 50 sec)
|
||||
|
||||
=item B<--no-ps>
|
||||
|
||||
Don't encode powershell. To be used with --command and 'type' command.
|
||||
|
||||
=item B<--command>
|
||||
|
||||
Command to get information (Default: 'powershell.exe').
|
||||
Can be changed if you have output in a file. To be used with --no-ps option!!!
|
||||
|
||||
=item B<--command-path>
|
||||
|
||||
Command path (Default: none).
|
||||
|
||||
=item B<--command-options>
|
||||
|
||||
Command options (Default: '-InputFormat none -NoLogo -EncodedCommand').
|
||||
|
||||
=item B<--ps-exec-only>
|
||||
|
||||
Print powershell output.
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold.
|
||||
Can used special variables like: %{servicesrunning}, %{servicesnotrunning}, %{role}, %{requiredservicesrunning}
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Set critical threshold (Default: '%{requiredservicesrunning} =~ /True/i and %{servicesnotrunning} ne ""').
|
||||
Can used special variables like: %{servicesrunning}, %{servicesnotrunning}, %{role}, %{requiredservicesrunning}
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -38,6 +38,8 @@ sub new {
|
|||
'imap-mailbox' => 'apps::exchange::2010::local::mode::imapmailbox',
|
||||
'mapi-mailbox' => 'apps::exchange::2010::local::mode::mapimailbox',
|
||||
'owa-mailbox' => 'apps::exchange::2010::local::mode::owamailbox',
|
||||
'queues' => 'apps::exchange::2010::local::mode::queues',
|
||||
'services' => 'apps::exchange::2010::local::mode::services',
|
||||
);
|
||||
|
||||
return $self;
|
||||
|
|
|
@ -71,28 +71,36 @@ sub check {
|
|||
my $checked = 0;
|
||||
$self->{output}->output_add(long_msg => $options{stdout});
|
||||
while ($options{stdout} =~ /\[scenario=(.*?)\]\[result=(.*?)\]\[latency=(.*?)\]\[\[error=(.*?)\]\]/msg) {
|
||||
my ($scenario, $result, $latency, $error) = ($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
$self->{data} = {};
|
||||
($self->{data}->{scenario}, $self->{data}->{result}, $self->{data}->{latency}, $self->{data}->{error}) =
|
||||
($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
|
||||
$checked++;
|
||||
foreach my $th (('critical', 'warning')) {
|
||||
next if (!defined($self->{thresholds}->{$th}));
|
||||
|
||||
if ($self->{thresholds}->{$th}->{operator} eq '=' &&
|
||||
$result =~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("ActiveSync scenario '%s' to '%s' is '%s'",
|
||||
$scenario, $options{mailbox}, $result));
|
||||
} elsif ($self->{thresholds}->{$th}->{operator} eq '!=' &&
|
||||
$result !~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("ActiveSync scenario '%s' to '%s' is '%s'",
|
||||
$scenario, $options{mailbox}, $result));
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
eval "$self->{option_results}->{critical}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
eval "$self->{option_results}->{warning}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $status,
|
||||
short_msg => sprintf("ActiveSync scenario '%s' to '%s' is '%s'",
|
||||
$self->{data}->{scenario}, $options{mailbox}, $self->{data}->{result}));
|
||||
}
|
||||
|
||||
if ($latency =~ /^(\d+)/) {
|
||||
$self->{output}->perfdata_add(label => $scenario, unit => 's',
|
||||
if ($self->{data}->{latency} =~ /^(\d+)/) {
|
||||
$self->{output}->perfdata_add(label => $self->{data}->{scenario}, unit => 's',
|
||||
value => sprintf("%.3f", $1 / 1000),
|
||||
min => 0);
|
||||
}
|
||||
|
|
|
@ -115,23 +115,29 @@ sub check_mapi {
|
|||
return ;
|
||||
}
|
||||
|
||||
my $mapi_result = centreon::plugins::misc::trim($1);
|
||||
$self->{data}->{mapi_result} = centreon::plugins::misc::trim($1);
|
||||
$self->{output}->output_add(long_msg => " MAPI Test connectivity: " . $self->{data}->{mapi_result});
|
||||
|
||||
$self->{output}->output_add(long_msg => " MAPI Test connectivity: " . $mapi_result);
|
||||
foreach my $th (('critical_mapi', 'warning_mapi')) {
|
||||
next if (!defined($self->{thresholds}->{$th}));
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if ($self->{thresholds}->{$th}->{operator} eq '=' &&
|
||||
$mapi_result =~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("Server '%s' Database '%s' MAPI connectivity is %s",
|
||||
$options{server}, $options{database}, $mapi_result));
|
||||
} elsif ($self->{thresholds}->{$th}->{operator} eq '!=' &&
|
||||
$mapi_result !~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("Server '%s' Database '%s' MAPI connectivity is %s",
|
||||
$options{server}, $options{database}, $mapi_result));
|
||||
if (defined($self->{option_results}->{critical_mapi}) && $self->{option_results}->{critical_mapi} ne '' &&
|
||||
eval "$self->{option_results}->{critical_mapi}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning_mapi}) && $self->{option_results}->{warning_mapi} ne '' &&
|
||||
eval "$self->{option_results}->{warning_mapi}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $status,
|
||||
short_msg => sprintf("Server '%s' Database '%s' MAPI connectivity is %s",
|
||||
$self->{data}->{server}, $self->{data}->{database}, $self->{data}->{mapi_result}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,27 +154,34 @@ sub check_mailflow {
|
|||
return ;
|
||||
}
|
||||
|
||||
my ($mailflow_result, $latency) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2));
|
||||
$self->{data}->{mailflow_result} = centreon::plugins::misc::trim($1);
|
||||
my $latency = centreon::plugins::misc::trim($2);
|
||||
$self->{output}->output_add(long_msg => " Mailflow Test: " . $self->{data}->{mailflow_result});
|
||||
|
||||
$self->{output}->output_add(long_msg => " Mailflow Test: " . $mailflow_result);
|
||||
foreach my $th (('critical_mailflow', 'warning_mailflow')) {
|
||||
next if (!defined($self->{thresholds}->{$th}));
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if ($self->{thresholds}->{$th}->{operator} eq '=' &&
|
||||
$mailflow_result =~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("Server '%s' Database '%s' Mailflow test is %s",
|
||||
$options{server}, $options{database}, $mailflow_result));
|
||||
} elsif ($self->{thresholds}->{$th}->{operator} eq '!=' &&
|
||||
$mailflow_result !~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("Server '%s' Database '%s' Mailflow test is %s",
|
||||
$options{server}, $options{database}, $mailflow_result));
|
||||
if (defined($self->{option_results}->{critical_mailflow}) && $self->{option_results}->{critical_mailflow} ne '' &&
|
||||
eval "$self->{option_results}->{critical_mailflow}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning_mailflow}) && $self->{option_results}->{warning_mailflow} ne '' &&
|
||||
eval "$self->{option_results}->{warning_mailflow}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $status,
|
||||
short_msg => sprintf("Server '%s' Database '%s' Mailflow test is %s",
|
||||
$self->{data}->{server}, $self->{data}->{database}, $self->{data}->{mailflow_result}));
|
||||
}
|
||||
|
||||
if ($latency =~ /^(\d+)/) {
|
||||
$self->{output}->perfdata_add(label => 'latency_' . $options{database}, unit => 's',
|
||||
$self->{output}->perfdata_add(label => 'latency_' . $self->{data}->{server} . '_' . $self->{data}->{database}, unit => 's',
|
||||
value => sprintf("%.3f", $1 / 1000),
|
||||
min => 0);
|
||||
}
|
||||
|
@ -197,23 +210,24 @@ sub check {
|
|||
foreach my $line (split /\n/, $options{stdout}) {
|
||||
next if ($line !~ /^\[name=(.*?)\]\[server=(.*?)\]\[mounted=(.*?)\]\[size=(.*?)\]\[asize=(.*?)\]/);
|
||||
$checked++;
|
||||
my ($database, $server, $mounted, $size, $asize) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
|
||||
$self->{data} = {};
|
||||
($self->{data}->{database}, $self->{data}->{server}, $self->{data}->{mounted}, $self->{data}->{size}, $self->{data}->{asize}) = (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 => sprintf("Test database '%s' server '%s':", $database, $server));
|
||||
if ($size =~ /\((.*?)\s*bytes/) {
|
||||
$self->{output}->output_add(long_msg => sprintf("Test database '%s' server '%s':", $self->{data}->{database}, $self->{data}->{server}));
|
||||
if ($self->{data}->{size} =~ /\((.*?)\s*bytes/) {
|
||||
my $total_bytes = $1;
|
||||
$total_bytes =~ s/[.,]//g;
|
||||
$self->{output}->perfdata_add(label => 'size_' . $database, unit => 'B',
|
||||
$self->{output}->perfdata_add(label => 'size_' . $self->{data}->{database}, unit => 'B',
|
||||
value => $total_bytes,
|
||||
min => 0);
|
||||
my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_bytes);
|
||||
$self->{output}->output_add(long_msg => sprintf(" Size %s", $total_value . ' ' . $total_unit));
|
||||
}
|
||||
if ($asize =~ /\((.*?)\s*bytes/) {
|
||||
if ($self->{data}->{asize} =~ /\((.*?)\s*bytes/) {
|
||||
my $total_bytes = $1;
|
||||
$total_bytes =~ s/[.,]//g;
|
||||
$self->{output}->perfdata_add(label => 'asize_' . $database, unit => 'B',
|
||||
$self->{output}->perfdata_add(label => 'asize_' . $self->{data}->{database}, unit => 'B',
|
||||
value => $total_bytes,
|
||||
min => 0);
|
||||
my ($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $total_bytes);
|
||||
|
@ -222,16 +236,16 @@ sub check {
|
|||
|
||||
|
||||
# Check mounted
|
||||
if ($mounted =~ /False/i) {
|
||||
if ($self->{data}->{mounted} =~ /False/i) {
|
||||
$self->{output}->output_add(long_msg => sprintf(" not mounted\n Skip mapi/mailflow test"));
|
||||
$self->{output}->output_add(severity => 'CRITICAL',
|
||||
short_msg => sprintf("Database '%s' server '%s' is not mounted", $database, $server));
|
||||
short_msg => sprintf("Database '%s' server '%s' is not mounted", $self->{data}->{database}, $self->{data}->{server}));
|
||||
next;
|
||||
}
|
||||
$self->{output}->output_add(long_msg => sprintf(" mounted"));
|
||||
|
||||
check_mapi($self, database => $database, server => $server, line => $line);
|
||||
check_mailflow($self, database => $database, server => $server, line => $line);
|
||||
check_mapi($self, line => $line);
|
||||
check_mailflow($self, line => $line);
|
||||
}
|
||||
|
||||
if ($checked == 0) {
|
||||
|
|
|
@ -70,28 +70,37 @@ sub check {
|
|||
my $checked = 0;
|
||||
$self->{output}->output_add(long_msg => $options{stdout});
|
||||
while ($options{stdout} =~ /\[scenario=(.*?)\]\[result=(.*?)\]\[latency=(.*?)\]\[\[error=(.*?)\]\]/msg) {
|
||||
my ($scenario, $result, $latency, $error) = ($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
$self->{data} = {};
|
||||
($self->{data}->{scenario}, $self->{data}->{result}, $self->{data}->{latency}, $self->{data}->{error}) =
|
||||
($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
|
||||
$checked++;
|
||||
foreach my $th (('critical', 'warning')) {
|
||||
next if (!defined($self->{thresholds}->{$th}));
|
||||
|
||||
if ($self->{thresholds}->{$th}->{operator} eq '=' &&
|
||||
$result =~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("Imap scenario '%s' to '%s' is '%s'",
|
||||
$scenario, $options{mailbox}, $result));
|
||||
} elsif ($self->{thresholds}->{$th}->{operator} eq '!=' &&
|
||||
$result !~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("Imap scenario '%s' to '%s' is '%s'",
|
||||
$scenario, $options{mailbox}, $result));
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
eval "$self->{option_results}->{critical}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
eval "$self->{option_results}->{warning}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $status,
|
||||
short_msg => sprintf("Imap scenario '%s' to '%s' is '%s'",
|
||||
$self->{data}->{scenario}, $options{mailbox}, $self->{data}->{result}));
|
||||
}
|
||||
|
||||
if ($latency =~ /^(\d+)/) {
|
||||
$self->{output}->perfdata_add(label => $scenario, unit => 's',
|
||||
if ($self->{data}->{latency} =~ /^(\d+)/) {
|
||||
$self->{output}->perfdata_add(label => $self->{data}->{scenario}, unit => 's',
|
||||
value => sprintf("%.3f", $1 / 1000),
|
||||
min => 0);
|
||||
}
|
||||
|
|
|
@ -63,27 +63,36 @@ sub check {
|
|||
short_msg => 'Cannot find informations');
|
||||
return ;
|
||||
}
|
||||
my ($database, $server, $result, $error) = (centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
$self->{data} = {};
|
||||
($self->{data}->{database}, $self->{data}->{server}, $self->{data}->{result}, $self->{data}->{error}) =
|
||||
(centreon::plugins::misc::trim($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "MAPI connection to '" . $options{mailbox} . "' is '" . $result . "'.");
|
||||
short_msg => "MAPI connection to '" . $options{mailbox} . "' is '" . $self->{data}->{result} . "'.");
|
||||
$self->{output}->output_add(long_msg => sprintf("Database: %s, Server: %s\nError: %s",
|
||||
$database, $server, $error));
|
||||
foreach my $th (('critical_mapi', 'warning_mapi')) {
|
||||
next if (!defined($self->{thresholds}->{$th}));
|
||||
$self->{data}->{database}, $self->{data}->{server}, $self->{data}->{error}));
|
||||
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if ($self->{thresholds}->{$th}->{operator} eq '=' &&
|
||||
$result =~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("MAPI connection to '%s' is '%s'",
|
||||
$options{mailbox}, $result));
|
||||
} elsif ($self->{thresholds}->{$th}->{operator} eq '!=' &&
|
||||
$result !~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("MAPI connection to '%s' is '%s'",
|
||||
$options{mailbox}, $result));
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
eval "$self->{option_results}->{critical}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
eval "$self->{option_results}->{warning}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $status,
|
||||
short_msg => sprintf("MAPI connection to '%s' is '%s'",
|
||||
$options{mailbox}, $self->{data}->{result}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,28 +71,36 @@ sub check {
|
|||
my $checked = 0;
|
||||
$self->{output}->output_add(long_msg => $options{stdout});
|
||||
while ($options{stdout} =~ /\[url=(.*?)\]\[scenario=(.*?)\]\[result=(.*?)\]\[latency=(.*?)\]\[\[error=(.*?)\]\]/msg) {
|
||||
my ($url, $scenario, $result, $latency, $error) = ($self->{output}->to_utf8($1), $self->{output}->to_utf8($2), centreon::plugins::misc::trim($3),
|
||||
centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
|
||||
$self->{data} = {};
|
||||
($self->{data}->{url}, $self->{data}->{scenario}, $self->{data}->{result}, $self->{data}->{latency}, $self->{data}->{error}) =
|
||||
($self->{output}->to_utf8($1), $self->{output}->to_utf8($2), centreon::plugins::misc::trim($3),
|
||||
centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5));
|
||||
|
||||
$checked++;
|
||||
foreach my $th (('critical', 'warning')) {
|
||||
next if (!defined($self->{thresholds}->{$th}));
|
||||
|
||||
if ($self->{thresholds}->{$th}->{operator} eq '=' &&
|
||||
$result =~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("OWA scenario '%s' to '%s' is '%s' [url: %s]",
|
||||
$scenario, $options{mailbox}, $result, $url));
|
||||
} elsif ($self->{thresholds}->{$th}->{operator} eq '!=' &&
|
||||
$result !~ /$self->{thresholds}->{$th}->{state}/) {
|
||||
$self->{output}->output_add(severity => $self->{thresholds}->{$th}->{out},
|
||||
short_msg => sprintf("OWA scenario '%s' to '%s' is '%s' [url: %s]",
|
||||
$scenario, $options{mailbox}, $result, $url));
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
eval "$self->{option_results}->{critical}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
eval "$self->{option_results}->{warning}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $status,
|
||||
short_msg => sprintf("OWA scenario '%s' to '%s' is '%s' [url: %s]",
|
||||
$self->{data}->{scenario}, $options{mailbox}, $self->{data}->{result}, $self->{data}->{url}));
|
||||
}
|
||||
|
||||
if ($latency =~ /^(\d+)/) {
|
||||
$self->{output}->perfdata_add(label => $url . '_' . $scenario, unit => 's',
|
||||
if ($self->{data}->{latency} =~ /^(\d+)/) {
|
||||
$self->{output}->perfdata_add(label => $self->{data}->{url} . '_' . $self->{data}->{scenario}, unit => 's',
|
||||
value => sprintf("%.3f", $1 / 1000),
|
||||
min => 0);
|
||||
}
|
||||
|
@ -110,6 +118,6 @@ __END__
|
|||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Method to check Exchange 2010 activesync on a specific mailbox.
|
||||
Method to check Exchange 2010 owa connection on a specific mailbox.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,117 @@
|
|||
#
|
||||
# Copyright 2015 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package centreon::common::powershell::exchange::2010::queues;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::powershell;
|
||||
|
||||
sub get_powershell {
|
||||
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);
|
||||
|
||||
$ps .= '
|
||||
try {
|
||||
$ErrorActionPreference = "Stop"
|
||||
$results = Get-Queue
|
||||
} catch {
|
||||
Write-Host $Error[0].Exception
|
||||
exit 1
|
||||
}
|
||||
|
||||
Foreach ($result in $results) {
|
||||
Write-Host "[identity=" $result.Identity "][deliverytype=" $result.DeliveryType "][status=" $result.Status "][isvalid=" $result.IsValid "][messagecount=" $result.MessageCount "][[error=" $result.LastError "]]"
|
||||
}
|
||||
exit 0
|
||||
';
|
||||
|
||||
return centreon::plugins::misc::powershell_encoded($ps);
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self, %options) = @_;
|
||||
# options: stdout
|
||||
|
||||
# Following output:
|
||||
#[identity= ][deliverytype= SmtpRelayWithinAdSite][status= Active ][isvalid= Yes][messagecount= 1 ][[error=...]]
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "All Queues are ok.");
|
||||
|
||||
my $checked = 0;
|
||||
$self->{output}->output_add(long_msg => $options{stdout});
|
||||
while ($options{stdout} =~ /\[identity=(.*?)\]\[deliverytype=(.*?)\]\[status=(.*?)\]\[isvalid=(.*?)\]\[messagecount=(.*?)\]\[\[error=(.*?)\]\]/msg) {
|
||||
$self->{data} = {};
|
||||
($self->{data}->{identity}, $self->{data}->{deliverytype}, $self->{data}->{status}, $self->{data}->{isvalid}, $self->{data}->{messagecount}, $self->{data}->{error}) =
|
||||
($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4), centreon::plugins::misc::trim($5), centreon::plugins::misc::trim($6));
|
||||
|
||||
$checked++;
|
||||
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
eval "$self->{option_results}->{critical}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
eval "$self->{option_results}->{warning}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $status,
|
||||
short_msg => sprintf("Queue '%s' status is '%s' [last error: %s]",
|
||||
$self->{data}->{identity}, $self->{data}->{status}, $self->{data}->{error}));
|
||||
}
|
||||
|
||||
if ($self->{data}->{messagecount} =~ /^(\d+)/) {
|
||||
$self->{output}->perfdata_add(label => 'queue_length_' . $self->{data}->{identity},
|
||||
value => $1,
|
||||
min => 0);
|
||||
}
|
||||
}
|
||||
|
||||
if ($checked == 0) {
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
short_msg => 'Cannot find informations');
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Method to check Exchange 2010 queues.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,113 @@
|
|||
#
|
||||
# Copyright 2015 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package centreon::common::powershell::exchange::2010::services;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::misc;
|
||||
use centreon::common::powershell::exchange::2010::powershell;
|
||||
|
||||
sub get_powershell {
|
||||
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);
|
||||
|
||||
$ps .= '
|
||||
try {
|
||||
$ErrorActionPreference = "Stop"
|
||||
$results = Test-ServiceHealth
|
||||
} catch {
|
||||
Write-Host $Error[0].Exception
|
||||
exit 1
|
||||
}
|
||||
|
||||
Foreach ($result in $results) {
|
||||
$servicesrunning = [String]::join(",", $result.ServicesRunning)
|
||||
$servicesnotrunning = [String]::join(",", $result.ServicesNotRunning)
|
||||
Write-Host "[role=" $result.Role "][requiredservicesrunning=" $result.RequiredServicesRunning "][servicesrunning=" $servicesrunning "][servicesnotrunning=" $servicesnotrunning "]"
|
||||
}
|
||||
exit 0
|
||||
';
|
||||
|
||||
return centreon::plugins::misc::powershell_encoded($ps);
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self, %options) = @_;
|
||||
# options: stdout
|
||||
|
||||
# Following output:
|
||||
#[role= Mailbox Server Role ][requiredservicesrunning= True ][servicesrunning= IISAdmin,MSExchangeADTopology,MSExchangeSA,... ][servicesnotrunning= ]
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => "All role services are ok.");
|
||||
|
||||
my $checked = 0;
|
||||
$self->{output}->output_add(long_msg => $options{stdout});
|
||||
while ($options{stdout} =~ /\[role=(.*?)\]\[requiredservicesrunning=(.*?)\]\[servicesrunning=(.*?)\]\[servicesnotrunning=(.*?)\]/msg) {
|
||||
$self->{data} = {};
|
||||
($self->{data}->{role}, $self->{data}->{requiredservicesrunning}, $self->{data}->{servicesrunning}, $self->{data}->{servicesnotrunning}) =
|
||||
($self->{output}->to_utf8($1), centreon::plugins::misc::trim($2),
|
||||
centreon::plugins::misc::trim($3), centreon::plugins::misc::trim($4));
|
||||
|
||||
$checked++;
|
||||
|
||||
my ($status, $message) = ('ok');
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
if (defined($self->{option_results}->{critical}) && $self->{option_results}->{critical} ne '' &&
|
||||
eval "$self->{option_results}->{critical}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{option_results}->{warning}) && $self->{option_results}->{warning} ne '' &&
|
||||
eval "$self->{option_results}->{warning}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
if (!$self->{output}->is_status(value => $status, compare => 'ok', litteral => 1)) {
|
||||
$self->{output}->output_add(severity => $status,
|
||||
short_msg => sprintf("Role '%s' services problem [services not running: %s]",
|
||||
$self->{data}->{role}, $self->{data}->{servicesnotrunning}));
|
||||
}
|
||||
}
|
||||
|
||||
if ($checked == 0) {
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
short_msg => 'Cannot find informations');
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Method to check Exchange 2010 services running or not running.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue