mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 16:14:21 +02:00
parent
7a177673ed
commit
fd845dff88
@ -55,7 +55,10 @@ sub new {
|
|||||||
'password:s' => { name => 'password' },
|
'password:s' => { name => 'password' },
|
||||||
'legacy-password:s' => { name => 'legacy_password' },
|
'legacy-password:s' => { name => 'legacy_password' },
|
||||||
'new-api' => { name => 'new_api' },
|
'new-api' => { name => 'new_api' },
|
||||||
'timeout:s' => { name => 'timeout' }
|
'timeout:s' => { name => 'timeout' },
|
||||||
|
'unknown-http-status:s' => { name => 'unknown_http_status' },
|
||||||
|
'warning-http-status:s' => { name => 'warning_http_status' },
|
||||||
|
'critical-http-status:s' => { name => 'critical_http_status' }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$options{options}->add_help(package => __PACKAGE__, sections => 'CUSTOM MODE OPTIONS', once => 1);
|
$options{options}->add_help(package => __PACKAGE__, sections => 'CUSTOM MODE OPTIONS', once => 1);
|
||||||
@ -84,9 +87,12 @@ sub check_options {
|
|||||||
$self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : undef;
|
$self->{username} = (defined($self->{option_results}->{username})) ? $self->{option_results}->{username} : undef;
|
||||||
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef;
|
$self->{password} = (defined($self->{option_results}->{password})) ? $self->{option_results}->{password} : undef;
|
||||||
$self->{legacy_password} = (defined($self->{option_results}->{legacy_password})) ? $self->{option_results}->{legacy_password} : undef;
|
$self->{legacy_password} = (defined($self->{option_results}->{legacy_password})) ? $self->{option_results}->{legacy_password} : undef;
|
||||||
|
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300' ;
|
||||||
|
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
||||||
|
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
||||||
|
|
||||||
if (!defined($self->{hostname}) || $self->{hostname} eq '') {
|
if ($self->{hostname} eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
|
$self->{output}->add_option_msg(short_msg => 'Need to specify --hostname option.');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -100,9 +106,6 @@ sub build_options_for_httplib {
|
|||||||
$self->{option_results}->{port} = $self->{port};
|
$self->{option_results}->{port} = $self->{port};
|
||||||
$self->{option_results}->{proto} = $self->{proto};
|
$self->{option_results}->{proto} = $self->{proto};
|
||||||
$self->{option_results}->{timeout} = $self->{timeout};
|
$self->{option_results}->{timeout} = $self->{timeout};
|
||||||
$self->{option_results}->{warning_status} = '';
|
|
||||||
$self->{option_results}->{critical_status} = '';
|
|
||||||
$self->{option_results}->{unknown_status} = '%{http_code} < 200 or %{http_code} >= 300';
|
|
||||||
|
|
||||||
if (defined($self->{username})) {
|
if (defined($self->{username})) {
|
||||||
$self->{option_results}->{username} = $self->{username};
|
$self->{option_results}->{username} = $self->{username};
|
||||||
@ -228,7 +231,12 @@ sub request {
|
|||||||
} else {
|
} else {
|
||||||
$url = '/query/' . $options{command} . '?' . $encoded_args
|
$url = '/query/' . $options{command} . '?' . $encoded_args
|
||||||
}
|
}
|
||||||
my ($content) = $self->{http}->request(url_path => $url);
|
my ($content) = $self->{http}->request(
|
||||||
|
url_path => $url,
|
||||||
|
unknown_status => $self->{unknown_http_status},
|
||||||
|
warning_status => $self->{warning_http_status},
|
||||||
|
critical_status => $self->{critical_http_status}
|
||||||
|
);
|
||||||
if (!defined($content) || $content eq '') {
|
if (!defined($content) || $content eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
|
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
@ -31,9 +31,9 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"command:s" => { name => 'command' },
|
'command:s' => { name => 'command' },
|
||||||
"arg:s@" => { name => 'arg' },
|
'arg:s@' => { name => 'arg' },
|
||||||
"sanitize-message:s" => { name => 'sanitize_message' },
|
'sanitize-message:s' => { name => 'sanitize_message' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -44,7 +44,7 @@ sub check_options {
|
|||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '') {
|
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => "Please set --command option");
|
$self->{output}->add_option_msg(short_msg => 'Please set --command option');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,12 +30,12 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
'query' => 'apps::protocols::nrpe::mode::query',
|
'query' => 'apps::protocols::nrpe::mode::query'
|
||||||
);
|
};
|
||||||
|
|
||||||
$self->{custom_modes}{nrpe} = 'apps::protocols::nrpe::custom::nrpe';
|
$self->{custom_modes}->{nrpe} = 'apps::protocols::nrpe::custom::nrpe';
|
||||||
$self->{custom_modes}{nsclient} = 'apps::protocols::nrpe::custom::nsclient';
|
$self->{custom_modes}->{nsclient} = 'apps::protocols::nrpe::custom::nsclient';
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,27 +77,27 @@ sub set_defaults {}
|
|||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef;
|
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
|
||||||
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
|
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
|
||||||
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
|
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
|
||||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30;
|
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30;
|
||||||
$self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef;
|
$self->{ssl_opt} = (defined($self->{option_results}->{ssl_opt})) ? $self->{option_results}->{ssl_opt} : undef;
|
||||||
$self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : undef;
|
$self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : '';
|
||||||
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : undef;
|
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : '';
|
||||||
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300' ;
|
$self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300' ;
|
||||||
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
$self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : '';
|
||||||
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
$self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : '';
|
||||||
|
|
||||||
if (!defined($self->{hostname}) || $self->{hostname} eq '') {
|
if ($self->{hostname} eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
|
$self->{output}->add_option_msg(short_msg => 'Need to specify --hostname option.');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
if (!defined($self->{api_username}) || $self->{api_username} eq '') {
|
if ($self->{api_username} eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify --api-username option.");
|
$self->{output}->add_option_msg(short_msg => 'Need to specify --api-username option.');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
if (!defined($self->{api_password}) || $self->{api_password} eq '') {
|
if ($self->{api_password} eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify --api-password option.");
|
$self->{output}->add_option_msg(short_msg => 'Need to specify --api-password option.');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,14 +147,15 @@ sub authenticate {
|
|||||||
my $content = $self->{http}->request(
|
my $content = $self->{http}->request(
|
||||||
method => 'POST', query_form_post => $post_data,
|
method => 'POST', query_form_post => $post_data,
|
||||||
url_path => '/api/login',
|
url_path => '/api/login',
|
||||||
warning_status => '', unknown_status => '', critical_status => '%{http_code} < 200 or %{http_code} >= 300'
|
unknown_status => $self->{unknown_http_status},
|
||||||
|
warning_status => $self->{warning_http_status},
|
||||||
|
critical_status => $self->{critical_http_status}
|
||||||
);
|
);
|
||||||
|
|
||||||
my $header = $self->{http}->get_header(name => 'Set-Cookie');
|
my $header = $self->{http}->get_header(name => 'Set-Cookie');
|
||||||
if (defined ($header) && $header =~ /(?:^| ).AspNetCore.Cookies=([^;]+);.*/) {
|
if (defined ($header) && $header =~ /(?:^| ).AspNetCore.Cookies=([^;]+);.*/) {
|
||||||
$cookie = $1;
|
$cookie = $1;
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->output_add(long_msg => $content, debug => 1);
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Error retrieving cookie");
|
$self->{output}->add_option_msg(short_msg => "Error retrieving cookie");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
@ -184,7 +185,7 @@ sub request_api {
|
|||||||
%options,
|
%options,
|
||||||
unknown_status => $self->{unknown_http_status},
|
unknown_status => $self->{unknown_http_status},
|
||||||
warning_status => $self->{warning_http_status},
|
warning_status => $self->{warning_http_status},
|
||||||
critical_status => $self->{critical_http_status},
|
critical_status => $self->{critical_http_status}
|
||||||
);
|
);
|
||||||
|
|
||||||
# Some content may be strangely returned, for example :
|
# Some content may be strangely returned, for example :
|
||||||
@ -201,12 +202,10 @@ sub request_api {
|
|||||||
$decoded = JSON::XS->new->decode($content);
|
$decoded = JSON::XS->new->decode($content);
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$self->{output}->output_add(long_msg => $content, debug => 1);
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
if (!defined($decoded)) {
|
if (!defined($decoded)) {
|
||||||
$self->{output}->output_add(long_msg => $decoded, debug => 1);
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Error while retrieving data (add --debug option for detailed message)");
|
$self->{output}->add_option_msg(short_msg => "Error while retrieving data (add --debug option for detailed message)");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||||
|
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
@ -56,14 +56,16 @@ sub set_counters {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{extension} = [
|
$self->{maps_counters}->{extension} = [
|
||||||
{ label => 'status', threshold => 0, set => {
|
{ label => 'status', type => 2, set => {
|
||||||
key_values => [ { name => 'extension' }, { name => 'registered' }, { name => 'dnd' }, { name => 'profile' }, { name => 'status' }, { name => 'duration' } ],
|
key_values => [
|
||||||
closure_custom_calc => \&catalog_status_calc,
|
{ name => 'extension' }, { name => 'registered' }, { name => 'dnd' },
|
||||||
|
{ name => 'profile' }, { name => 'status' }, { name => 'duration' }
|
||||||
|
],
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,25 +80,13 @@ sub new {
|
|||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
'filter-extension:s' => { name => 'filter_extension' }
|
||||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
|
||||||
'critical-status:s' => { name => 'critical_status', default => '' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
|
|
||||||
$self->change_macros(macros => [
|
|
||||||
'warning_status', 'critical_status', 'unknown_status',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -116,6 +106,12 @@ sub manage_selection {
|
|||||||
my $extension = $options{custom}->api_extension_list();
|
my $extension = $options{custom}->api_extension_list();
|
||||||
$self->{extension} = {};
|
$self->{extension} = {};
|
||||||
foreach my $item (@$extension) {
|
foreach my $item (@$extension) {
|
||||||
|
if (defined($self->{option_results}->{filter_extension}) && $self->{option_results}->{filter_extension} ne '' &&
|
||||||
|
$item->{_str} !~ /$self->{option_results}->{filter_extension}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping extension '" . $item->{_str} . "': no matching filter.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
$self->{extension}->{$item->{_str}} = {
|
$self->{extension}->{$item->{_str}} = {
|
||||||
extension => $item->{_str},
|
extension => $item->{_str},
|
||||||
registered => $item->{IsRegistered} ? 'true' : 'false',
|
registered => $item->{IsRegistered} ? 'true' : 'false',
|
||||||
@ -138,6 +134,10 @@ Check extentions status
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-extension>
|
||||||
|
|
||||||
|
Filter extension.
|
||||||
|
|
||||||
=item B<--unknown-status>
|
=item B<--unknown-status>
|
||||||
|
|
||||||
Set unknown threshold for status.
|
Set unknown threshold for status.
|
||||||
|
@ -24,14 +24,14 @@ use base qw(centreon::plugins::templates::counter);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
||||||
|
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $msg = '';
|
my $msg = '';
|
||||||
if ($self->{result_values}->{service} !~ /^Has[A-Z]/) {
|
if ($self->{result_values}->{service} !~ /^Has[A-Z]/) {
|
||||||
$msg .= 'error ';
|
$msg .= 'error';
|
||||||
}
|
}
|
||||||
$msg .= ': ' . $self->{result_values}->{error};
|
$msg .= ': ' . $self->{result_values}->{error};
|
||||||
return $msg;
|
return $msg;
|
||||||
@ -48,33 +48,30 @@ sub set_counters {
|
|||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'calls-active', nlabel => 'system.calls.active.current', set => {
|
{ label => 'calls-active', nlabel => 'system.calls.active.current', set => {
|
||||||
key_values => [ { name => 'calls_active' } ],
|
key_values => [ { name => 'calls_active' } ],
|
||||||
output_template => 'calls active : %s',
|
output_template => 'calls active: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'calls_active', template => '%s', value => 'calls_active',
|
{ label => 'calls_active', template => '%s', min => 0 }
|
||||||
min => 0 },
|
]
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'extensions-registered', nlabel => 'system.extensions.registered.current', set => {
|
{ label => 'extensions-registered', nlabel => 'system.extensions.registered.current', set => {
|
||||||
key_values => [ { name => 'extensions_registered' } ],
|
key_values => [ { name => 'extensions_registered' } ],
|
||||||
output_template => 'extensions registered : %s',
|
output_template => 'extensions registered: %s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'extensions_registered', template => '%s', value => 'extensions_registered',
|
{ label => 'extensions_registered', template => '%s', min => 0 }
|
||||||
min => 0 },
|
]
|
||||||
],
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{service} = [
|
$self->{maps_counters}->{service} = [
|
||||||
{ label => 'status', threshold => 0, set => {
|
{ label => 'status', type => 2, critical_default => '%{error} =~ /true/', set => {
|
||||||
key_values => [ { name => 'error' }, { name => 'service' } ],
|
key_values => [ { name => 'error' }, { name => 'service' } ],
|
||||||
closure_custom_calc => \&catalog_status_calc,
|
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,25 +86,12 @@ sub new {
|
|||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"unknown-status:s" => { name => 'unknown_status', default => '' },
|
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{error} =~ /true/' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
|
|
||||||
$self->change_macros(macros => [
|
|
||||||
'warning_status', 'critical_status', 'unknown_status',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
'extension' => 'apps::voip::3cx::restapi::mode::extension',
|
'extension' => 'apps::voip::3cx::restapi::mode::extension',
|
||||||
'system' => 'apps::voip::3cx::restapi::mode::system',
|
'system' => 'apps::voip::3cx::restapi::mode::system'
|
||||||
);
|
};
|
||||||
|
|
||||||
$self->{custom_modes}{api} = 'apps::voip::3cx::restapi::custom::api';
|
$self->{custom_modes}->{api} = 'apps::voip::3cx::restapi::custom::api';
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ sub new {
|
|||||||
|
|
||||||
if (!defined($options{noptions}) || $options{noptions} != 1) {
|
if (!defined($options{noptions}) || $options{noptions} != 1) {
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'curl-opt:s@' => { name => 'curl_opt' },
|
'curl-opt:s@' => { name => 'curl_opt' }
|
||||||
});
|
});
|
||||||
$options{options}->add_help(package => __PACKAGE__, sections => 'BACKEND CURL OPTIONS', once => 1);
|
$options{options}->add_help(package => __PACKAGE__, sections => 'BACKEND CURL OPTIONS', once => 1);
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ my $http_code_explained = {
|
|||||||
502 => 'Bad Gateway',
|
502 => 'Bad Gateway',
|
||||||
503 => 'Service Unavailable',
|
503 => 'Service Unavailable',
|
||||||
504 => 'Gateway Timeout',
|
504 => 'Gateway Timeout',
|
||||||
505 => 'HTTP Version Not Supported',
|
505 => 'HTTP Version Not Supported'
|
||||||
};
|
};
|
||||||
|
|
||||||
sub cb_debug {
|
sub cb_debug {
|
||||||
@ -231,17 +231,38 @@ sub set_proxy {
|
|||||||
sub set_extra_curl_opt {
|
sub set_extra_curl_opt {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $fields = { key => '', value => '' };
|
my $entries = {};
|
||||||
foreach (@{$options{request}->{curl_opt}}) {
|
foreach (@{$options{request}->{curl_opt}}) {
|
||||||
($fields->{key}, $fields->{value}) = split /=>/;
|
my ($key, $value) = split /=>/;
|
||||||
foreach my $label ('key', 'value') {
|
$key = centreon::plugins::misc::trim($key);
|
||||||
$fields->{$label} = centreon::plugins::misc::trim($fields->{$label});
|
|
||||||
if ($fields->{$label} =~ /^CURLOPT|CURL/) {
|
if (!defined($entries->{$key})) {
|
||||||
$fields->{$label} = $self->{constant_cb}->(name => $fields->{$label});
|
$entries->{$key} = { val => [], force_array => 0 };
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->curl_setopt(option => $fields->{key}, parameter => $fields->{value});
|
$value = centreon::plugins::misc::trim($value);
|
||||||
|
if ($value =~ /^\[(.*)\]$/) {
|
||||||
|
$entries->{$key}->{force_array} = 1;
|
||||||
|
$value = centreon::plugins::misc::trim($1);
|
||||||
|
}
|
||||||
|
if ($value =~ /^CURLOPT|CURL/) {
|
||||||
|
$value = $self->{constant_cb}->(name => $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
push @{$entries->{$key}->{val}}, $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (keys %$entries) {
|
||||||
|
my $key = $_;
|
||||||
|
if (/^CURLOPT|CURL/) {
|
||||||
|
$key = $self->{constant_cb}->(name => $_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($entries->{$_}->{force_array} == 1 || scalar(@{$entries->{$_}->{val}}) > 1) {
|
||||||
|
$self->curl_setopt(option => $key, parameter => $entries->{$_}->{val});
|
||||||
|
} else {
|
||||||
|
$self->curl_setopt(option => $key, parameter => pop @{$entries->{$_}->{val}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,18 +24,25 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_pdisk_state %map_pdisk_smartstate);
|
use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_pdisk_state %map_pdisk_smartstate);
|
||||||
|
|
||||||
|
my $map_pdisk_sparestate = {
|
||||||
|
1 => '', # notASpare
|
||||||
|
2 => 'SpareDedicated', # dedicatedHotSpare
|
||||||
|
3 => 'SpareGlobal' # globalHotSpare
|
||||||
|
};
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
physicalDiskState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.4', map => \%map_pdisk_state },
|
physicalDiskState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.4', map => \%map_pdisk_state },
|
||||||
|
physicalDiskSpareState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.22', map => $map_pdisk_sparestate },
|
||||||
physicalDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.24', map => \%map_status },
|
physicalDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.24', map => \%map_status },
|
||||||
physicalDiskSmartAlertIndication => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.31', map => \%map_pdisk_smartstate },
|
physicalDiskSmartAlertIndication => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.31', map => \%map_pdisk_smartstate },
|
||||||
physicalDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.54' },
|
physicalDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.54' }
|
||||||
};
|
};
|
||||||
my $oid_physicalDiskTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1';
|
my $oid_physicalDiskTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1';
|
||||||
|
|
||||||
sub load {
|
sub load {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
foreach (keys %{$mapping}) {
|
foreach (keys %$mapping) {
|
||||||
push @{$self->{request}}, { oid => $mapping->{$_}->{oid} };
|
push @{$self->{request}}, { oid => $mapping->{$_}->{oid} };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,27 +67,41 @@ sub check {
|
|||||||
next if ($self->check_filter(section => 'pdisk', instance => $instance));
|
next if ($self->check_filter(section => 'pdisk', instance => $instance));
|
||||||
$self->{components}->{pdisk}->{total}++;
|
$self->{components}->{pdisk}->{total}++;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => sprintf("physical disk '%s' status is '%s' [instance = %s] [state = %s] [smart alert = %s]",
|
if ($result->{physicalDiskState} eq 'ready') {
|
||||||
|
$result->{physicalDiskState} .= $result->{physicalDiskSpareState};
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"physical disk '%s' status is '%s' [instance = %s] [state = %s] [smart alert = %s]",
|
||||||
$result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus}, $instance,
|
$result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus}, $instance,
|
||||||
$result->{physicalDiskState}, $result->{physicalDiskSmartAlertIndication}));
|
$result->{physicalDiskState}, $result->{physicalDiskSmartAlertIndication}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
my $exit = $self->get_severity(section => 'pdisk.state', value => $result->{physicalDiskState});
|
my $exit = $self->get_severity(section => 'pdisk.state', value => $result->{physicalDiskState});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("physical disk '%s' state is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskState}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("physical disk '%s' state is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskState})
|
||||||
|
);
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
$exit = $self->get_severity(label => 'default.status', section => 'pdisk.status', value => $result->{physicalDiskComponentStatus});
|
$exit = $self->get_severity(label => 'default.status', section => 'pdisk.status', value => $result->{physicalDiskComponentStatus});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("physical disk '%s' status is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("physical disk '%s' status is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$exit = $self->get_severity(section => 'pdisk.smartalert', value => $result->{physicalDiskSmartAlertIndication});
|
$exit = $self->get_severity(section => 'pdisk.smartalert', value => $result->{physicalDiskSmartAlertIndication});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(severity => $exit,
|
$self->{output}->output_add(
|
||||||
short_msg => sprintf("physical disk '%s' smart alert predictive failure is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskSmartAlertIndication}));
|
severity => $exit,
|
||||||
|
short_msg => sprintf("physical disk '%s' smart alert predictive failure is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskSmartAlertIndication})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,9 @@ sub set_system {
|
|||||||
],
|
],
|
||||||
'pdisk.state' => [
|
'pdisk.state' => [
|
||||||
['unknown', 'UNKNOWN'],
|
['unknown', 'UNKNOWN'],
|
||||||
['ready', 'OK'],
|
['readySpareDedicated', 'OK'],
|
||||||
|
['readySpareGlobal', 'OK'],
|
||||||
|
['ready', 'WARNING'],
|
||||||
['online', 'OK'],
|
['online', 'OK'],
|
||||||
['foreign', 'OK'],
|
['foreign', 'OK'],
|
||||||
['offline', 'WARNING'],
|
['offline', 'WARNING'],
|
||||||
|
@ -30,10 +30,10 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
'global-status' => 'hardware::server::dell::idrac::snmp::mode::globalstatus',
|
'global-status' => 'hardware::server::dell::idrac::snmp::mode::globalstatus',
|
||||||
'hardware' => 'hardware::server::dell::idrac::snmp::mode::hardware',
|
'hardware' => 'hardware::server::dell::idrac::snmp::mode::hardware'
|
||||||
);
|
};
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user