InfluxDB, allow to select custom field

This commit is contained in:
CPbN 2019-10-24 17:23:44 +02:00
commit 154f96cf62
550 changed files with 18293 additions and 6462 deletions

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'dcdiag' => 'apps::activedirectory::local::mode::dcdiag',
'dfsr-backlog' => 'apps::activedirectory::local::mode::dfsrbacklog',
'netdom' => 'apps::activedirectory::local::mode::netdom',
);
'dcdiag' => 'apps::activedirectory::local::mode::dcdiag',
'dfsr-backlog' => 'apps::activedirectory::local::mode::dfsrbacklog',
'netdom' => 'apps::activedirectory::local::mode::netdom',
);
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'dcdiag' => 'apps::activedirectory::wsman::mode::dcdiag',
);
'dcdiag' => 'apps::activedirectory::wsman::mode::dcdiag',
);
return $self;
}

View File

@ -118,28 +118,27 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options' },
"warning-engine-status:s" => { name => 'warning_engine_status', default => '' },
"critical-engine-status:s" => { name => 'critical_engine_status', default => '%{last_engine_version} ne %{current_engine_version}' },
"warning-maindb-status:s" => { name => 'warning_maindb_status', default => '' },
"critical-maindb-status:s" => { name => 'critical_maindb_status', default => '%{last_maindb_version} ne %{current_maindb_version}' },
"warning-dailydb-status:s" => { name => 'warning_dailydb_status', default => '' },
"critical-dailydb-status:s" => { name => 'critical_dailydb_status', default => '%{last_dailydb_version} ne %{current_dailydb_version} || %{current_dailydb_timediff} > 432000' },
"nameservers:s@" => { name => 'nameservers' },
"maindb-file:s" => { name => 'maindb_file', default => '/var/lib/clamav/main.cvd' },
"dailydb-file:s" => { name => 'dailydb_file', default => '/var/lib/clamav/daily.cvd' },
});
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'remote' => { name => 'remote' },
'ssh-option:s@' => { name => 'ssh_option' },
'ssh-path:s' => { name => 'ssh_path' },
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 30 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options' },
'warning-engine-status:s' => { name => 'warning_engine_status', default => '' },
'critical-engine-status:s' => { name => 'critical_engine_status', default => '%{last_engine_version} ne %{current_engine_version}' },
'warning-maindb-status:s' => { name => 'warning_maindb_status', default => '' },
'critical-maindb-status:s' => { name => 'critical_maindb_status', default => '%{last_maindb_version} ne %{current_maindb_version}' },
'warning-dailydb-status:s' => { name => 'warning_dailydb_status', default => '' },
'critical-dailydb-status:s' => { name => 'critical_dailydb_status', default => '%{last_dailydb_version} ne %{current_dailydb_version} || %{current_dailydb_timediff} > 432000' },
'nameservers:s@' => { name => 'nameservers' },
'maindb-file:s' => { name => 'maindb_file', default => '/var/lib/clamav/main.cvd' },
'dailydb-file:s' => { name => 'dailydb_file', default => '/var/lib/clamav/daily.cvd' },
});
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'update-status' => 'apps::antivirus::clamav::local::mode::updatestatus',
);
'update-status' => 'apps::antivirus::clamav::local::mode::updatestatus',
);
return $self;
}

View File

@ -32,13 +32,13 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'deployment' => 'apps::antivirus::kaspersky::snmp::mode::deployment',
'events' => 'apps::antivirus::kaspersky::snmp::mode::events',
'full-scan' => 'apps::antivirus::kaspersky::snmp::mode::fullscan',
'logical-network' => 'apps::antivirus::kaspersky::snmp::mode::logicalnetwork',
'protection' => 'apps::antivirus::kaspersky::snmp::mode::protection',
'updates' => 'apps::antivirus::kaspersky::snmp::mode::updates',
);
'deployment' => 'apps::antivirus::kaspersky::snmp::mode::deployment',
'events' => 'apps::antivirus::kaspersky::snmp::mode::events',
'full-scan' => 'apps::antivirus::kaspersky::snmp::mode::fullscan',
'logical-network' => 'apps::antivirus::kaspersky::snmp::mode::logicalnetwork',
'protection' => 'apps::antivirus::kaspersky::snmp::mode::protection',
'updates' => 'apps::antivirus::kaspersky::snmp::mode::updates',
);
return $self;
}

View File

@ -32,14 +32,14 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'clients' => 'apps::antivirus::mcafee::webgateway::snmp::mode::clients',
'connections' => 'apps::antivirus::mcafee::webgateway::snmp::mode::connections',
'detections' => 'apps::antivirus::mcafee::webgateway::snmp::mode::detections',
'ftp-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::ftpstatistics',
'http-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpstatistics',
'https-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpsstatistics',
'versions' => 'apps::antivirus::mcafee::webgateway::snmp::mode::versions',
);
'clients' => 'apps::antivirus::mcafee::webgateway::snmp::mode::clients',
'connections' => 'apps::antivirus::mcafee::webgateway::snmp::mode::connections',
'detections' => 'apps::antivirus::mcafee::webgateway::snmp::mode::detections',
'ftp-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::ftpstatistics',
'http-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpstatistics',
'https-statistics' => 'apps::antivirus::mcafee::webgateway::snmp::mode::httpsstatistics',
'versions' => 'apps::antivirus::mcafee::webgateway::snmp::mode::versions',
);
return $self;
}

View File

@ -40,16 +40,16 @@ sub new {
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 50 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '' },
'hostname:s' => { name => 'hostname' },
'remote' => { name => 'remote' },
'ssh-option:s@' => { name => 'ssh_option' },
'ssh-path:s' => { name => 'ssh_path' },
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 50 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command', default => 'ANSIBLE_LOAD_CALLBACK_PLUGINS=true ANSIBLE_STDOUT_CALLBACK=json ansible' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '' },
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'CLI OPTIONS', once => 1);
@ -99,7 +99,8 @@ sub execute {
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $options{cmd_options}
command_options => $options{cmd_options},
no_errors => { 4 => 1 }
);
my $raw_results;

View File

@ -32,8 +32,8 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"host-pattern:s" => { name => 'host_pattern', default => 'all' },
"prettify" => { name => 'prettify' },
'host-pattern:s' => { name => 'host_pattern', default => 'all' },
'prettify' => { name => 'prettify' },
});
return $self;

View File

@ -40,15 +40,15 @@ sub new {
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
"host:s" => { name => 'host' },
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"timeout:s" => { name => 'timeout', default => 50 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'tower-cli' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '' },
"proxyurl:s" => { name => 'proxyurl' },
'host:s' => { name => 'host' },
'username:s' => { name => 'username' },
'password:s' => { name => 'password' },
'timeout:s' => { name => 'timeout', default => 50 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command', default => 'tower-cli' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '' },
'proxyurl:s' => { name => 'proxyurl' },
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'TOWERCLI OPTIONS', once => 1);

View File

@ -32,9 +32,9 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"group" => { name => 'group' },
"inventory" => { name => 'inventory' },
"prettify" => { name => 'prettify' },
'group' => { name => 'group' },
'inventory' => { name => 'inventory' },
'prettify' => { name => 'prettify' },
});
return $self;

View File

@ -24,7 +24,6 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
sub custom_status_threshold {
@ -110,6 +109,7 @@ sub new {
$options{options}->add_options(arguments => {
'filter-server-name:s' => { name => 'filter_server_name' },
'filter-type:s' => { name => 'filter_type' },
'filter-start-time:s' => { name => 'filter_start_time' },
'filter-end-time:s' => { name => 'filter_end_time', default => 86400 },
'ok-status:s' => { name => 'ok_status', default => '%{status} == 1' },
'warning-status:s' => { name => 'warning_status', default => '' },

View File

@ -0,0 +1,270 @@
#
# Copyright 2019 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::backup::netapp::snapcenter::restapi::custom::api;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
use centreon::plugins::http;
use centreon::plugins::statefile;
use JSON::XS;
use Digest::MD5 qw(md5_hex);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
if (!defined($options{output})) {
print "Class Custom: Need to specify 'output' argument.\n";
exit 3;
}
if (!defined($options{options})) {
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
$options{output}->option_exit();
}
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port'},
'proto:s' => { name => 'proto' },
'api-username:s' => { name => 'api_username' },
'api-password:s' => { name => 'api_password' },
'api-version:s' => { name => 'api_version' },
'timeout:s' => { name => 'timeout' },
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
$self->{output} = $options{output};
$self->{mode} = $options{mode};
$self->{http} = centreon::plugins::http->new(%options);
$self->{cache} = centreon::plugins::statefile->new(%options);
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{option_results} = $options{option_results};
}
sub set_defaults {
my ($self, %options) = @_;
foreach (keys %{$options{default}}) {
if ($_ eq $self->{mode}) {
for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) {
foreach my $opt (keys %{$options{default}->{$_}[$i]}) {
if (!defined($self->{option_results}->{$opt}[$i])) {
$self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt};
}
}
}
}
}
}
sub check_options {
my ($self, %options) = @_;
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : undef;
$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->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30;
$self->{api_username} = (defined($self->{option_results}->{api_username})) ? $self->{option_results}->{api_username} : undef;
$self->{api_password} = (defined($self->{option_results}->{api_password})) ? $self->{option_results}->{api_password} : undef;
$self->{api_version} = (defined($self->{option_results}->{api_version}) && $self->{option_results}->{api_version} ne '') ? $self->{option_results}->{api_version} : '4.1.1';
if (!defined($self->{hostname}) || $self->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --hostname option.");
$self->{output}->option_exit();
}
if (!defined($self->{api_username}) || $self->{api_username} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --api-username option.");
$self->{output}->option_exit();
}
if (!defined($self->{api_password}) || $self->{api_password} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --api-password option.");
$self->{output}->option_exit();
}
$self->{cache}->check_options(option_results => $self->{option_results});
return 0;
}
sub build_options_for_httplib {
my ($self, %options) = @_;
$self->{option_results}->{hostname} = $self->{hostname};
$self->{option_results}->{port} = $self->{port};
$self->{option_results}->{proto} = $self->{proto};
$self->{option_results}->{timeout} = $self->{timeout};
}
sub settings {
my ($self, %options) = @_;
$self->build_options_for_httplib();
$self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8');
$self->{http}->add_header(key => 'Accept', value => 'application/json;charset=UTF-8');
if (defined($self->{token})) {
$self->{http}->add_header(key => 'Token', value => $self->{token});
}
$self->{http}->set_options(%{$self->{option_results}});
}
sub json_decode {
my ($self, %options) = @_;
my $decoded;
eval {
$decoded = JSON::XS->new->utf8->decode($options{content});
};
if ($@) {
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
$self->{output}->option_exit();
}
return $decoded;
}
sub clean_token {
my ($self, %options) = @_;
my $datas = { last_timestamp => time() };
$options{statefile}->write(data => $datas);
$self->{token} = undef;
}
sub authenticate {
my ($self, %options) = @_;
my $has_cache_file = $options{statefile}->read(statefile => 'netapp_snapcenter_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username}));
my $token = $options{statefile}->get(name => 'token');
if ($has_cache_file == 0 || !defined($token)) {
my $login = { UserOperationContext => { User => { Name => $self->{api_username}, Passphrase => $self->{api_password} } } };
my $post_json = JSON::XS->new->utf8->encode($login);
my $content = $self->{http}->request(
method => 'POST',
url_path => '/api/' . $self->{api_version} . '/auth/login?TokenNeverExpires=false',
query_form_post => $post_json,
warning_status => '', unknown_status => '', critical_status => '',
);
if ($self->{http}->get_code() != 200) {
$self->{output}->add_option_msg(short_msg => "Login error [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
$self->{output}->option_exit();
}
my $decoded = $self->json_decode(content => $content);
if (defined($decoded) && defined($decoded->{User}->{Token})) {
$token = $decoded->{User}->{Token};
} else {
$self->{output}->add_option_msg(short_msg => "Error retrieving token");
$self->{output}->option_exit();
}
$self->{http}->add_header(key => 'Token', value => $token);
my $datas = { last_timestamp => time(), token => $token };
$options{statefile}->write(data => $datas);
}
$self->{token} = $token;
}
sub request_api {
my ($self, %options) = @_;
$self->settings();
if (!defined($self->{token})) {
$self->authenticate(statefile => $self->{cache});
}
my $content = $self->{http}->request(
url_path => '/api/' . $self->{api_version} . '/' . $options{endpoint},
warning_status => '', unknown_status => '', critical_status => ''
);
# Maybe there is an issue with the token. So we retry.
if ($self->{http}->get_code() != 200) {
$self->clean_token(statefile => $self->{cache});
$self->authenticate(statefile => $self->{cache});
$content = $self->{http}->request(
url_path => '/api/' . $self->{api_version} . '/' . $options{endpoint},
warning_status => '', unknown_status => '', critical_status => ''
);
}
my $decoded = $self->json_decode(content => $content);
if (!defined($decoded)) {
$self->{output}->add_option_msg(short_msg => "Error while retrieving data (add --debug option for detailed message)");
$self->{output}->option_exit();
}
return $decoded;
}
1;
__END__
=head1 NAME
Netapp SnapCenter Rest API
=head1 REST API OPTIONS
=over 8
=item B<--hostname>
Set hostname or IP of vsca.
=item B<--port>
Set port (Default: '443').
=item B<--proto>
Specify https if needed (Default: 'https').
=item B<--api-username>
Set username.
=item B<--api-password>
Set password.
=item B<--timeout>
Threshold for HTTP timeout (Default: '30').
=back
=cut

View File

@ -0,0 +1,277 @@
#
# Copyright 2019 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::backup::netapp::snapcenter::restapi::mode::jobs;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf('status : %s [type: %s] [end time: %s]: %s',
$self->{result_values}->{status},
$self->{result_values}->{type},
$self->{result_values}->{end_time},
$self->{result_values}->{error},
);
return $msg;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'jobs', type => 2, message_multiple => '0 problem(s) detected', display_counter_problem => { nlabel => 'alerts.problems.current.count', min => 0 },
group => [ { name => 'job', , cb_prefix_output => 'prefix_job_output', skipped_code => { -11 => 1 } } ]
}
];
$self->{maps_counters}->{global} = [
{ label => 'total', nlabel => 'jobs.total.count', set => {
key_values => [ { name => 'total' } ],
output_template => 'total jobs : %s',
perfdatas => [
{ label => 'total', value => 'total_absolute', template => '%s', min => 0 },
],
}
},
];
$self->{maps_counters}->{job} = [
{ label => 'status', threshold => 0, set => {
key_values => [
{ name => 'status' }, { name => 'display' },
{ name => 'type' }, { name => 'error' },
{ name => 'elapsed_time' }, { name => 'end_time' }
],
closure_custom_calc => \&catalog_status_calc,
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
}
sub prefix_job_output {
my ($self, %options) = @_;
return "job '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'filter-type:s' => { name => 'filter_type' },
'filter-start-time:s' => { name => 'filter_start_time' },
'filter-end-time:s' => { name => 'filter_end_time', default => 86400 },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '%{status} =~ /warning/i' },
'critical-status:s' => { name => 'critical_status', default => '%{status} =~ /failed/i' },
'timezone:s' => { name => 'timezone' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
centreon::plugins::misc::mymodule_load(
output => $self->{output}, module => 'DateTime',
error_msg => "Cannot load module 'DateTime'."
);
$self->change_macros(macros => [
'warning_status', 'critical_status', 'unknown_status',
]);
if (defined($self->{option_results}->{timezone}) && $self->{option_results}->{timezone} ne '') {
$ENV{TZ} = $self->{option_results}->{timezone};
}
}
sub date2ts {
my ($self, %options) = @_;
return undef if (!defined($options{date}) || $options{date} eq '');
if ($options{date} !~ /^(\d{1,2})\/(\d{1,2})\/(\d{4})\s+(\d{1,2}):(\d{1,2}):(\d{2})\s+(AM|PM)/i) {
$self->{output}->add_option_msg(short_msg => "unknown date format: $options{date}");
$self->{output}->option_exit();
}
my $hour = $4;
$hour += 12 if ($7 eq 'PM');
my $dt = DateTime->new(
year => $3,
month => $1,
day => $2,
hour => $4,
minute => $5,
second => $6
);
return $dt->epoch();
}
sub manage_selection {
my ($self, %options) = @_;
my $results = $options{custom}->request_api(endpoint => 'jobs');
my $map_status = {
-1 => 'None', 0 => 'running', 1 => 'warning', 2 => 'failed', 3 => 'completed',
4 => 'retry', 5 => 'queued', 6 => 'validating',
7 => 'completedWithVerificationPending', 8 => 'canceled',
9 => 'completedWithRMANCatalogingPending', 10 => 'completedWithVerificationAndRMANCatalogingPending',
11 => 'completedPrimaryBackup', 12 => 'transferredBackupToVault',
13 => 'cancelling',
};
my $map_type = {
-1 => 'None', 0 => 'backup', 1 => 'restore', 2 => 'replication', 3 => 'retention',
4 => 'verification', 5 => 'plug-in installation', 6 => 'clone',
7 => 'delete clone', 8 => 'clone life cycle',
9 => 'ressource group', 10 => 'host', 11 => 'policy', 12 => 'discovery',
13 => 'attach policy', 14 => 'detach policy', 15 => 'storage connection',
16 => 'license check', 17 => 'mount backup', 18 => 'unmount backup',
19 => 'register mount', 20 => 'get mount', 21 => 'delete mount',
22 => 'provision', 23 => 'maintenance', 24 => 'plugin',
25 => 'remote plugin uninstallation', 26 => 'protect snapCenter repository',
27 => 'configure resources', 28 => 'catalog backup', 29 => 'uncatalog backup',
30 => 'resource', 32 => 'apply protection', 33 => 'catalog', 34 => 'plugin modify',
35 => 'repository management', 36 => 'remove protection', 37 => 'clone split',
38 => 'server management', 39 => 'import protection', 40 => 'guest file restore',
41 => 'extend protection', 42 => 'purge jobs', 43 => 'assign assets',
};
$self->{global} = { total => 0 };
$self->{jobs}->{global} = { job => {} };
my $current_time = time();
foreach (@{$results->{Results}}) {
my $type = defined($_->{Type}) && defined($map_type->{$_->{Type}}) ? $map_type->{$_->{Type}} : 'unknown';
my $status = defined($_->{Status}) && defined($map_status->{$_->{Status}}) ? $map_status->{$_->{Status}} : 'unknown';
my $start_ts = $self->date2ts(date => $_->{StartTime});
my $end_ts = $self->date2ts(date => $_->{EndTime});
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$_->{Name} !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping job '" . $_->{Id} . "': no matching filter type.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
$type !~ /$self->{option_results}->{filter_type}/) {
$self->{output}->output_add(long_msg => "skipping job '" . $_->{Id} . "': no matching filter type.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_end_time}) && $self->{option_results}->{filter_end_time} =~ /[0-9]+/ &&
(!defined($end_ts) || $end_ts < ($current_time - $self->{option_results}->{filter_end_time}))) {
$self->{output}->output_add(long_msg => "skipping job '" . $_->{Id} . "': end time too old.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_start_time}) && $self->{option_results}->{filter_start_time} =~ /[0-9]+/ &&
(!defined($start_ts) || $start_ts < ($current_time - $self->{option_results}->{filter_start_time}))) {
$self->{output}->output_add(long_msg => "skipping job '" . $_->{Id} . "': start time too old.", debug => 1);
next;
}
my $error = defined($_->{Error}) && $_->{Error} ne '' ? $_->{Error} : 'no error';
$error =~ s/[\n\|]/ -- /msg;
$error =~ s/[\r]//msg;
my $elapsed_time = defined($start_ts) ? $current_time - $start_ts : -1;
$self->{jobs}->{global}->{job}->{$_->{Id}} = {
display => $_->{Name},
elapsed_time => $elapsed_time,
status => $status,
type => $type,
end_time => defined($_->{EndTime}) && $_->{EndTime} ne '' ? $_->{EndTime} : -1,
error => $error,
};
$self->{global}->{total}++;
}
}
1;
__END__
=head1 MODE
Check jobs status.
=over 8
=item B<--filter-name>
Filter job name (can be a regexp).
=item B<--filter-type>
Filter job type (can be a regexp).
=item B<--filter-start-time>
Filter job with start time greater than current time less value in seconds.
=item B<--filter-end-time>
Filter job with end time greater than current time less value in seconds (Default: 86400).
=item B<--timezone>
Set timezone (If not set, we use current server execution timezone).
=item B<--unknown-status>
Set unknown threshold for status.
Can used special variables like: %{display}, %{status}, %{type}
=item B<--warning-status>
Set warning threshold for status (Default: '%{status} =~ /warning/i').
Can used special variables like: %{display}, %{status}, %{type}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} =~ /failed/i').
Can used special variables like: %{display}, %{status}, %{type}
=item B<--warning-total>
Set warning threshold for total jobs.
=item B<--critical-total>
Set critical threshold for total jobs.
=back
=cut

View File

@ -0,0 +1,54 @@
#
# Copyright 2019 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::backup::netapp::snapcenter::restapi::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_custom);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'jobs' => 'apps::backup::netapp::snapcenter::restapi::mode::jobs',
);
$self->{custom_modes}{api} = 'apps::backup::netapp::snapcenter::restapi::custom::api';
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Netapp SnapCenter through HTTP/REST API.
=over 8
=back
=cut

View File

@ -31,13 +31,13 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'dedup-status' => 'apps::backup::netbackup::local::mode::dedupstatus',
'drive-cleaning' => 'apps::backup::netbackup::local::mode::drivecleaning',
'drive-status' => 'apps::backup::netbackup::local::mode::drivestatus',
'job-status' => 'apps::backup::netbackup::local::mode::jobstatus',
'list-policies' => 'apps::backup::netbackup::local::mode::listpolicies',
'tape-usage' => 'apps::backup::netbackup::local::mode::tapeusage',
);
'dedup-status' => 'apps::backup::netbackup::local::mode::dedupstatus',
'drive-cleaning' => 'apps::backup::netbackup::local::mode::drivecleaning',
'drive-status' => 'apps::backup::netbackup::local::mode::drivestatus',
'job-status' => 'apps::backup::netbackup::local::mode::jobstatus',
'list-policies' => 'apps::backup::netbackup::local::mode::listpolicies',
'tape-usage' => 'apps::backup::netbackup::local::mode::tapeusage',
);
return $self;
}

View File

@ -154,25 +154,24 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'vcconfig' },
"command-path:s" => { name => 'command_path', default => '/quadstorvtl/bin' },
"command-options:s" => { name => 'command_options', default => '-l -v %{vtl_name}' },
"vtl-name:s" => { name => 'vtl_name' },
"filter-name:s" => { name => 'filter_name' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /active/i' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
});
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'remote' => { name => 'remote' },
'ssh-option:s@' => { name => 'ssh_option' },
'ssh-path:s' => { name => 'ssh_path' },
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
'timeout:s' => { name => 'timeout', default => 30 },
'sudo' => { name => 'sudo' },
'command:s' => { name => 'command', default => 'vcconfig' },
'command-path:s' => { name => 'command_path', default => '/quadstorvtl/bin' },
'command-options:s' => { name => 'command_options', default => '-l -v %{vtl_name}' },
'vtl-name:s' => { name => 'vtl_name' },
'filter-name:s' => { name => 'filter_name' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /active/i' },
'units:s' => { name => 'units', default => '%' },
'free' => { name => 'free' },
});
return $self;
}
@ -199,12 +198,15 @@ sub prefix_tape_output {
sub manage_selection {
my ($self, %options) = @_;
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my ($stdout) = centreon::plugins::misc::execute(
output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options}
);
$self->{global}->{count} = 0;
$self->{tape} = {};
#Pool Label Element Address Vtype WORM Size Used% Status

View File

@ -31,11 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'list-vtl' => 'apps::backup::quadstor::local::mode::listvtl',
'vtl-disk-usage' => 'apps::backup::quadstor::local::mode::vtldiskusage',
'vtl-job-status' => 'apps::backup::quadstor::local::mode::vtljobstatus',
'vtl-tape-usage' => 'apps::backup::quadstor::local::mode::vtltapeusage',
);
'list-vtl' => 'apps::backup::quadstor::local::mode::listvtl',
'vtl-disk-usage' => 'apps::backup::quadstor::local::mode::vtldiskusage',
'vtl-job-status' => 'apps::backup::quadstor::local::mode::vtljobstatus',
'vtl-tape-usage' => 'apps::backup::quadstor::local::mode::vtltapeusage',
);
return $self;
}

View File

@ -31,12 +31,12 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'actlog' => 'apps::backup::tsm::local::mode::actlog',
'drives' => 'apps::backup::tsm::local::mode::drives',
'nodes' => 'apps::backup::tsm::local::mode::nodes',
'sessions' => 'apps::backup::tsm::local::mode::sessions',
'volumes' => 'apps::backup::tsm::local::mode::volumes',
);
'actlog' => 'apps::backup::tsm::local::mode::actlog',
'drives' => 'apps::backup::tsm::local::mode::drives',
'nodes' => 'apps::backup::tsm::local::mode::nodes',
'sessions' => 'apps::backup::tsm::local::mode::sessions',
'volumes' => 'apps::backup::tsm::local::mode::volumes',
);
$self->{custom_modes}{api} = 'apps::backup::tsm::local::custom::api';
return $self;

View File

@ -32,8 +32,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'incoming' => 'apps::bluemind::mode::incoming',
);
'incoming' => 'apps::bluemind::mode::incoming',
);
return $self;
}

View File

@ -35,12 +35,12 @@ sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"centreon-config:s" => { name => 'centreon_config', default => '/etc/centreon/centreon-config.pm' },
"meta-id:s" => { name => 'meta_id', },
});
$options{options}->add_options(arguments => {
'centreon-config:s' => { name => 'centreon_config', default => '/etc/centreon/centreon-config.pm' },
'meta-id:s' => { name => 'meta_id' },
});
$self->{metric_selected} = {};
return $self;
}
@ -58,11 +58,13 @@ sub check_options {
sub execute_query {
my ($self, $db, $query) = @_;
my ($status, $stmt) = $db->query($query);
if ($status == -1) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => 'SQL Query error: ' . $query);
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => 'SQL Query error: ' . $query
);
$self->{output}->display();
$self->{output}->exit();
}
@ -71,10 +73,12 @@ sub execute_query {
sub select_by_regexp {
my ($self, %options) = @_;
my $count = 0;
my $stmt = $self->execute_query($self->{centreon_db_centstorage},
"SELECT metrics.metric_id, metrics.metric_name, metrics.current_value FROM index_data, metrics WHERE index_data.service_description LIKE " . $self->{centreon_db_centstorage}->quote($options{regexp_str}) . " AND index_data.id = metrics.index_id");
my $stmt = $self->execute_query(
$self->{centreon_db_centstorage},
"SELECT metrics.metric_id, metrics.metric_name, metrics.current_value FROM index_data, metrics WHERE index_data.service_description LIKE " . $self->{centreon_db_centstorage}->quote($options{regexp_str}) . " AND index_data.id = metrics.index_id"
);
while ((my $row = $stmt->fetchrow_hashref())) {
if ($options{metric_select} eq $row->{metric_name}) {
$self->{metric_selected}->{$row->{metric_id}} = $row->{current_value};
@ -82,8 +86,10 @@ sub select_by_regexp {
}
}
if ($count == 0) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => 'Cannot find a metric.');
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => 'Cannot find a metric.'
);
$self->{output}->display();
$self->{output}->exit();
}
@ -91,7 +97,7 @@ sub select_by_regexp {
sub select_by_list {
my ($self, %options) = @_;
my $count = 0;
my $metric_ids = {};
my $stmt = $self->execute_query($self->{centreon_db_centreon}, "SELECT metric_id FROM `meta_service_relation` WHERE meta_id = '". $self->{option_results}->{meta_id} . "' AND activate = '1'");
@ -100,22 +106,28 @@ sub select_by_list {
$count++;
}
if ($count == 0) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => 'Cannot find a metric_id in table meta_service_relation.');
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => 'Cannot find a metric_id in table meta_service_relation.'
);
$self->{output}->display();
$self->{output}->exit();
}
$count = 0;
$stmt = $self->execute_query($self->{centreon_db_centstorage},
"SELECT metric_id, current_value FROM metrics WHERE metric_id IN (" . join(',', keys %{$metric_ids}) . ")");
$stmt = $self->execute_query(
$self->{centreon_db_centstorage},
"SELECT metric_id, current_value FROM metrics WHERE metric_id IN (" . join(',', keys %{$metric_ids}) . ")"
);
while ((my $row = $stmt->fetchrow_hashref())) {
$self->{metric_selected}->{$row->{metric_id}} = $row->{current_value};
$count++;
}
if ($count == 0) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => 'Cannot find a metric_id in metrics table.');
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => 'Cannot find a metric_id in metrics table.'
);
$self->{output}->display();
$self->{output}->exit();
}
@ -124,22 +136,22 @@ sub select_by_list {
sub calculate {
my ($self, %options) = @_;
my $result = 0;
if ($options{calculation} eq "MIN") {
my @values = sort(values %{$self->{metric_selected}});
if ($options{calculation} eq 'MIN') {
my @values = sort { $a <=> $b } values(%{$self->{metric_selected}});
if (defined($values[0])) {
$result = $values[0];
}
} elsif ($options{calculation} eq "MAX") {
my @values = sort(values %{$self->{metric_selected}});
} elsif ($options{calculation} eq 'MAX') {
my @values = sort { $a <=> $b } values(%{$self->{metric_selected}});
if (defined($values[0])) {
$result = $values[scalar(@values) - 1];
}
} elsif ($options{calculation} eq "SOM") {
} elsif ($options{calculation} eq 'SOM') {
foreach my $value (values %{$self->{metric_selected}}) {
$result += $value;
}
} elsif ($options{calculation} eq "AVE") {
} elsif ($options{calculation} eq 'AVE') {
my @values = values %{$self->{metric_selected}};
foreach my $value (@values) {
$result += $value;
@ -158,13 +170,15 @@ sub run {
$self->{logger} = centreon::common::logger->new();
$self->{logger}->severity('none');
$self->{centreon_db_centreon} = centreon::common::db->new(db => $centreon_config->{centreon_db},
host => $centreon_config->{db_host},
port => $centreon_config->{db_port},
user => $centreon_config->{db_user},
password => $centreon_config->{db_passwd},
force => 0,
logger => $self->{logger});
$self->{centreon_db_centreon} = centreon::common::db->new(
db => $centreon_config->{centreon_db},
host => $centreon_config->{db_host},
port => $centreon_config->{db_port},
user => $centreon_config->{db_user},
password => $centreon_config->{db_passwd},
force => 0,
logger => $self->{logger}
);
my $status = $self->{centreon_db_centreon}->connect();
if ($status == -1) {
$self->{output}->output_add(severity => 'UNKNOWN',
@ -172,40 +186,46 @@ sub run {
$self->{output}->display();
$self->{output}->exit();
}
$self->{centreon_db_centstorage} = centreon::common::db->new(db => $centreon_config->{centstorage_db},
host => $centreon_config->{db_host},
port => $centreon_config->{db_port},
user => $centreon_config->{db_user},
password => $centreon_config->{db_passwd},
force => 0,
logger => $self->{logger});
$self->{centreon_db_centstorage} = centreon::common::db->new(
db => $centreon_config->{centstorage_db},
host => $centreon_config->{db_host},
port => $centreon_config->{db_port},
user => $centreon_config->{db_user},
password => $centreon_config->{db_passwd},
force => 0,
logger => $self->{logger}
);
$status = $self->{centreon_db_centstorage}->connect();
if ($status == -1) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => 'Cannot connect to Centstorage Database.');
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => 'Cannot connect to Centstorage Database.'
);
$self->{output}->display();
$self->{output}->exit();
}
my $stmt = $self->execute_query($self->{centreon_db_centreon}, "SELECT meta_display, calcul_type, regexp_str, warning, critical, metric, meta_select_mode, data_source_type FROM `meta_service` WHERE meta_id = '". $self->{option_results}->{meta_id} . "' LIMIT 1");
my $row = $stmt->fetchrow_hashref();
if (!defined($row)) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => 'Cannot get meta service informations.');
$self->{output}->output_add(
severity => 'UNKNOWN',
short_msg => 'Cannot get meta service informations.'
);
$self->{output}->display();
$self->{output}->exit();
}
# Set threshold
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $row->{warning})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $row->{warning} . "'.");
$self->{output}->option_exit();
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $row->{warning} . "'.");
$self->{output}->option_exit();
}
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $row->{critical})) == 0) {
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $row->{critical} . "'.");
$self->{output}->option_exit();
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $row->{critical} . "'.");
$self->{output}->option_exit();
}
if ($row->{meta_select_mode} == 2) {
$self->select_by_regexp(regexp_str => $row->{regexp_str}, metric_select => $row->{metric});
} else {
@ -213,17 +233,20 @@ sub run {
}
my $result = $self->calculate(calculation => $row->{calcul_type});
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
my $display = defined($row->{meta_display}) ? $row->{meta_display} : $row->{calcul_type} . ' - value : %f';
$self->{output}->output_add(severity => $exit,
short_msg => sprintf($display, $result));
$self->{output}->perfdata_add(label => (defined($DSTYPE{$row->{data_source_type}}) ? $DSTYPE{$row->{data_source_type}} : 'g') . '[' . $row->{metric} . ']',
value => sprintf("%02.2f", $result),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf($display, $result)
);
$self->{output}->perfdata_add(
label => (defined($DSTYPE{$row->{data_source_type}}) ? $DSTYPE{$row->{data_source_type}} : 'g') . '[' . $row->{metric} . ']',
value => sprintf("%02.2f", $result),
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
);
$self->{output}->display();
$self->{output}->exit();
}

View File

@ -30,12 +30,12 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'gates' => 'apps::centreon::map4::jmx::mode::gates',
'elements' => 'apps::centreon::map4::jmx::mode::elements',
'sessions' => 'apps::centreon::map4::jmx::mode::sessions',
'event-queue' => 'apps::centreon::map4::jmx::mode::eventqueue',
'event-statistics' => 'apps::centreon::map4::jmx::mode::eventstatistics',
);
'elements' => 'apps::centreon::map4::jmx::mode::elements',
'event-queue' => 'apps::centreon::map4::jmx::mode::eventqueue',
'event-statistics' => 'apps::centreon::map4::jmx::mode::eventstatistics',
'gates' => 'apps::centreon::map4::jmx::mode::gates',
'sessions' => 'apps::centreon::map4::jmx::mode::sessions',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -129,9 +129,13 @@ sub custom_metric_threshold {
my $label_warn = ($self->{result_values}->{type} eq 'unique') ? 'warning-metric' : 'warning-global-'.$self->{result_values}->{instance};
my $label_crit = ($self->{result_values}->{type} eq 'unique') ? 'critical-metric' : 'critical-global-'.$self->{result_values}->{instance};
my $exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{perfdata_value},
threshold => [ { label => $label_crit, exit_litteral => 'critical' },
{ label => $label_warn, exit_litteral => 'warning' } ]);
my $exit = $self->{perfdata}->threshold_check(
value => $self->{result_values}->{perfdata_value},
threshold => [
{ label => $label_crit, exit_litteral => 'critical' },
{ label => $label_warn, exit_litteral => 'warning' }
]
);
return $exit;
}
@ -169,11 +173,12 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"config-file:s" => { name => 'config_file' },
"json-data:s" => { name => 'json_data' },
});
$options{options}->add_options(arguments => {
'config-file:s' => { name => 'config_file' },
'json-data:s' => { name => 'json_data' },
'database:s' => { name => 'database' },
});
return $self;
}
@ -205,6 +210,10 @@ sub check_options {
$config_data->{formatting}->{custom_message_metric} = "All metrics are OK" if (!exists($config_data->{formatting}->{custom_message_metric}));
$config_data->{formatting}->{cannonical_separator} = "#" if (!exists($config_data->{formatting}->{cannonical_separator}));
$config_data->{formatting}->{change_bytes} = 0 if (!exists($config_data->{formatting}->{change_bytes}));
$self->{option_results}->{database} =
(defined($self->{option_results}->{database}) && $self->{option_results}->{database} ne '') ?
$self->{option_results}->{database} . '.' : 'centreon_storage.';
}
sub parse_json_config {
@ -234,7 +243,6 @@ sub parse_json_config {
sub manage_selection {
my ($self, %options) = @_;
# $options{sql} = sqlmode object
$self->{sql} = $options{sql};
$self->{sql}->connect();
$self->{metrics} = {};
@ -253,7 +261,7 @@ sub manage_selection {
};
foreach my $id (keys %{$config_data->{selection}}) {
my $query = "SELECT index_data.host_name, index_data.service_description, metrics.metric_name, metrics.current_value, metrics.unit_name, metrics.min, metrics.max ";
$query .= "FROM centreon_storage.index_data, centreon_storage.metrics WHERE index_data.id = metrics.index_id ";
$query .= "FROM $self->{option_results}->{database}index_data, $self->{option_results}->{database}metrics WHERE index_data.id = metrics.index_id ";
$query .= "AND index_data.service_description = '" . $config_data->{selection}->{$id}->{service_name} . "'";
$query .= "AND index_data.host_name = '" . $config_data->{selection}->{$id}->{host_name} . "'" ;
$query .= "AND metrics.metric_name = '" . $config_data->{selection}->{$id}->{metric_name} . "'";
@ -274,10 +282,11 @@ sub manage_selection {
name => 'metric', type => 1, message_separator => $config_data->{formatting}->{message_separator}, message_multiple => $config_data->{formatting}->{custom_message_metric},
};
my $query = "SELECT index_data.host_name, index_data.service_description, metrics.metric_name, metrics.current_value, metrics.unit_name, metrics.min, metrics.max ";
$query .= "FROM centreon_storage.index_data, centreon_storage.metrics WHERE index_data.id = metrics.index_id ";
$query .= "AND index_data.service_description LIKE '" . $config_data->{filters}->{service} . "'" if (defined($config_data->{filters}->{service}) && ($config_data->{filters}->{service} ne ''));
$query .= "AND index_data.host_name LIKE '" . $config_data->{filters}->{host} . "'" if (defined($config_data->{filters}->{host}) && ($config_data->{filters}->{host} ne ''));
$query .= "AND metrics.metric_name LIKE '" . $config_data->{filters}->{metric} . "'" if (defined($config_data->{filters}->{metric}) && ($config_data->{filters}->{metric} ne ''));
$query .= "FROM $self->{option_results}->{database}index_data, $self->{option_results}->{database}metrics, $self->{option_results}->{database}services WHERE index_data.id = metrics.index_id AND services.service_id = index_data.service_id AND services.host_id = index_data.host_id ";
$query .= "AND index_data.service_description LIKE '" . $config_data->{filters}->{service} . "' " if (defined($config_data->{filters}->{service}) && ($config_data->{filters}->{service} ne ''));
$query .= "AND index_data.host_name LIKE '" . $config_data->{filters}->{host} . "' " if (defined($config_data->{filters}->{host}) && ($config_data->{filters}->{host} ne ''));
$query .= "AND metrics.metric_name LIKE '" . $config_data->{filters}->{metric} . "' " if (defined($config_data->{filters}->{metric}) && ($config_data->{filters}->{metric} ne ''));
$query .= "AND services.enabled = '1'";
$self->{sql}->query(query => $query);
while ((my $row = $self->{sql}->fetchrow_hashref())) {
my $metric_key = $row->{host_name}.$config_data->{formatting}->{cannonical_separator}.$row->{service_description}.$config_data->{formatting}->{cannonical_separator}.$row->{metric_name};
@ -302,14 +311,18 @@ sub manage_selection {
next if (scalar(@{$self->{vmetrics}->{$vcurve}->{values}}) == 0);
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
sum(@{$self->{vmetrics}->{$vcurve}->{values}})/scalar(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'avg');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
sum(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'sum');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
min(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'min');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf($config_data->{formatting}->{printf_metric_value},
max(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'max');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf(
$config_data->{formatting}->{printf_metric_value},
sum(@{$self->{vmetrics}->{$vcurve}->{values}}) / scalar(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'avg');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf(
$config_data->{formatting}->{printf_metric_value},
sum(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'sum');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf(
$config_data->{formatting}->{printf_metric_value},
min(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'min');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = sprintf(
$config_data->{formatting}->{printf_metric_value},
max(@{$self->{vmetrics}->{$vcurve}->{values}})) if ($config_data->{virtualcurve}->{$vcurve}->{aggregation} eq 'max');
$self->{vmetrics}->{$vcurve}->{aggregated_value} = eval "$self->{vmetrics}->{$vcurve}->{aggregated_value} $config_data->{virtualcurve}->{$vcurve}->{custom}" if (defined($config_data->{virtualcurve}->{$vcurve}->{custom}));
$self->{vmetrics}->{$vcurve}->{unit} = (defined($config_data->{virtualcurve}->{$vcurve}->{unit})) ? $config_data->{virtualcurve}->{$vcurve}->{unit} : '';
@ -317,32 +330,36 @@ sub manage_selection {
$self->{vmetrics}->{$vcurve}->{max} = (defined($config_data->{virtualcurve}->{$vcurve}->{max})) ? $config_data->{virtualcurve}->{$vcurve}->{max} : '';
if (defined($self->{option_results}->{'warning-global'}) || defined($config_data->{virtualcurve}->{$vcurve}->{warning})) {
$self->{perfdata}->threshold_validate(label => 'warning-global-'.$vcurve,
$self->{perfdata}->threshold_validate(label => 'warning-global-' . $vcurve,
value => (defined($self->{option_results}->{'warning-global'})) ? $self->{option_results}->{'warning-global'} : $config_data->{virtualcurve}->{$vcurve}->{warning});
}
if (defined($self->{option_results}->{'critical-global'}) || defined($config_data->{virtualcurve}->{$vcurve}->{critical})) {
$self->{perfdata}->threshold_validate(label => 'critical-global-'.$vcurve,
$self->{perfdata}->threshold_validate(label => 'critical-global-' . $vcurve,
value => (defined($self->{option_results}->{'critical-global'})) ? $self->{option_results}->{'critical-global'} : $config_data->{virtualcurve}->{$vcurve}->{critical});
}
$self->{global}->{$vcurve} = {display => $vcurve,
type => 'global',
unit => $self->{vmetrics}->{$vcurve}->{unit},
value => $self->{vmetrics}->{$vcurve}->{aggregated_value},
min => $self->{vmetrics}->{$vcurve}->{min},
max => $self->{vmetrics}->{$vcurve}->{max} };
}
$self->{global}->{$vcurve} = {
display => $vcurve,
type => 'global',
unit => $self->{vmetrics}->{$vcurve}->{unit},
value => $self->{vmetrics}->{$vcurve}->{aggregated_value},
min => $self->{vmetrics}->{$vcurve}->{min},
max => $self->{vmetrics}->{$vcurve}->{max}
};
}
$self->{metric}->{$metric} = {display => $self->{metrics}->{$metric}->{display_name},
type => 'unique',
unit => $self->{metrics}->{$metric}->{unit},
value => $self->{metrics}->{$metric}->{current},
min => $self->{metrics}->{$metric}->{min},
max => $self->{metrics}->{$metric}->{max} } if ($self->{metrics}->{$metric}->{display} == 1);
$self->{metric}->{$metric} = {
display => $self->{metrics}->{$metric}->{display_name},
type => 'unique',
unit => $self->{metrics}->{$metric}->{unit},
value => $self->{metrics}->{$metric}->{current},
min => $self->{metrics}->{$metric}->{min},
max => $self->{metrics}->{$metric}->{max}
} if ($self->{metrics}->{$metric}->{display} == 1);
}
if (scalar(keys %{$self->{metric}}) <= 0 && scalar(keys %{$self->{vmetrics}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No metrics returned - are your selection/filters correct ?");
$self->{output}->add_option_msg(short_msg => 'No metrics returned - are your selection/filters correct ?');
$self->{output}->option_exit();
}
}
@ -359,6 +376,10 @@ e.g: aggregate multiple metrics (min,max,avg,sum) or custom operation
=over 8
=item B<--database>
Specify the database (default: 'centreon_storage')
=item B<--config-file>
Specify the full path to a json config file

View File

@ -32,8 +32,8 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'status' => 'apps::checkmyws::mode::status',
);
'status' => 'apps::checkmyws::mode::status',
);
return $self;
}

View File

@ -31,12 +31,13 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'alarms' => 'apps::cisco::cms::restapi::mode::alarms',
'calls' => 'apps::cisco::cms::restapi::mode::calls',
'database-status' => 'apps::cisco::cms::restapi::mode::databasestatus',
'licenses' => 'apps::cisco::cms::restapi::mode::licenses',
'system-status' => 'apps::cisco::cms::restapi::mode::systemstatus',
);
'alarms' => 'apps::cisco::cms::restapi::mode::alarms',
'calls' => 'apps::cisco::cms::restapi::mode::calls',
'database-status' => 'apps::cisco::cms::restapi::mode::databasestatus',
'licenses' => 'apps::cisco::cms::restapi::mode::licenses',
'system-status' => 'apps::cisco::cms::restapi::mode::systemstatus',
);
$self->{custom_modes}{xmlapi} = 'apps::cisco::cms::restapi::custom::xmlapi';
return $self;
}

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'session' => 'apps::cisco::ise::restapi::mode::session',
);
'session' => 'apps::cisco::ise::restapi::mode::session',
);
$self->{custom_modes}{xmlapi} = 'apps::cisco::ise::restapi::custom::xmlapi';
return $self;
}

View File

@ -29,12 +29,13 @@ use Win32::OLE;
sub custom_license_output {
my ($self, %options) = @_;
my $msg = sprintf("Licenses Total: %s %s Used: %s %s (%.2f%%) Free: %s %s (%.2f%%)",
$self->{perfdata}->change_bytes(value => $self->{result_values}->{total_absolute}),
$self->{perfdata}->change_bytes(value => $self->{result_values}->{used_absolute}),
my $msg = sprintf("Licenses Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$self->{result_values}->{total_absolute},
$self->{result_values}->{used_absolute},
$self->{result_values}->{prct_used_absolute},
$self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}),
$self->{result_values}->{prct_free_absolute});
$self->{result_values}->{free_absolute},
$self->{result_values}->{prct_free_absolute}
);
return $msg;
}
@ -50,8 +51,7 @@ sub set_counters {
key_values => [ { name => 'used' }, { name => 'free' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
closure_custom_output => $self->can('custom_license_output'),
perfdatas => [
{ label => 'mem_used', value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute',
unit => 'B', cast_int => 1 },
{ value => 'used_absolute', template => '%d', min => 0, max => 'total_absolute' },
],
}
},
@ -59,7 +59,7 @@ sub set_counters {
key_values => [ { name => 'free' }, { name => 'used' }, { name => 'prct_used' }, { name => 'prct_free' }, { name => 'total' } ],
closure_custom_output => $self->can('custom_license_output'),
perfdatas => [
{ value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute', cast_int => 1 },
{ value => 'free_absolute', template => '%d', min => 0, max => 'total_absolute' },
],
}
},

View File

@ -31,11 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'license' => 'apps::citrix::local::mode::license',
'session' => 'apps::citrix::local::mode::session',
'zone' => 'apps::citrix::local::mode::zone',
'folder' => 'apps::citrix::local::mode::folder',
);
'folder' => 'apps::citrix::local::mode::folder',
'license' => 'apps::citrix::local::mode::license',
'session' => 'apps::citrix::local::mode::session',
'zone' => 'apps::citrix::local::mode::zone',
);
return $self;
}

View File

@ -31,13 +31,13 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'list-nodes' => 'apps::cluster::mscs::local::mode::listnodes',
'list-resources' => 'apps::cluster::mscs::local::mode::listresources',
'network-status' => 'apps::cluster::mscs::local::mode::networkstatus',
'node-status' => 'apps::cluster::mscs::local::mode::nodestatus',
'resource-status' => 'apps::cluster::mscs::local::mode::resourcestatus',
'resourcegroup-status' => 'apps::cluster::mscs::local::mode::resourcegroupstatus',
);
'list-nodes' => 'apps::cluster::mscs::local::mode::listnodes',
'list-resources' => 'apps::cluster::mscs::local::mode::listresources',
'network-status' => 'apps::cluster::mscs::local::mode::networkstatus',
'node-status' => 'apps::cluster::mscs::local::mode::nodestatus',
'resource-status' => 'apps::cluster::mscs::local::mode::resourcestatus',
'resourcegroup-status' => 'apps::cluster::mscs::local::mode::resourcegroupstatus',
);
return $self;
}

View File

@ -31,17 +31,17 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'activesync-mailbox' => 'apps::exchange::2010::local::mode::activesyncmailbox',
'databases' => 'apps::exchange::2010::local::mode::databases',
'list-databases' => 'apps::exchange::2010::local::mode::listdatabases',
'imap-mailbox' => 'apps::exchange::2010::local::mode::imapmailbox',
'mapi-mailbox' => 'apps::exchange::2010::local::mode::mapimailbox',
'outlook-webservices' => 'apps::exchange::2010::local::mode::outlookwebservices',
'owa-mailbox' => 'apps::exchange::2010::local::mode::owamailbox',
'queues' => 'apps::exchange::2010::local::mode::queues',
'replication-health' => 'apps::exchange::2010::local::mode::replicationhealth',
'services' => 'apps::exchange::2010::local::mode::services',
);
'activesync-mailbox' => 'apps::exchange::2010::local::mode::activesyncmailbox',
'databases' => 'apps::exchange::2010::local::mode::databases',
'list-databases' => 'apps::exchange::2010::local::mode::listdatabases',
'imap-mailbox' => 'apps::exchange::2010::local::mode::imapmailbox',
'mapi-mailbox' => 'apps::exchange::2010::local::mode::mapimailbox',
'outlook-webservices' => 'apps::exchange::2010::local::mode::outlookwebservices',
'owa-mailbox' => 'apps::exchange::2010::local::mode::owamailbox',
'queues' => 'apps::exchange::2010::local::mode::queues',
'replication-health' => 'apps::exchange::2010::local::mode::replicationhealth',
'services' => 'apps::exchange::2010::local::mode::services',
);
return $self;
}

View File

@ -31,12 +31,13 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'status' => 'apps::github::mode::status',
'issues' => 'apps::github::mode::issues',
'commits' => 'apps::github::mode::commits',
'pullrequests' => 'apps::github::mode::pullrequests',
'stats' => 'apps::github::mode::stats',
);
'issues' => 'apps::github::mode::issues',
'commits' => 'apps::github::mode::commits',
'pullrequests' => 'apps::github::mode::pullrequests',
'stats' => 'apps::github::mode::stats',
'status' => 'apps::github::mode::status',
);
return $self;
}

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'backend-usage' => 'apps::haproxy::snmp::mode::backendusage',
'frontend-usage' => 'apps::haproxy::snmp::mode::frontendusage',
);
'backend-usage' => 'apps::haproxy::snmp::mode::backendusage',
'frontend-usage' => 'apps::haproxy::snmp::mode::frontendusage',
);
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'temperature' => 'apps::hddtemp::local::mode::temperature',
);
'temperature' => 'apps::hddtemp::local::mode::temperature',
);
return $self;
}

View File

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

View File

@ -31,11 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'applicationpool-state' => 'apps::iis::local::mode::applicationpoolstate',
'list-applicationpools' => 'apps::iis::local::mode::listapplicationpools',
'list-sites' => 'apps::iis::local::mode::listsites',
'webservice-statistics' => 'apps::iis::local::mode::webservicestatistics',
);
'applicationpool-state' => 'apps::iis::local::mode::applicationpoolstate',
'list-applicationpools' => 'apps::iis::local::mode::listapplicationpools',
'list-sites' => 'apps::iis::local::mode::listsites',
'webservice-statistics' => 'apps::iis::local::mode::webservicestatistics',
);
return $self;
}

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'applicationpool-state' => 'apps::iis::wsman::mode::applicationpoolstate',
'list-applicationpools' => 'apps::iis::wsman::mode::listapplicationpools',
);
'applicationpool-state' => 'apps::iis::wsman::mode::applicationpoolstate',
'list-applicationpools' => 'apps::iis::wsman::mode::listapplicationpools',
);
return $self;
}

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'span-usage' => 'apps::inin::ig::snmp::mode::spanusage',
'stats' => 'apps::inin::ig::snmp::mode::stats',
);
'span-usage' => 'apps::inin::ig::snmp::mode::spanusage',
'stats' => 'apps::inin::ig::snmp::mode::stats',
);
return $self;
}

View File

@ -31,12 +31,12 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'audioengine-usage' => 'apps::inin::mediaserver::snmp::mode::audioengineusage',
'cmdsrv-usage' => 'apps::inin::mediaserver::snmp::mode::cmdsrvusage',
'disk-usage' => 'apps::inin::mediaserver::snmp::mode::diskusage',
'component' => 'apps::inin::mediaserver::snmp::mode::component',
'memory-usage' => 'apps::inin::mediaserver::snmp::mode::memoryusage',
);
'audioengine-usage' => 'apps::inin::mediaserver::snmp::mode::audioengineusage',
'cmdsrv-usage' => 'apps::inin::mediaserver::snmp::mode::cmdsrvusage',
'component' => 'apps::inin::mediaserver::snmp::mode::component',
'disk-usage' => 'apps::inin::mediaserver::snmp::mode::diskusage',
'memory-usage' => 'apps::inin::mediaserver::snmp::mode::memoryusage',
);
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'stats' => 'apps::java::hibernate::jmx::mode::stats',
);
'stats' => 'apps::java::hibernate::jmx::mode::stats',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -84,10 +84,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"filter-name:s" => { name => 'filter_name' },
});
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
});
return $self;
}

View File

@ -31,13 +31,13 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'class-count' => 'centreon::common::jvm::mode::classcount',
'datasource-usage' => 'apps::java::jboss::jmx::mode::datasourceusage',
'list-datasources' => 'apps::java::jboss::jmx::mode::listdatasources',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
);
'class-count' => 'centreon::common::jvm::mode::classcount',
'datasource-usage' => 'apps::java::jboss::jmx::mode::datasourceusage',
'list-datasources' => 'apps::java::jboss::jmx::mode::listdatasources',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'global-stats' => 'apps::java::kafka::jmx::mode::globalstats',
);
'global-stats' => 'apps::java::kafka::jmx::mode::globalstats',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'queue-length' => 'apps::java::peoplesoft::jmx::mode::queuelength',
'sessions' => 'apps::java::peoplesoft::jmx::mode::sessions',
);
'queue-length' => 'apps::java::peoplesoft::jmx::mode::queuelength',
'sessions' => 'apps::java::peoplesoft::jmx::mode::sessions',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'cache-usage' => 'apps::java::solr::jmx::mode::cacheusage',
'request-handler-usage' => 'apps::java::solr::jmx::mode::requesthandlerusage',
);
'cache-usage' => 'apps::java::solr::jmx::mode::cacheusage',
'request-handler-usage' => 'apps::java::solr::jmx::mode::requesthandlerusage',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,12 +31,12 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'class-count' => 'centreon::common::jvm::mode::classcount',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
'work-manager' => 'apps::java::weblogic::jmx::mode::workmanager',
);
'class-count' => 'centreon::common::jvm::mode::classcount',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
'work-manager' => 'apps::java::weblogic::jmx::mode::workmanager',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'stats' => 'apps::java::zookeeper::jmx::mode::stats',
);
'stats' => 'apps::java::zookeeper::jmx::mode::stats',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -32,8 +32,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'job-state' => 'apps::jenkins::mode::jobstate',
);
'job-state' => 'apps::jenkins::mode::jobstate',
);
return $self;
}

View File

@ -80,11 +80,10 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{instanceState} ne %{instanceWantedState} or %{instanceState} ne %{instanceStateLast}' },
});
$options{options}->add_options(arguments => {
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{instanceState} ne %{instanceWantedState} or %{instanceState} ne %{instanceStateLast}' },
});
return $self;
}
@ -110,8 +109,11 @@ sub manage_selection {
my ($self, %options) = @_;
$self->{vrrp} = {};
my $snmp_result = $options{snmp}->get_table(oid => $oid_vrrpInstanceEntry, end => $mapping->{vrrpInstancePrimaryInterface}->{oid},
nothing_quit => 1);
my $snmp_result = $options{snmp}->get_table(
oid => $oid_vrrpInstanceEntry,
end => $mapping->{vrrpInstancePrimaryInterface}->{oid},
nothing_quit => 1
);
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{vrrpInstanceState}->{oid}\.(.*)$/);

View File

@ -31,7 +31,7 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'vrrp-status' => 'apps::keepalived::snmp::mode::vrrpstatus',
'vrrp-status' => 'apps::keepalived::snmp::mode::vrrpstatus',
);
return $self;

View File

@ -31,12 +31,12 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'mail-state' => 'apps::lotus::snmp::mode::mailstate',
'mail-time' => 'apps::lotus::snmp::mode::mailtime',
'server-availability' => 'apps::lotus::snmp::mode::serveravailability',
'user-sessions' => 'apps::lotus::snmp::mode::usersessions',
'server-transactions' => 'apps::lotus::snmp::mode::servertransactions',
);
'mail-state' => 'apps::lotus::snmp::mode::mailstate',
'mail-time' => 'apps::lotus::snmp::mode::mailtime',
'server-availability' => 'apps::lotus::snmp::mode::serveravailability',
'server-transactions' => 'apps::lotus::snmp::mode::servertransactions',
'user-sessions' => 'apps::lotus::snmp::mode::usersessions',
);
return $self;
}

View File

@ -75,11 +75,11 @@ sub run {
$metric !~ /$self->{option_results}->{filter_metrics}/);
foreach my $data (@{$self->{metrics}->{$metric}->{data}}) {
next if (defined($self->{option_results}->{instance}) &&
next if (defined($self->{option_results}->{instance}) && $self->{option_results}->{instance} ne '' &&
!defined($data->{dimensions}->{$self->{option_results}->{instance}}) ||
defined($self->{option_results}->{filter_instance}) && $self->{option_results}->{filter_instance} ne '' &&
$data->{dimensions}->{$self->{option_results}->{instance}} !~ /$self->{option_results}->{filter_instance}/);
next if (defined($self->{option_results}->{subinstance}) &&
next if (defined($self->{option_results}->{subinstance}) && $self->{option_results}->{subinstance} ne '' &&
!defined($data->{dimensions}->{$self->{option_results}->{subinstance}}) ||
defined($self->{option_results}->{filter_subinstance}) && $self->{option_results}->{filter_subinstance} ne '' &&
$data->{dimensions}->{$self->{option_results}->{subinstance}} !~ /$self->{option_results}->{filter_subinstance}/);
@ -87,14 +87,14 @@ sub run {
my $label = $metric;
$label =~ s/_/./g if (defined($self->{option_results}->{new_perfdata}));
$label = $data->{dimensions}->{$self->{option_results}->{instance}} . '#' . $label
if (defined($self->{option_results}->{instance}) &&
if (defined($self->{option_results}->{instance}) && $self->{option_results}->{instance} ne '' &&
defined($data->{dimensions}->{$self->{option_results}->{instance}}) &&
!defined($self->{option_results}->{subinstance}));
$label = $data->{dimensions}->{$self->{option_results}->{instance}} . '~' .
$data->{dimensions}->{$self->{option_results}->{subinstance}} . '#' . $label
if (defined($self->{option_results}->{instance}) &&
if (defined($self->{option_results}->{instance}) && $self->{option_results}->{instance} ne '' &&
defined($data->{dimensions}->{$self->{option_results}->{instance}}) &&
defined($self->{option_results}->{subinstance}) &&
defined($self->{option_results}->{subinstance}) && $self->{option_results}->{subinstance} ne '' &&
defined($data->{dimensions}->{$self->{option_results}->{subinstance}}));
$label =~ s/'//g;
@ -147,7 +147,7 @@ Examples:
# perl centreon_plugins.pl --plugin=apps::monitoring::openmetrics::plugin --mode=scrape-metrics
--custommode=web --hostname=10.2.3.4 --port=9100 --verbose --filter-metrics='node_cpu_seconds_total'
--instance='cpu' --subinstance='mode' --filter-subinstance='idle'
--instance='cpu' --subinstance='mode' --filter-subinstance='mode'
# perl centreon_plugins.pl --plugin=apps::monitoring::openmetrics::plugin --mode=scrape-metrics
--custommode=file --command-options='/tmp/metrics' --filter-metrics='cpu' --verbose

View File

@ -125,8 +125,18 @@ __END__
Check web scenario availability metrics.
(Data are delayed by a minimum of 3 hours)
=over 8
=item B<--scenario-id>
Set ID of the scenario.
=item B<--timeframe>
Set timeframe in seconds (Default: 14400).
=item B<--warning-*> B<--critical-*>
Can be: 'total-response-time', 'availability',

View File

@ -38,12 +38,6 @@ sub new {
return $self;
}
sub init {
my ( $self, %options ) = @_;
$self->SUPER::init(%options);
}
1;
__END__

View File

@ -43,7 +43,7 @@ sub new {
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'api-version' => { name => 'api_version' },
'api-version:s' => { name => 'api_version' },
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'server-usage' => 'apps::openvpn::omi::mode::serverusage',
);
'server-usage' => 'apps::openvpn::omi::mode::serverusage',
);
$self->{custom_modes}{api} = 'apps::openvpn::omi::custom::api';
return $self;

View File

@ -31,17 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'city-weather' => 'apps::openweathermap::restapi::mode::cityweather',
'city-weather' => 'apps::openweathermap::restapi::mode::cityweather',
);
$self->{custom_modes}{api} = 'apps::openweathermap::restapi::custom::api';
return $self;
}
sub init {
my ( $self, %options ) = @_;
$self->SUPER::init(%options);
return $self;²
}
1;

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'crm' => 'apps::pacemaker::local::mode::crm',
'constraints' => 'apps::pacemaker::local::mode::constraints',
'clustat' => 'apps::pacemaker::local::mode::clustat',
);
'clustat' => 'apps::pacemaker::local::mode::clustat',
'constraints' => 'apps::pacemaker::local::mode::constraints',
'crm' => 'apps::pacemaker::local::mode::crm',
);
return $self;
}

View File

@ -31,11 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'list-pfinterfaces' => 'apps::pfsense::snmp::mode::listpfinterfaces',
'packet-stats' => 'apps::pfsense::snmp::mode::packetstats',
'pfinterfaces' => 'apps::pfsense::snmp::mode::pfinterfaces',
'runtime' => 'apps::pfsense::snmp::mode::runtime',
);
'list-pfinterfaces' => 'apps::pfsense::snmp::mode::listpfinterfaces',
'packet-stats' => 'apps::pfsense::snmp::mode::packetstats',
'pfinterfaces' => 'apps::pfsense::snmp::mode::pfinterfaces',
'runtime' => 'apps::pfsense::snmp::mode::runtime',
);
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'bgppeerstate' => 'apps::protocols::bgp::4::mode::bgppeerstate',
);
'bgppeerstate' => 'apps::protocols::bgp::4::mode::bgppeerstate',
);
return $self;
}

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'connection' => 'apps::protocols::dhcp::mode::connection',
);
'connection' => 'apps::protocols::dhcp::mode::connection',
);
return $self;
}

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'request' => 'apps::protocols::dns::mode::request',
);
'request' => 'apps::protocols::dns::mode::request',
);
return $self;
}

View File

@ -31,11 +31,12 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'login' => 'apps::protocols::ftp::mode::login',
'commands' => 'apps::protocols::ftp::mode::commands',
'date' => 'apps::protocols::ftp::mode::date',
'filescount' => 'apps::protocols::ftp::mode::filescount',
);
'commands' => 'apps::protocols::ftp::mode::commands',
'date' => 'apps::protocols::ftp::mode::date',
'filescount' => 'apps::protocols::ftp::mode::filescount',
'login' => 'apps::protocols::ftp::mode::login',
);
return $self;
}

View File

@ -31,11 +31,11 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'expected-content' => 'apps::protocols::http::mode::expectedcontent',
'json-content' => 'apps::protocols::http::mode::jsoncontent',
'response' => 'apps::protocols::http::mode::response',
'soap-content' => 'apps::protocols::http::mode::soapcontent',
);
'expected-content' => 'apps::protocols::http::mode::expectedcontent',
'json-content' => 'apps::protocols::http::mode::jsoncontent',
'response' => 'apps::protocols::http::mode::response',
'soap-content' => 'apps::protocols::http::mode::soapcontent',
);
return $self;
}

View File

@ -31,9 +31,10 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'login' => 'apps::protocols::imap::mode::login',
'search-message' => 'apps::protocols::imap::mode::searchmessage',
);
'login' => 'apps::protocols::imap::mode::login',
'search-message' => 'apps::protocols::imap::mode::searchmessage',
);
return $self;
}

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'list-attributes' => 'apps::protocols::jmx::mode::listattributes',
'numeric-value' => 'apps::protocols::jmx::mode::numericvalue',
);
'list-attributes' => 'apps::protocols::jmx::mode::listattributes',
'numeric-value' => 'apps::protocols::jmx::mode::numericvalue',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,9 +31,10 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'login' => 'apps::protocols::ldap::mode::login',
'search' => 'apps::protocols::ldap::mode::search',
);
'login' => 'apps::protocols::ldap::mode::login',
'search' => 'apps::protocols::ldap::mode::search',
);
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'numeric-value' => 'apps::protocols::modbus::mode::numericvalue',
);
'numeric-value' => 'apps::protocols::modbus::mode::numericvalue',
);
$self->{custom_modes}{api} = 'centreon::common::protocols::modbus::custom::api';
return $self;

View File

@ -100,6 +100,7 @@ Trigger commands against NRPE/NSClient agent.
=item B<--command>
Set command.
In nrpe use following command to get server version: --command='_NRPE_CHECK'
=item B<--arg>

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'response-time' => 'apps::protocols::ntp::mode::responsetime',
'offset' => 'apps::protocols::ntp::mode::offset',
);
'offset' => 'apps::protocols::ntp::mode::offset',
'response-time' => 'apps::protocols::ntp::mode::responsetime',
);
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'neighbor' => 'apps::protocols::ospf::snmp::mode::neighbor',
);
'neighbor' => 'apps::protocols::ospf::snmp::mode::neighbor',
);
return $self;
}

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'login' => 'apps::protocols::radius::mode::login',
);
'login' => 'apps::protocols::radius::mode::login',
);
return $self;
}

View File

@ -31,9 +31,10 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'login' => 'apps::protocols::smtp::mode::login',
'message' => 'apps::protocols::smtp::mode::message',
);
'login' => 'apps::protocols::smtp::mode::login',
'message' => 'apps::protocols::smtp::mode::message',
);
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'login' => 'apps::protocols::ssh::mode::login',
);
'login' => 'apps::protocols::ssh::mode::login',
);
$self->{custom_modes}{api} = 'centreon::common::protocols::ssh::custom::api';
return $self;

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'response-time' => 'apps::protocols::tcp::mode::responsetime',
);
'response-time' => 'apps::protocols::tcp::mode::responsetime',
);
return $self;
}

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'scenario' => 'apps::protocols::telnet::mode::scenario',
);
'scenario' => 'apps::protocols::telnet::mode::scenario',
);
return $self;
}

View File

@ -31,8 +31,9 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'connection' => 'apps::protocols::udp::mode::connection',
);
'connection' => 'apps::protocols::udp::mode::connection',
);
return $self;
}

View File

@ -31,9 +31,10 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'certificate' => 'apps::protocols::x509::mode::certificate',
'validity' => 'apps::protocols::x509::mode::validity', #legacy mode
);
'certificate' => 'apps::protocols::x509::mode::certificate',
'validity' => 'apps::protocols::x509::mode::validity', #legacy mode
);
return $self;
}

View File

@ -32,26 +32,19 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'list-nodes' => 'apps::proxmox::ve::restapi::mode::listnodes',
'list-storages' => 'apps::proxmox::ve::restapi::mode::liststorages',
'list-vms' => 'apps::proxmox::ve::restapi::mode::listvms',
'storage-usage' => 'apps::proxmox::ve::restapi::mode::storageusage',
'node-usage' => 'apps::proxmox::ve::restapi::mode::nodeusage',
'version' => 'apps::proxmox::ve::restapi::mode::version',
'vm-usage' => 'apps::proxmox::ve::restapi::mode::vmusage',
);
'list-nodes' => 'apps::proxmox::ve::restapi::mode::listnodes',
'list-storages' => 'apps::proxmox::ve::restapi::mode::liststorages',
'list-vms' => 'apps::proxmox::ve::restapi::mode::listvms',
'node-usage' => 'apps::proxmox::ve::restapi::mode::nodeusage',
'storage-usage' => 'apps::proxmox::ve::restapi::mode::storageusage',
'version' => 'apps::proxmox::ve::restapi::mode::version',
'vm-usage' => 'apps::proxmox::ve::restapi::mode::vmusage',
);
$self->{custom_modes}{api} = 'apps::proxmox::ve::restapi::custom::api';
return $self;
}
sub init {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
1;
__END__

View File

@ -31,23 +31,16 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'http-hits' => 'apps::pvx::restapi::mode::httphits',
'network-connection' => 'apps::pvx::restapi::mode::networkconnection',
'network-user-experience' => 'apps::pvx::restapi::mode::networkuserexperience',
'network-traffic' => 'apps::pvx::restapi::mode::networktraffic',
);
'http-hits' => 'apps::pvx::restapi::mode::httphits',
'network-connection' => 'apps::pvx::restapi::mode::networkconnection',
'network-user-experience' => 'apps::pvx::restapi::mode::networkuserexperience',
'network-traffic' => 'apps::pvx::restapi::mode::networktraffic',
);
$self->{custom_modes}{api} = 'apps::pvx::restapi::custom::api';
return $self;
}
sub init {
my ( $self, %options ) = @_;
$self->SUPER::init(%options);
}
1;
__END__

View File

@ -31,25 +31,19 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'clients' => 'apps::redis::cli::mode::clients',
'commands' => 'apps::redis::cli::mode::commands',
'connections' => 'apps::redis::cli::mode::connections',
'cpu' => 'apps::redis::cli::mode::cpu',
'memory' => 'apps::redis::cli::mode::memory',
'persistence' => 'apps::redis::cli::mode::persistence',
'replication' => 'apps::redis::cli::mode::replication',
);
'clients' => 'apps::redis::cli::mode::clients',
'commands' => 'apps::redis::cli::mode::commands',
'connections' => 'apps::redis::cli::mode::connections',
'cpu' => 'apps::redis::cli::mode::cpu',
'memory' => 'apps::redis::cli::mode::memory',
'persistence' => 'apps::redis::cli::mode::persistence',
'replication' => 'apps::redis::cli::mode::replication',
);
$self->{custom_modes}{rediscli} = 'apps::redis::cli::custom::rediscli';
return $self;
}
sub init {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
1;
__END__

View File

@ -31,14 +31,15 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'databases-stats' => 'apps::redis::restapi::mode::databasesstats',
'cluster-stats' => 'apps::redis::restapi::mode::clusterstats',
'list-databases' => 'apps::redis::restapi::mode::listdatabases',
'list-nodes' => 'apps::redis::restapi::mode::listnodes',
'list-shards' => 'apps::redis::restapi::mode::listshards',
'nodes-stats' => 'apps::redis::restapi::mode::nodesstats',
'shards-stats' => 'apps::redis::restapi::mode::shardsstats',
);
'databases-stats' => 'apps::redis::restapi::mode::databasesstats',
'cluster-stats' => 'apps::redis::restapi::mode::clusterstats',
'list-databases' => 'apps::redis::restapi::mode::listdatabases',
'list-nodes' => 'apps::redis::restapi::mode::listnodes',
'list-shards' => 'apps::redis::restapi::mode::listshards',
'nodes-stats' => 'apps::redis::restapi::mode::nodesstats',
'shards-stats' => 'apps::redis::restapi::mode::shardsstats',
);
$self->{custom_modes}{api} = 'apps::redis::restapi::custom::api';
return $self;
}

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'stats' => 'apps::rrdcached::mode::stats',
);
'stats' => 'apps::rrdcached::mode::stats',
);
return $self;
}

View File

@ -45,12 +45,6 @@ sub new {
return $self;
}
sub init {
my ( $self, %options ) = @_;
$self->SUPER::init(%options);
}
1;
__END__

View File

@ -122,7 +122,7 @@ sub set_counters {
sub prefix_global_output {
my ($self, %options) = @_;
return "Scenario ";
return 'Scenario ';
}
sub prefix_step_output {
@ -137,24 +137,24 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"sahi-hostname:s" => { name => 'sahi_hostname' },
"sahi-port:s" => { name => 'sahi_port', default => 9999 },
"sahi-proto:s" => { name => 'sahi_proto', default => 'http' },
"sahi-http-timeout:s" => { name => 'sahi_http_timeout', default => 5 },
"sahi-endpoint:s" => { name => 'sahi_endpoint', default => '/_s_/dyn/' },
"sahi-suite:s" => { name => 'sahi_suite' },
"sahi-threads:s" => { name => 'sahi_threads', default => 1 },
"sahi-startwith:s" => { name => 'sahi_startwith', default => 'BROWSER' },
"sahi-browsertype:s" => { name => 'sahi_browsertype', default => 'chrome' },
"sahi-baseurl:s" => { name => 'sahi_baseurl' },
"timeout:s" => { name => 'timeout' },
"retries-scenario-status:s" => { name => 'retries_scenario_status' },
"interval-scenario-status:s" => { name => 'interval_scenario_status', default => 10 },
"unknown-run-status:s" => { name => 'unknown_run_status', default => '%{http_code} < 200 or %{http_code} >= 300' },
"warning-run-status:s" => { name => 'warning_run_status' },
"critical-run-status:s" => { name => 'critical_run_status', default => '' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} ne "SUCCESS"' },
'sahi-hostname:s' => { name => 'sahi_hostname' },
'sahi-port:s' => { name => 'sahi_port', default => 9999 },
'sahi-proto:s' => { name => 'sahi_proto', default => 'http' },
'sahi-http-timeout:s' => { name => 'sahi_http_timeout', default => 5 },
'sahi-endpoint:s' => { name => 'sahi_endpoint', default => '/_s_/dyn/' },
'sahi-suite:s' => { name => 'sahi_suite' },
'sahi-threads:s' => { name => 'sahi_threads', default => 1 },
'sahi-startwith:s' => { name => 'sahi_startwith', default => 'BROWSER' },
'sahi-browsertype:s' => { name => 'sahi_browsertype', default => 'chrome' },
'sahi-baseurl:s' => { name => 'sahi_baseurl' },
'timeout:s' => { name => 'timeout' },
'retries-scenario-status:s' => { name => 'retries_scenario_status' },
'interval-scenario-status:s' => { name => 'interval_scenario_status', default => 10 },
'unknown-run-status:s' => { name => 'unknown_run_status', default => '%{http_code} < 200 or %{http_code} >= 300' },
'warning-run-status:s' => { name => 'warning_run_status' },
'critical-run-status:s' => { name => 'critical_run_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} ne "SUCCESS"' },
});
$self->{http} = centreon::plugins::http->new(%options);
@ -179,7 +179,7 @@ sub handle_ALRM {
my $self = shift;
$self->killed_scenario();
$self->{output}->add_option_msg(short_msg => "Cannot finished scenario execution (timeout received)");
$self->{output}->add_option_msg(short_msg => 'Cannot finished scenario execution (timeout received)');
$self->{output}->option_exit();
}
@ -190,7 +190,7 @@ sub check_options {
foreach my $option (('sahi_hostname', 'sahi_suite', 'sahi_startwith', 'sahi_browsertype')) {
(my $label = $option) =~ s/_/-/g;
if (!defined($self->{option_results}->{$option}) || $self->{option_results}->{$option} eq '') {
$self->{output}->add_option_msg(short_msg => "Please set " . $label . " option");
$self->{output}->add_option_msg(short_msg => 'Please set ' . $label . ' option');
$self->{output}->option_exit();
}
}
@ -232,7 +232,7 @@ sub generate_user_defined_id {
my ($self, %options) = @_;
my ($seconds, $microseconds) = Time::HiRes::gettimeofday();
my $user_defined_id = strftime("%d%B%Y__%H_%M_%S_", localtime($seconds));
my $user_defined_id = strftime('%d%B%Y__%H_%M_%S_', localtime($seconds));
$user_defined_id .= $microseconds;
return $user_defined_id;
@ -301,7 +301,7 @@ sub run_scenario {
);
if ($self->{http}->get_code() != 200) {
$self->{output}->add_option_msg(short_msg => "run scenario issue:" . $content);
$self->{output}->add_option_msg(short_msg => 'run scenario issue:' . $content);
$self->{output}->option_exit();
}
@ -325,7 +325,7 @@ sub check_scenario_status {
);
if ($self->{http}->get_code() != 200) {
if ($retries == $self->{option_results}->{retries_scenario_status}) {
$self->{output}->add_option_msg(short_msg => "check scenario status issue:" . $content);
$self->{output}->add_option_msg(short_msg => 'check scenario status issue:' . $content);
$self->{output}->option_exit();
}
$retries++;
@ -362,13 +362,13 @@ sub get_suite_report {
);
if ($self->{http}->get_code() != 200) {
$self->cleanup_option_exit(short_msg => "get suite report issue:" . $content);
$self->cleanup_option_exit(short_msg => 'get suite report issue:' . $content);
}
my $response = $self->decode_xml_response(response => $content, ForceArray => ['summary']);
if (!defined($response->{suite}->{scriptSummaries}->{summary})) {
$self->{output}->output_add(long_msg => $response, debug => 1);
$self->cleanup_option_exit(short_msg => "get suite report issue: unknown response format");
$self->cleanup_option_exit(short_msg => 'get suite report issue: unknown response format');
}
# in milliseconds
@ -396,13 +396,13 @@ sub get_script_report {
);
if ($self->{http}->get_code() != 200) {
$self->cleanup_option_exit(short_msg => "get suite report issue:" . $content);
$self->cleanup_option_exit(short_msg => 'get suite report issue:' . $content);
}
my $response = $self->decode_xml_response(response => $content, ForceArray => ['step']);
if (!defined($response->{steps}->{step})) {
$self->{output}->output_add(long_msg => $response, debug => 1);
$self->cleanup_option_exit(short_msg => "get script report issue: unknown response format");
$self->cleanup_option_exit(short_msg => 'get script report issue: unknown response format');
}
$self->{steps} = {};

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'mta-usage' => 'snmp_standard::mode::mtausage',
);
'mta-usage' => 'snmp_standard::mode::mtausage',
);
return $self;
}

View File

@ -31,9 +31,10 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'count-channels' => 'apps::slack::restapi::mode::countchannels',
'count-members' => 'apps::slack::restapi::mode::countmembers',
);
'count-channels' => 'apps::slack::restapi::mode::countchannels',
'count-members' => 'apps::slack::restapi::mode::countmembers',
);
$self->{custom_modes}{restapi} = 'apps::slack::restapi::custom::api';
return $self;
}

View File

@ -31,20 +31,20 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'class-count' => 'centreon::common::jvm::mode::classcount',
'connector-usage' => 'apps::tomcat::jmx::mode::connectorusage',
'cpu-load' => 'centreon::common::jvm::mode::cpuload',
'datasource-usage' => 'apps::tomcat::jmx::mode::datasourceusage',
'fd-usage' => 'centreon::common::jvm::mode::fdusage',
'gc-usage' => 'centreon::common::jvm::mode::gcusage',
'list-datasources' => 'apps::tomcat::jmx::mode::listdatasources',
'list-webapps' => 'apps::tomcat::jmx::mode::listwebapps',
'load-average' => 'centreon::common::jvm::mode::loadaverage',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
'webapps-sessions' => 'apps::tomcat::jmx::mode::webappssessions',
);
'class-count' => 'centreon::common::jvm::mode::classcount',
'connector-usage' => 'apps::tomcat::jmx::mode::connectorusage',
'cpu-load' => 'centreon::common::jvm::mode::cpuload',
'datasource-usage' => 'apps::tomcat::jmx::mode::datasourceusage',
'fd-usage' => 'centreon::common::jvm::mode::fdusage',
'gc-usage' => 'centreon::common::jvm::mode::gcusage',
'list-datasources' => 'apps::tomcat::jmx::mode::listdatasources',
'list-webapps' => 'apps::tomcat::jmx::mode::listwebapps',
'load-average' => 'centreon::common::jvm::mode::loadaverage',
'memory' => 'centreon::common::jvm::mode::memory',
'memory-detailed' => 'centreon::common::jvm::mode::memorydetailed',
'threads' => 'centreon::common::jvm::mode::threads',
'webapps-sessions' => 'apps::tomcat::jmx::mode::webappssessions',
);
$self->{custom_modes}{jolokia} = 'centreon::common::protocols::jmx::custom::jolokia';
return $self;

View File

@ -31,9 +31,9 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'node-usage' => 'apps::video::openheadend::snmp::mode::nodeusage',
'operation-status' => 'apps::video::openheadend::snmp::mode::operationstatus',
);
'node-usage' => 'apps::video::openheadend::snmp::mode::nodeusage',
'operation-status' => 'apps::video::openheadend::snmp::mode::operationstatus',
);
return $self;
}

View File

@ -31,13 +31,13 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'broadcaster-input-usage' => 'apps::video::zixi::restapi::mode::broadcasterinputusage',
'broadcaster-license-usage' => 'apps::video::zixi::restapi::mode::broadcasterlicenseusage',
'broadcaster-output-usage' => 'apps::video::zixi::restapi::mode::broadcasteroutputusage',
'broadcaster-system-usage' => 'apps::video::zixi::restapi::mode::broadcastersystemusage',
'feeder-input-usage' => 'apps::video::zixi::restapi::mode::feederinputusage',
'feeder-output-usage' => 'apps::video::zixi::restapi::mode::feederoutputusage',
);
'broadcaster-input-usage' => 'apps::video::zixi::restapi::mode::broadcasterinputusage',
'broadcaster-license-usage' => 'apps::video::zixi::restapi::mode::broadcasterlicenseusage',
'broadcaster-output-usage' => 'apps::video::zixi::restapi::mode::broadcasteroutputusage',
'broadcaster-system-usage' => 'apps::video::zixi::restapi::mode::broadcastersystemusage',
'feeder-input-usage' => 'apps::video::zixi::restapi::mode::feederinputusage',
'feeder-output-usage' => 'apps::video::zixi::restapi::mode::feederoutputusage',
);
$self->{custom_modes}{api} = 'apps::video::zixi::restapi::custom::api';
return $self;

View File

@ -40,86 +40,30 @@ sub custom_status_calc {
return 0;
}
sub custom_usage_perfdata {
my ($self, %options) = @_;
my ($label, $nlabel) = ('used', $self->{nlabel});
my $value_perf = $self->{result_values}->{used};
if (defined($self->{instance_mode}->{option_results}->{free})) {
($label, $nlabel) = ('free', 'datastore.space.free.bytes');
$value_perf = $self->{result_values}->{free};
}
my %total_options = ();
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1;
}
$self->{output}->perfdata_add(
label => $label, unit => 'B',
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
nlabel => $nlabel,
value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
min => 0, max => $self->{result_values}->{total}
);
}
sub custom_usage_threshold {
my ($self, %options) = @_;
my ($exit, $threshold_value);
$threshold_value = $self->{result_values}->{used};
$threshold_value = $self->{result_values}->{free} if (defined($self->{instance_mode}->{option_results}->{free}));
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
}
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]);
return $exit;
}
sub custom_usage_output {
my ($self, %options) = @_;
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
my $msg = sprintf("Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_space_absolute});
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute});
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used_space_absolute});
my $msg = sprintf(
'Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)',
$total_size_value . " " . $total_size_unit,
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used_space_absolute},
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free_space_absolute}
);
return $msg;
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
if ($self->{result_values}->{total} <= 0) {
$self->{error_msg} = 'size is 0';
return -20;
}
$self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'};
$self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0;
}
sub custom_provisioned_output {
my ($self, %options) = @_;
my ($total_uncomitted_value, $total_uncommitted_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_uncommitted});
my $msg = sprintf("Provisioned: %s (%.2f%%)",
$total_uncomitted_value . " " . $total_uncommitted_unit,
$self->{result_values}->{prct_uncommitted});
my $msg = sprintf(
'Provisioned: %s (%.2f%%)',
$total_uncomitted_value . " " . $total_uncommitted_unit,
$self->{result_values}->{prct_uncommitted}
);
return $msg;
}
@ -127,15 +71,15 @@ sub custom_provisioned_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
$self->{result_values}->{total_space} = $options{new_datas}->{$self->{instance} . '_total_space'};
if ($self->{result_values}->{total} <= 0) {
if ($self->{result_values}->{total_space} <= 0) {
return -10;
}
$self->{result_values}->{total_uncommitted} =
($self->{result_values}->{total} - $options{new_datas}->{$self->{instance} . '_free'}) + $options{new_datas}->{$self->{instance} . '_uncommitted'};
$self->{result_values}->{prct_uncommitted} = $self->{result_values}->{total_uncommitted} * 100 / $self->{result_values}->{total};
($self->{result_values}->{total_space} - $options{new_datas}->{$self->{instance} . '_free_space'}) + $options{new_datas}->{$self->{instance} . '_uncommitted'};
$self->{result_values}->{prct_uncommitted} = $self->{result_values}->{total_uncommitted} * 100 / $self->{result_values}->{total_space};
return 0;
}
@ -157,21 +101,40 @@ sub set_counters {
}
},
{ label => 'usage', nlabel => 'datastore.space.usage.bytes', set => {
key_values => [ { name => 'display' }, { name => 'free' }, { name => 'total' } ],
closure_custom_calc => $self->can('custom_usage_calc'),
key_values => [ { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ],
closure_custom_output => $self->can('custom_usage_output'),
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
perfdatas => [
{ label => 'used', value => 'used_space_absolute', template => '%d', min => 0, max => 'total_space_absolute',
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'usage-free', nlabel => 'datastore.space.free.bytes', display_ok => 0, set => {
key_values => [ { name => 'free_space' }, { name => 'used_space' }, { name => 'prct_used_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ],
closure_custom_output => $self->can('custom_usage_output'),
perfdatas => [
{ label => 'free', value => 'free_space_absolute', template => '%d', min => 0, max => 'total_space_absolute',
unit => 'B', cast_int => 1, label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'usage-prct', nlabel => 'datastore.space.usage.percentage', display_ok => 0, set => {
key_values => [ { name => 'prct_used_space' }, { name => 'display' } ],
output_template => 'used : %.2f %%',
perfdatas => [
{ label => 'used_prct', value => 'prct_used_space_absolute', template => '%.2f', min => 0, max => 100,
unit => '%', label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'provisioned', nlabel => 'datastore.space.provisioned.bytes', set => {
key_values => [ { name => 'display' }, { name => 'uncommitted' }, { name => 'total' }, { name => 'free' } ],
key_values => [ { name => 'display' }, { name => 'uncommitted' }, { name => 'total_space' }, { name => 'free_space' } ],
closure_custom_calc => $self->can('custom_provisioned_calc'),
closure_custom_output => $self->can('custom_provisioned_output'),
threshold_use => 'prct_uncommitted',
perfdatas => [
{ label => 'provisioned', value => 'total_uncommitted', template => '%s', unit => 'B',
min => 0, max => 'total', label_extra_instance => 1 },
min => 0, max => 'total_space', label_extra_instance => 1 },
],
}
},
@ -190,14 +153,14 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
"datastore-name:s" => { name => 'datastore_name' },
"filter" => { name => 'filter' },
"scope-datacenter:s" => { name => 'scope_datacenter' },
"units:s" => { name => 'units', default => '%' },
"free" => { name => 'free' },
"unknown-status:s" => { name => 'unknown_status', default => '%{accessible} !~ /^true|1$/i' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '' },
'datastore-name:s' => { name => 'datastore_name' },
'filter' => { name => 'filter' },
'scope-datacenter:s' => { name => 'scope_datacenter' },
'units:s' => { name => 'units', default => '%' },
'free' => { name => 'free' },
'unknown-status:s' => { name => 'unknown_status', default => '%{accessible} !~ /^true|1$/i' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '' },
});
return $self;
@ -205,6 +168,15 @@ sub new {
sub check_options {
my ($self, %options) = @_;
# Compatibility
$self->compat_threshold_counter(%options,
compat => {
th => [ ['usage', { free => 'usage-free', prct => 'usage-prct'} ], [ 'datastore.space.usage.bytes', { free => 'datastore.space.free.bytes', prct => 'datastore.space.usage.percentage' } ] ],
units => $options{option_results}->{units}, free => $options{option_results}->{free}
}
);
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
@ -214,19 +186,48 @@ sub check_options {
}
}
sub custom_usage_calc {
my ($self, %options) = @_;
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
if ($self->{result_values}->{total} <= 0) {
$self->{error_msg} = 'size is 0';
return -20;
}
$self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'};
$self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free};
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
return 0;
}
sub manage_selection {
my ($self, %options) = @_;
$self->{datastore} = {};
my $response = $options{custom}->execute(params => $self->{option_results},
command => 'datastoreusage');
my $response = $options{custom}->execute(
params => $self->{option_results},
command => 'datastoreusage'
);
foreach my $ds_id (keys %{$response->{data}}) {
my $ds_name = $response->{data}->{$ds_id}->{name};
if ($response->{data}->{$ds_id}->{size} <= 0) {
$self->{output}->output_add(long_msg => "skipping datastore '" . $ds_name . "': no total size");
next;
}
$self->{datastore}->{$ds_name} = {
display => $ds_name,
accessible => $response->{data}->{$ds_id}->{accessible},
free => $response->{data}->{$ds_id}->{free},
total => $response->{data}->{$ds_id}->{size},
used_space => $response->{data}->{$ds_id}->{size} - $response->{data}->{$ds_id}->{free},
free_space => $response->{data}->{$ds_id}->{free},
total_space => $response->{data}->{$ds_id}->{size},
prct_used_space => ($response->{data}->{$ds_id}->{size} - $response->{data}->{$ds_id}->{free}) * 100 / $response->{data}->{$ds_id}->{size},
prct_free_space => $response->{data}->{$ds_id}->{free} * 100 / $response->{data}->{$ds_id}->{size},
uncommitted => $response->{data}->{$ds_id}->{uncommitted},
};
}
@ -254,14 +255,6 @@ Datastore name is a regexp.
Search in following datacenter(s) (can be a regexp).
=item B<--units>
Units of thresholds (Default: '%') ('%', 'B').
=item B<--free>
Thresholds are on free space left.
=item B<--unknown-status>
Set warning threshold for status (Default: '%{accessible} !~ /^true|1$/i').
@ -277,15 +270,11 @@ Can used special variables like: %{accessible}
Set critical threshold for status (Default: '').
Can used special variables like: %{accessible}
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Threshold warning.
Can be: 'usage', 'provisioned'.
=item B<--critical-*>
Threshold critical.
Can be: 'usage', 'provisioned'.
Thresholds.
Can be: Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%),
'provisioned'.
=back

View File

@ -44,7 +44,7 @@ sub new {
}
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port'},
'proto:s' => { name => 'proto' },
@ -129,11 +129,6 @@ sub settings {
$self->build_options_for_httplib();
$self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8');
$self->{http}->add_header(key => 'Accept', value => 'application/json;charset=UTF-8');
if (defined($self->{session_id})) {
$self->{http}->add_header(key => 'vmware-api-session-id', value => $self->{session_id});
} else {
$self->{http}->add_header(key => 'vmware-api-session-id', value => 'null');
}
$self->{http}->set_options(%{$self->{option_results}});
}
@ -158,6 +153,7 @@ sub clean_session_id {
my $datas = { last_timestamp => time() };
$options{statefile}->write(data => $datas);
$self->{session_id} = undef;
$self->{http}->add_header(key => 'vmware-api-session-id', value => undef);
}
sub authenticate {
@ -165,7 +161,7 @@ sub authenticate {
my $has_cache_file = $options{statefile}->read(statefile => 'vcsa_api_' . md5_hex($self->{option_results}->{hostname}) . '_' . md5_hex($self->{option_results}->{api_username}));
my $session_id = $options{statefile}->get(name => 'session_id');
if ($has_cache_file == 0 || !defined($session_id)) {
my $content = $self->{http}->request(
method => 'POST',
@ -195,6 +191,7 @@ sub authenticate {
}
$self->{session_id} = $session_id;
$self->{http}->add_header(key => 'vmware-api-session-id', value => $self->{session_id});
}
sub request_api {
@ -204,13 +201,14 @@ sub request_api {
if (!defined($self->{session_id})) {
$self->authenticate(statefile => $self->{cache});
}
my $content = $self->{http}->request(%options,
warning_status => '', unknown_status => '', critical_status => ''
);
# Maybe there is an issue with the session_id. So we retry.
if ($self->{http}->get_code() != 200) {
$self->clean_session_id();
$self->clean_session_id(statefile => $self->{cache});
$self->authenticate(statefile => $self->{cache});
$content = $self->{http}->request(%options,
warning_status => '', unknown_status => '', critical_status => ''
@ -222,6 +220,10 @@ sub request_api {
$self->{output}->add_option_msg(short_msg => "Error while retrieving data (add --debug option for detailed message)");
$self->{output}->option_exit();
}
if ($self->{http}->get_code() != 200) {
$self->{output}->add_option_msg(short_msg => 'api request error: ' . (defined($decoded->{type}) ? $decoded->{type} : 'unknown'));
$self->{output}->option_exit();
}
return $decoded;
}

View File

@ -114,6 +114,10 @@ Check service health.
=over 8
=item B<--filter-service>
Filter service (can be a regexp).
=item B<--unknown-status>
Set unknown threshold for status.

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '0.1';
%{$self->{modes}} = (
'hardware' => 'apps::vmware::wsman::mode::hardware',
);
'hardware' => 'apps::vmware::wsman::mode::hardware',
);
return $self;
}

View File

@ -31,10 +31,10 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'channel-usage' => 'apps::voip::asterisk::ami::mode::channelusage',
'dahdi-status' => 'apps::voip::asterisk::ami::mode::dahdistatus',
'sip-peers-usage' => 'apps::voip::asterisk::ami::mode::sippeersusage',
);
'channel-usage' => 'apps::voip::asterisk::ami::mode::channelusage',
'dahdi-status' => 'apps::voip::asterisk::ami::mode::dahdistatus',
'sip-peers-usage' => 'apps::voip::asterisk::ami::mode::sippeersusage',
);
$self->{custom_modes}{api} = 'apps::voip::asterisk::ami::custom::api';
return $self;

View File

@ -31,8 +31,8 @@ sub new {
$self->{version} = '1.0';
%{$self->{modes}} = (
'job-status' => 'apps::vtom::restapi::mode::jobstatus',
);
'job-status' => 'apps::vtom::restapi::mode::jobstatus',
);
$self->{custom_modes}{api} = 'apps::vtom::restapi::custom::api';
return $self;

View File

@ -38,12 +38,6 @@ sub new {
return $self;
}
sub init {
my ( $self, %options ) = @_;
$self->SUPER::init(%options);
}
1;
__END__

View File

@ -91,6 +91,7 @@ sub run {
$ap{group} = $result->{wlanAPGroupName};
$ap{location} = $result->{wlanAPLocation};
$ap{status} = $result->{wlanAPStatus};
$ap{type} = "ap";
push @disco_data, \%ap;
}

View File

@ -63,16 +63,19 @@ sub check_fan_envmon {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonFanStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance));
next if ($self->check_filter(section => 'fan', instance => $instance, name => $result->{ciscoEnvMonFanStatusDescr}));
next if ($result->{ciscoEnvMonFanState} =~ /not present/i &&
$self->absent_problem(section => 'fan', instance => $instance));
$self->absent_problem(section => 'fan', instance => $instance, name => $result->{ciscoEnvMonFanStatusDescr}));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is %s [instance: %s].",
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState},
$instance
));
my $exit = $self->get_severity(section => 'fan', value => $result->{ciscoEnvMonFanState});
$self->{output}->output_add(
long_msg => sprintf(
"fan '%s' status is %s [instance: %s].",
$result->{ciscoEnvMonFanStatusDescr}, $result->{ciscoEnvMonFanState},
$instance
)
);
my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{ciscoEnvMonFanState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("fan '%s' status is %s",
@ -94,12 +97,16 @@ sub check_fan_entity {
my $fan_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFanTrayOperStatus}, instance => $instance);
next if ($self->check_filter(section => 'fan', instance => $instance));
next if ($self->check_filter(section => 'fan', instance => $instance, name => $fan_descr));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Fan '%s' status is %s [instance: %s]",
$fan_descr, $result->{cefcFanTrayOperStatus}, $instance));
my $exit = $self->get_severity(section => 'fan', value => $result->{cefcFanTrayOperStatus});
$self->{output}->output_add(
long_msg => sprintf(
"Fan '%s' status is %s [instance: %s]",
$fan_descr, $result->{cefcFanTrayOperStatus}, $instance
)
);
my $exit = $self->get_severity(section => 'fan', instance => $instance, value => $result->{cefcFanTrayOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s/%s' status is %s", $fan_descr, $instance, $result->{cefcFanTrayOperStatus}));
@ -118,4 +125,4 @@ sub check {
check_fan_entity($self);
}
1;
1;

View File

@ -79,12 +79,12 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcModuleOperStatus}, instance => $instance);
my $module_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
next if ($self->check_filter(section => 'module', instance => $instance));
next if ($self->check_filter(section => 'module', instance => $instance, name => $module_descr));
$self->{components}->{module}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Module '%s' status is %s [instance: %s]",
$module_descr, $result->{cefcModuleOperStatus}, $instance));
my $exit = $self->get_severity(section => 'module', value => $result->{cefcModuleOperStatus});
my $exit = $self->get_severity(section => 'module', instance => $instance, value => $result->{cefcModuleOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Module '%s/%s' status is %s", $module_descr,
@ -93,4 +93,4 @@ sub check {
}
}
1;
1;

View File

@ -61,12 +61,12 @@ sub check {
next;
}
next if ($self->check_filter(section => 'physical', instance => $instance));
next if ($self->check_filter(section => 'physical', instance => $instance, name => $physical_descr));
$self->{components}->{physical}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Physical '%s' status is %s [instance: %s]",
$physical_descr, $result->{cefcPhysicalStatus}, $instance));
my $exit = $self->get_severity(section => 'physical', value => $result->{cefcPhysicalStatus});
my $exit = $self->get_severity(section => 'physical', instance => $instance, value => $result->{cefcPhysicalStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Physical '%s/%s' status is %s", $physical_descr,
@ -75,4 +75,4 @@ sub check {
}
}
1;
1;

View File

@ -79,16 +79,16 @@ sub check_psu_envmon {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_ciscoEnvMonSupplyStatusEntry}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
next if ($self->check_filter(section => 'psu', instance => $instance, name => $result->{ciscoEnvMonSupplyStatusDescr}));
next if ($result->{ciscoEnvMonSupplyState} =~ /not present/i &&
$self->absent_problem(section => 'psu', instance => $instance));
$self->absent_problem(section => 'psu', instance => $instance, name => $result->{ciscoEnvMonSupplyStatusDescr}));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s] [source: %s]",
$result->{ciscoEnvMonSupplyStatusDescr}, $result->{ciscoEnvMonSupplyState},
$instance, $result->{ciscoEnvMonSupplySource}
));
my $exit = $self->get_severity(section => 'psu', value => $result->{ciscoEnvMonSupplyState});
my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{ciscoEnvMonSupplyState});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s' status is %s",
@ -110,12 +110,12 @@ sub check_psu_entity {
my $psu_descr = $self->{results}->{$oid_entPhysicalDescr}->{$oid_entPhysicalDescr . '.' . $instance};
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cefcFRUPowerOperStatus}, instance => $instance);
next if ($self->check_filter(section => 'psu', instance => $instance));
next if ($self->check_filter(section => 'psu', instance => $instance, name => $psu_descr));
$self->{components}->{psu}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Power supply '%s' status is %s [instance: %s]",
$psu_descr, $result->{cefcFRUPowerOperStatus}, $instance));
my $exit = $self->get_severity(section => 'psu', value => $result->{cefcFRUPowerOperStatus});
my $exit = $self->get_severity(section => 'psu', instance => $instance, value => $result->{cefcFRUPowerOperStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power supply '%s/%s' status is %s", $psu_descr, $instance, $result->{cefcFRUPowerOperStatus}));
@ -134,4 +134,4 @@ sub check {
check_psu_entity($self);
}
1;
1;

Some files were not shown because too many files have changed in this diff Show More