commit
54c6326d93
|
@ -34,19 +34,19 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"config:s" => { name => 'config' },
|
||||
"language:s" => { name => 'language', default => 'en' },
|
||||
"dfsr" => { name => 'dfsr' },
|
||||
"noeventlog" => { name => 'noeventlog' },
|
||||
"nomachineaccount" => { name => 'nomachineaccount' },
|
||||
"timeout:s" => { name => 'timeout', default => 30 },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
'config:s' => { name => 'config' },
|
||||
'language:s' => { name => 'language', default => 'en' },
|
||||
'dfsr' => { name => 'dfsr' },
|
||||
'noeventlog' => { name => 'noeventlog' },
|
||||
'nomachineaccount' => { name => 'nomachineaccount' },
|
||||
'timeout:s' => { name => 'timeout', default => 30 },
|
||||
});
|
||||
|
||||
$self->{os_is2003} = 0;
|
||||
$self->{os_is2008} = 0;
|
||||
$self->{os_is2012} = 0;
|
||||
$self->{os_is2016} = 0;
|
||||
|
||||
$self->{msg} = { global => undef, ok => undef, warning => undef, critical => undef };
|
||||
return $self;
|
||||
|
@ -72,12 +72,15 @@ sub check_version {
|
|||
# 5.1, 5.2 => XP/2003
|
||||
# 6.0, 6.1 => Vista/7/2008
|
||||
# 6.2, 6.3 => 2012
|
||||
# 10.0 => 2016, 2019
|
||||
if ($ver_major == 5 && ($ver_minor == 1 || $ver_minor == 2)) {
|
||||
$self->{os_is2003} = 1;
|
||||
} elsif ($ver_major == 6 && ($ver_minor == 0 || $ver_minor == 1)) {
|
||||
$self->{os_is2008} = 1;
|
||||
} elsif ($ver_major == 6 && ($ver_minor == 2 || $ver_minor == 3)) {
|
||||
$self->{os_is2012} = 1;
|
||||
} elsif ($ver_major == 10 && $ver_minor == 0) {
|
||||
$self->{os_is2016} = 1;
|
||||
} else {
|
||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
||||
short_msg => 'OS version ' . $ver_major . '.' . $ver_minor . ' not managed.');
|
||||
|
@ -136,19 +139,21 @@ sub dcdiag {
|
|||
my $dcdiag_cmd = 'dcdiag /test:services /test:replications /test:advertising /test:fsmocheck /test:ridmanager';
|
||||
$dcdiag_cmd .= ' /test:machineaccount' if (!defined($self->{option_results}->{nomachineaccount}));
|
||||
$dcdiag_cmd .= ' /test:frssysvol' if ($self->{os_is2003} == 1);
|
||||
$dcdiag_cmd .= ' /test:sysvolcheck' if ($self->{os_is2008} == 1 || $self->{os_is2012} == 1);
|
||||
$dcdiag_cmd .= ' /test:sysvolcheck' if ($self->{os_is2008} == 1 || $self->{os_is2012} == 1 || $self->{os_is2016} == 1);
|
||||
|
||||
if (!defined($self->{option_results}->{noeventlog})) {
|
||||
$dcdiag_cmd .= ' /test:frsevent /test:kccevent' if ($self->{os_is2003} == 1);
|
||||
$dcdiag_cmd .= ' /test:frsevent /test:kccevent' if (($self->{os_is2008} == 1 || $self->{os_is2012} == 1) && !defined($self->{option_results}->{dfsr}));
|
||||
$dcdiag_cmd .= ' /test:dfsrevent /test:kccevent' if (($self->{os_is2008} == 1 || $self->{os_is2012} == 1) && defined($self->{option_results}->{dfsr}));
|
||||
$dcdiag_cmd .= ' /test:frsevent /test:kccevent' if (($self->{os_is2008} == 1 || $self->{os_is2012} == 1 || $self->{os_is2016} == 1) && !defined($self->{option_results}->{dfsr}));
|
||||
$dcdiag_cmd .= ' /test:dfsrevent /test:kccevent' if (($self->{os_is2008} == 1 || $self->{os_is2012} == 1 || $self->{os_is2016} == 1) && defined($self->{option_results}->{dfsr}));
|
||||
}
|
||||
|
||||
my ($stdout) = centreon::plugins::misc::windows_execute(output => $self->{output},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
command => $dcdiag_cmd,
|
||||
command_path => undef,
|
||||
command_options => undef);
|
||||
my ($stdout) = centreon::plugins::misc::windows_execute(
|
||||
output => $self->{output},
|
||||
timeout => $self->{option_results}->{timeout},
|
||||
command => $dcdiag_cmd,
|
||||
command_path => undef,
|
||||
command_options => undef
|
||||
);
|
||||
|
||||
my $match = 0;
|
||||
while ($stdout =~ /$self->{msg}->{global}/imsg) {
|
||||
|
|
|
@ -49,7 +49,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"sending-member:s" => { name => 'sending_member' },
|
||||
|
|
|
@ -32,7 +32,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"domain:s" => { name => 'domain', },
|
||||
|
|
|
@ -32,7 +32,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"config:s" => { name => 'config', },
|
||||
|
|
|
@ -118,7 +118,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -206,7 +206,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /Warning/i' },
|
||||
|
|
|
@ -72,7 +72,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /Warning/i' },
|
||||
|
|
|
@ -72,7 +72,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /Warning/i' },
|
||||
|
|
|
@ -96,7 +96,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /Warning/i' },
|
||||
|
|
|
@ -104,7 +104,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /Warning/i' },
|
||||
|
|
|
@ -129,7 +129,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{status} =~ /Warning/i' },
|
||||
|
|
|
@ -60,7 +60,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -98,7 +98,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -73,7 +73,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
|
|
|
@ -92,7 +92,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -105,7 +105,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -105,7 +105,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -98,7 +98,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', },
|
||||
|
|
|
@ -32,7 +32,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', },
|
||||
|
|
|
@ -32,7 +32,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', },
|
||||
|
|
|
@ -199,7 +199,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"host-pattern:s" => { name => 'host_pattern', default => 'all' },
|
||||
"prettify" => { name => 'prettify' },
|
||||
|
|
|
@ -22,7 +22,6 @@ package apps::automation::ansible::tower::custom::towercli;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use DateTime;
|
||||
use JSON::XS;
|
||||
|
||||
sub new {
|
||||
|
|
|
@ -92,17 +92,11 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"group" => { name => 'group' },
|
||||
"inventory" => { name => 'inventory' },
|
||||
|
|
|
@ -140,19 +140,13 @@ sub new {
|
|||
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-inventory" => { name => 'filter_inventory' },
|
||||
'filter-inventory:s' => { name => 'filter_inventory' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -0,0 +1,259 @@
|
|||
#
|
||||
# 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::arcserve::udp::mssql::mode::jobstatus;
|
||||
|
||||
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 {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'ok';
|
||||
my $message;
|
||||
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||
|
||||
# To exclude some OK
|
||||
if (defined($self->{instance_mode}->{option_results}->{ok_status}) && $self->{instance_mode}->{option_results}->{ok_status} ne '' &&
|
||||
eval "$self->{instance_mode}->{option_results}->{ok_status}") {
|
||||
$status = 'ok';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{critical_status}) && $self->{instance_mode}->{option_results}->{critical_status} ne '' &&
|
||||
eval "$self->{instance_mode}->{option_results}->{critical_status}") {
|
||||
$status = 'critical';
|
||||
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
|
||||
eval "$self->{instance_mode}->{option_results}->{warning_status}") {
|
||||
$status = 'warning';
|
||||
}
|
||||
};
|
||||
if (defined($message)) {
|
||||
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf('status : %s (%s) [type: %s] [remote hostname: %s] [plan name: %s] [end time: %s]',
|
||||
$self->{result_values}->{status} == 1 ? 'ok' : 'failed',
|
||||
$self->{result_values}->{status},
|
||||
$self->{result_values}->{type},
|
||||
$self->{result_values}->{rhostname},
|
||||
$self->{result_values}->{plan_name},
|
||||
scalar(localtime($self->{result_values}->{end_time}))
|
||||
);
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0 },
|
||||
{ name => 'job', type => 1, cb_prefix_output => 'prefix_job_output', message_multiple => 'All jobs are ok' },
|
||||
];
|
||||
|
||||
$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 => 'rhostname' }, { name => 'plan_name' },
|
||||
{ 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 => $self->can('custom_status_threshold'),
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-server-name:s' => { name => 'filter_server_name' },
|
||||
'filter-type:s' => { name => 'filter_type' },
|
||||
'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 => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{status} != 1' },
|
||||
'timezone:s' => { name => 'timezone' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => [
|
||||
'ok_status', 'warning_status', 'critical_status']
|
||||
);
|
||||
|
||||
if (defined($self->{option_results}->{timezone}) && $self->{option_results}->{timezone} ne '') {
|
||||
$ENV{TZ} = $self->{option_results}->{timezone};
|
||||
}
|
||||
}
|
||||
|
||||
sub prefix_job_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "job '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $query = q{
|
||||
SELECT
|
||||
lj.jobId,
|
||||
lj.jobStatus,
|
||||
rhostname,
|
||||
DATEDIFF(s, '1970-01-01 00:00:00', lj.jobLocalStartTime) as start_time,
|
||||
DATEDIFF(s, '1970-01-01 00:00:00', lj.jobLocalEndTime) as end_time,
|
||||
ep.name,
|
||||
lj.jobType,
|
||||
lj.jobStatus
|
||||
FROM as_edge_d2dJobHistory_lastJob lj LEFT OUTER JOIN as_edge_policy ep ON lj.planUUID = ep.uuid,
|
||||
as_edge_host h
|
||||
WHERE lj.agentId = h.rhostid
|
||||
};
|
||||
$options{sql}->connect();
|
||||
$options{sql}->query(query => $query);
|
||||
|
||||
$self->{global} = { total => 0 };
|
||||
$self->{job} = {};
|
||||
my ($count, $current_time) = (0, time());
|
||||
while ((my $row = $options{sql}->fetchrow_hashref())) {
|
||||
my $rhostname = defined($row->{rhostname}) && $row->{rhostname} ne '' ? $row->{rhostname} : 'unknown';
|
||||
my $plan_name = defined($row->{name}) && $row->{name} ne '' ? $row->{name} : 'unknown';
|
||||
if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
|
||||
$row->{jobType} !~ /$self->{option_results}->{filter_type}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping job '" . $row->{jobId} . "': no matching filter type.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_end_time}) && $self->{option_results}->{filter_end_time} =~ /[0-9]+/ &&
|
||||
defined($row->{end_time}) && $row->{end_time} =~ /[0-9]+/ && $row->{end_time} < ($current_time - $self->{option_results}->{filter_end_time})) {
|
||||
$self->{output}->output_add(long_msg => "skipping job '" . $row->{jobId} . "': end time too old.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_start_time}) && $self->{option_results}->{filter_start_time} =~ /[0-9]+/ &&
|
||||
defined($row->{start_time}) && $row->{start_time} =~ /[0-9]+/ && $row->{start_time} < ($current_time - $self->{option_results}->{filter_start_time})) {
|
||||
$self->{output}->output_add(long_msg => "skipping job '" . $row->{jobId} . "': start time too old.", debug => 1);
|
||||
next;
|
||||
}
|
||||
if (defined($self->{option_results}->{filter_server_name}) && $self->{option_results}->{filter_server_name} ne '' &&
|
||||
$row->{rhostname} !~ /$self->{option_results}->{filter_server_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping job '" . $row->{jobId} . "': no matching filter type.", debug => 1);
|
||||
next;
|
||||
}
|
||||
|
||||
my $elapsed_time = defined($row->{start_time}) ? $current_time - $row->{start_time} : -1;
|
||||
$self->{job}->{$row->{jobId}} = {
|
||||
display => $row->{jobId},
|
||||
elapsed_time => $elapsed_time,
|
||||
status => $row->{jobStatus},
|
||||
type => $row->{jobType},
|
||||
rhostname => $rhostname,
|
||||
plan_name => $plan_name,
|
||||
end_time => $row->{end_time},
|
||||
};
|
||||
|
||||
$self->{global}->{total}++;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check job status.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-server-name>
|
||||
|
||||
Filter job server 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>
|
||||
|
||||
Timezone of mssql server (If not set, we use current server execution timezone).
|
||||
|
||||
=item B<--ok-status>
|
||||
|
||||
Set ok threshold for status (Default: '%{status} == 1')
|
||||
Can used special variables like: %{display}, %{status}
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status (Default: '%{status} == 1')
|
||||
Can used special variables like: %{display}, %{status}, %{type}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{status} != 1').
|
||||
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
|
|
@ -85,7 +85,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -51,7 +51,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -66,7 +66,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -203,30 +203,29 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$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 => 'bpdbjobs' },
|
||||
"command-path:s" => { name => 'command_path' },
|
||||
"command-options:s" => { name => 'command_options', default => '-report -most_columns' },
|
||||
"exec-only" => { name => 'exec_only' },
|
||||
"filter-policy-name:s" => { name => 'filter_policy_name' },
|
||||
"filter-type:s" => { name => 'filter_type' },
|
||||
"filter-end-time:s" => { name => 'filter_end_time', default => 86400 },
|
||||
"filter-start-time:s" => { name => 'filter_start_time' },
|
||||
"ok-status:s" => { name => 'ok_status', default => '%{status} == 0' },
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{status} == 1' },
|
||||
"critical-status:s" => { name => 'critical_status', default => '%{status} > 1' },
|
||||
"warning-long:s" => { name => 'warning_long' },
|
||||
"critical-long:s" => { name => 'critical_long' },
|
||||
"warning-frozen:s" => { name => 'warning_frozen' },
|
||||
"critical-frozen:s" => { name => 'critical_frozen', default => '%{state} =~ /active|queue/ && %{kb} == 0' },
|
||||
'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 => 'bpdbjobs' },
|
||||
'command-path:s' => { name => 'command_path' },
|
||||
'command-options:s' => { name => 'command_options', default => '-report -most_columns' },
|
||||
'exec-only' => { name => 'exec_only' },
|
||||
'filter-policy-name:s' => { name => 'filter_policy_name' },
|
||||
'filter-type:s' => { name => 'filter_type' },
|
||||
'filter-end-time:s' => { name => 'filter_end_time', default => 86400 },
|
||||
'filter-start-time:s' => { name => 'filter_start_time' },
|
||||
'ok-status:s' => { name => 'ok_status', default => '%{status} == 0' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '%{status} == 1' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{status} > 1' },
|
||||
'warning-long:s' => { name => 'warning_long' },
|
||||
'critical-long:s' => { name => 'critical_long' },
|
||||
'warning-frozen:s' => { name => 'warning_frozen' },
|
||||
'critical-frozen:s' => { name => 'critical_frozen', default => '%{state} =~ /active|queue/ && %{kb} == 0' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -311,7 +310,7 @@ sub manage_selection {
|
|||
($values[0], $values[1], $values[2], $values[3], $values[4], $values[5], $values[8], $values[10], $values[14], $values[33]);
|
||||
|
||||
$job_pname = defined($job_pname) && $job_pname ne '' ? $job_pname : 'unknown';
|
||||
$job_status = defined($job_status) && $job_status =~ /[0-9]/ ? $job_status : undef;
|
||||
$job_status = defined($job_status) && $job_status =~ /[0-9]/ ? $job_status : -1;
|
||||
if (defined($self->{option_results}->{filter_policy_name}) && $self->{option_results}->{filter_policy_name} ne '' &&
|
||||
$job_pname !~ /$self->{option_results}->{filter_policy_name}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping job '" . $job_pname . "/" . $job_id . "': no matching filter.", debug => 1);
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -110,7 +110,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"remote" => { name => 'remote' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -141,7 +141,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -148,7 +148,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -154,7 +154,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
|
|
@ -72,7 +72,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-time:s" => { name => 'filter_time', default => '1' },
|
||||
|
|
|
@ -111,7 +111,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
|
|
@ -65,7 +65,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
|
|
@ -91,7 +91,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-clientname:s" => { name => 'filter_clientname' },
|
||||
|
|
|
@ -116,7 +116,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-volume:s" => { name => 'filter_volume' },
|
||||
|
|
|
@ -138,7 +138,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
|
|
|
@ -32,7 +32,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"timeout:s" => { name => 'timeout', default => 50 },
|
||||
|
|
|
@ -93,7 +93,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
|
|
|
@ -82,7 +82,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
|
|
@ -30,7 +30,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning' },
|
||||
|
|
|
@ -33,7 +33,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', default => '8086'},
|
||||
|
|
|
@ -33,7 +33,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"centreon-config:s" => { name => 'centreon_config', default => '/etc/centreon/centreon-config.pm' },
|
||||
"bam-id:s" => { name => 'bam_id', },
|
||||
|
@ -84,7 +83,7 @@ sub run {
|
|||
value => $current_level,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0, max => 0,
|
||||
min => 0, max => 100,
|
||||
);
|
||||
|
||||
$self->{output}->display();
|
||||
|
|
|
@ -103,7 +103,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"broker-stats-file:s@" => { name => 'broker_stats_file' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning' },
|
||||
|
|
|
@ -55,7 +55,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"oid-trap:s" => { name => 'oid_trap', default => '.1.3.6.1.4.1.50000.1.1' },
|
||||
|
|
|
@ -32,7 +32,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"status:s" => { name => 'status' },
|
||||
|
|
|
@ -36,7 +36,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"centreon-config:s" => { name => 'centreon_config', default => '/etc/centreon/centreon-config.pm' },
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
#
|
||||
# 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::centreon::local::mode::notsodummy;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::statefile;
|
||||
use Digest::MD5 qw(md5_hex);
|
||||
|
||||
my %errors_service = (0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN');
|
||||
my %errors_host = (0 => 'UP', 1 => 'DOWN');
|
||||
my %errors_hash = ('UP' => 'OK', 'DOWN' => 'CRITICAL');
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"status-sequence:s" => { name => 'status_sequence' },
|
||||
"host" => { name => 'host' },
|
||||
"restart-sequence" => { name => 'restart_sequence' },
|
||||
"show-sequence" => { name => 'show_sequence' },
|
||||
"output:s" => { name => 'output' },
|
||||
});
|
||||
|
||||
$self->{cache} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (!defined($self->{option_results}->{status_sequence}) || $self->{option_results}->{status_sequence} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --status option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{option_results}->{output}) || $self->{option_results}->{output} eq '') {
|
||||
$self->{output}->add_option_msg(short_msg => "Need to specify --output option.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
foreach my $status (split(',', $self->{option_results}->{status_sequence})) {
|
||||
if (!defined($self->{option_results}->{host}) && $status !~ /^[0-3]$/ && $status !~ /ok|warning|critical|unknown/i) {
|
||||
$self->{output}->add_option_msg(short_msg => "Status should be in '0,1,2,3' or 'ok,warning,critical,unknown' (case isensitive).");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (defined($self->{option_results}->{host}) && $status !~ /^[0-1]$/ && $status !~ /up|down/i) {
|
||||
$self->{output}->add_option_msg(short_msg => "Status should be in '0,1' or 'up,down' (case isensitive).");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
push @{$self->{status_sequence}}, $status;
|
||||
}
|
||||
|
||||
$self->{cache}->check_options(option_results => $self->{option_results});
|
||||
}
|
||||
|
||||
sub get_next_status {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $index;
|
||||
my $has_cache_file = $options{statefile}->read(statefile => 'centreon_notsodummy_' .
|
||||
md5_hex(@{$self->{status_sequence}}) . '_' . md5_hex($self->{option_results}->{output}));
|
||||
|
||||
if ($has_cache_file == 0 || $self->{option_results}->{restart_sequence}) {
|
||||
$index = 0;
|
||||
my $datas = { last_timestamp => time(), status_sequence => $self->{status_sequence}, status_sequence_index => $index };
|
||||
$options{statefile}->write(data => $datas);
|
||||
} else {
|
||||
$index = $options{statefile}->get(name => 'status_sequence_index');
|
||||
$index = ($index < scalar(@{$self->{status_sequence}} - 1)) ? $index + 1 : 0;
|
||||
my $datas = { last_timestamp => time(), status_sequence => $self->{status_sequence}, status_sequence_index => $index };
|
||||
$options{statefile}->write(data => $datas);
|
||||
}
|
||||
|
||||
return $self->{status_sequence}[$index], $index;
|
||||
}
|
||||
|
||||
sub get_sequence_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my @sequence_output;
|
||||
|
||||
my $i = 0;
|
||||
foreach my $status (split(',', $self->{option_results}->{status_sequence})) {
|
||||
$status = $errors_service{$status} if ($status =~ /^[0-3]$/ && !defined($self->{option_results}->{host}));
|
||||
$status = $errors_host{$status} if ($status =~ /^[0-1]$/ && defined($self->{option_results}->{host}));
|
||||
|
||||
push @sequence_output, uc($status) if ($i == $options{index});
|
||||
push @sequence_output, lc($status) if ($i != $options{index});
|
||||
$i++
|
||||
}
|
||||
|
||||
return join(',', @sequence_output);
|
||||
}
|
||||
|
||||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($status, $index) = $self->get_next_status(statefile => $self->{cache});
|
||||
my $status_label = $status;
|
||||
if (defined($self->{option_results}->{host})) {
|
||||
$status_label = $errors_host{$status} if ($status =~ /^[0-1]$/);
|
||||
$status = $errors_host{$status} if ($status =~ /^[0-1]$/);
|
||||
$status = $errors_hash{uc($status)};
|
||||
} else {
|
||||
$status_label = $errors_service{$status} if ($status =~ /^[0-3]$/);
|
||||
$status = $errors_service{$status} if ($status =~ /^[0-3]$/);
|
||||
}
|
||||
my $output = $self->{option_results}->{output};
|
||||
$output .= ' [' . $self->get_sequence_output(index => $index) . ']' if ($self->{option_results}->{show_sequence});
|
||||
|
||||
$self->{output}->output_add(
|
||||
severity => $status,
|
||||
short_msg => uc($status_label) . ': ' . $output
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => 'sequence.index.position', value => ++$index,
|
||||
min => 1, max => scalar(@{$self->{status_sequence}})
|
||||
);
|
||||
$self->{output}->display(nolabel => 1);
|
||||
$self->{output}->exit();
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Do a not-so-dummy check.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--status-sequence>
|
||||
|
||||
Comma separated sequence of statuses
|
||||
from which the mode should pick is
|
||||
return code from.
|
||||
(Example: --status-sequence='ok,critical,ok,ok' or --status-sequence='up,up,down' --host)
|
||||
(Should be numeric value between 0 and 3, or string in ok, warning, critical, unknown, up, down).
|
||||
|
||||
=item B<--host>
|
||||
|
||||
Host statuses.
|
||||
|
||||
=item B<--restart-sequence>
|
||||
|
||||
Restart the sequence from the beginning (ie. reset the sequence).
|
||||
|
||||
=item B<--show-sequence>
|
||||
|
||||
Show the sequence is the output.
|
||||
|
||||
=item B<--output>
|
||||
|
||||
Output to be returned.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -32,7 +32,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"broker-config:s@" => { name => 'broker_config' },
|
||||
|
|
|
@ -37,6 +37,7 @@ sub new {
|
|||
'downtime-trap' => 'apps::centreon::local::mode::downtimetrap',
|
||||
'dummy' => 'apps::centreon::local::mode::dummy',
|
||||
'metaservice' => 'apps::centreon::local::mode::metaservice',
|
||||
'not-so-dummy' => 'apps::centreon::local::mode::notsodummy',
|
||||
'retention-broker' => 'apps::centreon::local::mode::retentionbroker',
|
||||
);
|
||||
|
||||
|
|
|
@ -89,7 +89,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -80,7 +80,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -65,7 +65,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -49,7 +49,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
|
|
@ -58,7 +58,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters', default => '' },
|
||||
|
|
|
@ -158,7 +158,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {});
|
||||
return $self;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
|
|
|
@ -38,7 +38,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-global:s" => { name => 'warning_global', },
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
|
|
|
@ -29,7 +29,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
|
|
|
@ -0,0 +1,285 @@
|
|||
#
|
||||
# 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::centreon::restapi::custom::api;
|
||||
|
||||
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 = {};
|
||||
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-path:s" => { name => 'api_path' },
|
||||
"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->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http';
|
||||
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 80;
|
||||
$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_path} = (defined($self->{option_results}->{api_path})) ?
|
||||
$self->{option_results}->{api_path} : '/centreon/api/index.php';
|
||||
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10;
|
||||
|
||||
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 get_connection_infos {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return $self->{hostname} . '_' . $self->{http}->get_port();
|
||||
}
|
||||
|
||||
sub build_options_for_httplib {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{option_results}->{hostname} = $self->{hostname};
|
||||
$self->{option_results}->{timeout} = $self->{timeout};
|
||||
$self->{option_results}->{port} = $self->{port};
|
||||
$self->{option_results}->{proto} = $self->{proto};
|
||||
}
|
||||
|
||||
sub settings {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->build_options_for_httplib();
|
||||
$self->{http}->add_header(key => 'Accept', value => 'application/json');
|
||||
if (defined($self->{auth_token})) {
|
||||
$self->{http}->add_header(key => 'Centreon-Auth-Token', value => $self->{auth_token});
|
||||
$self->{http}->add_header(key => 'Content-Type', value => 'application/json');
|
||||
}
|
||||
$self->{http}->set_options(%{$self->{option_results}});
|
||||
}
|
||||
|
||||
sub get_auth_token {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $has_cache_file = $options{statefile}->read(statefile => 'centreon_api_' . md5_hex($self->{hostname}) .
|
||||
'_' . md5_hex($self->{api_username}));
|
||||
my $expires_on = $options{statefile}->get(name => 'expires_on');
|
||||
my $auth_token = $options{statefile}->get(name => 'auth_token');
|
||||
|
||||
if ($has_cache_file == 0 || !defined($auth_token) || (($expires_on - time()) < 10)) {
|
||||
my $post_param = [ 'username=' . $self->{api_username}, 'password=' . $self->{api_password} ];
|
||||
|
||||
$self->settings();
|
||||
|
||||
my $content = $self->{http}->request(
|
||||
method => 'POST',
|
||||
url_path => '/centreon/api/index.php?action=authenticate',
|
||||
post_param => $post_param
|
||||
);
|
||||
|
||||
my $decoded;
|
||||
eval {
|
||||
$decoded = JSON::XS->new->utf8->decode($content);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($decoded->{authToken})) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot get token");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$auth_token = $decoded->{authToken};
|
||||
my $datas = { last_timestamp => time(), auth_token => $decoded->{authToken}, expires_on => time() + 3600 };
|
||||
$options{statefile}->write(data => $datas);
|
||||
}
|
||||
|
||||
return $auth_token;
|
||||
}
|
||||
|
||||
sub request_api {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($self->{auth_token})) {
|
||||
$self->{auth_token} = $self->get_auth_token(statefile => $self->{cache});
|
||||
}
|
||||
|
||||
$self->settings();
|
||||
|
||||
my $encoded_form_post;
|
||||
eval {
|
||||
$encoded_form_post = JSON::XS->new->utf8->encode($options{query_form_post});
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot encode json request");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $content = $self->{http}->request(
|
||||
method => $options{method},
|
||||
url_path => $options{url_path},
|
||||
query_form_post => $encoded_form_post,
|
||||
critical_status => '', warning_status => '', unknown_status => ''
|
||||
);
|
||||
|
||||
my $decoded;
|
||||
eval {
|
||||
$decoded = JSON::XS->new->utf8->decode($content);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot decode json response");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return ($decoded, JSON::XS->new->utf8->pretty->encode($decoded));
|
||||
}
|
||||
|
||||
sub submit_result {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my ($response, $raw) = $self->request_api(
|
||||
method => 'POST',
|
||||
url_path => $self->{api_path} . '?action=submit&object=centreon_submit_results',
|
||||
query_form_post => $options{post_data}
|
||||
);
|
||||
|
||||
return ($response, $raw);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Centreon REST API
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Centreon Rest API custom mode
|
||||
|
||||
=head1 REST API OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--hostname>
|
||||
|
||||
Centreon hostname.
|
||||
|
||||
=item B<--port>
|
||||
|
||||
Port used (Default: 80)
|
||||
|
||||
=item B<--proto>
|
||||
|
||||
Specify https if needed (Default: 'http')
|
||||
|
||||
=item B<--api-username>
|
||||
|
||||
Centreon username.
|
||||
|
||||
=item B<--api-password>
|
||||
|
||||
Centreon password.
|
||||
|
||||
=item B<--api-path>
|
||||
|
||||
API base url path (Default: '/centreon/api/index.php').
|
||||
|
||||
=item B<--timeout>
|
||||
|
||||
Set HTTP timeout in seconds (Default: '10').
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<custom>.
|
||||
|
||||
=cut
|
|
@ -0,0 +1,156 @@
|
|||
#
|
||||
# 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::centreon::restapi::mode::submitresult;
|
||||
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output', skipped_code => { -10 => 1 } },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'results-202', nlabel => 'results.202.count', set => {
|
||||
key_values => [ { name => '202' } ],
|
||||
output_template => '202: %d',
|
||||
perfdatas => [
|
||||
{ value => '202_absolute', template => '%d', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'results-400', nlabel => 'results.400.count', set => {
|
||||
key_values => [ { name => '400' } ],
|
||||
output_template => '400: %d',
|
||||
perfdatas => [
|
||||
{ value => '400_absolute', template => '%d', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'results-404', nlabel => 'results.404.count', set => {
|
||||
key_values => [ { name => '404' } ],
|
||||
output_template => '404: %d',
|
||||
perfdatas => [
|
||||
{ value => '404_absolute', template => '%d', min => 0 },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Results ";
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
"host:s@" => { name => 'host' },
|
||||
"service:s@" => { name => 'service' },
|
||||
"status:s@" => { name => 'status' },
|
||||
"output:s@" => { name => 'output' },
|
||||
"perfdata:s@" => { name => 'perfdata' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $post_data;
|
||||
my $i = 0;
|
||||
foreach (@{$self->{option_results}->{host}}) {
|
||||
my %result;
|
||||
$result{updatetime} = time();
|
||||
$result{host} = $_;
|
||||
$result{service} = ${$self->{option_results}->{service}}[$i] if (defined(${$self->{option_results}->{service}}[$i]));
|
||||
$result{status} = ${$self->{option_results}->{status}}[$i];
|
||||
$result{output} = ${$self->{option_results}->{output}}[$i];
|
||||
$result{perfdata} = ${$self->{option_results}->{perfdata}}[$i] if (defined(${$self->{option_results}->{perfdata}}[$i]));
|
||||
push @{$post_data->{results}}, \%result;
|
||||
$i++;
|
||||
}
|
||||
|
||||
my ($response, $raw) = $options{custom}->submit_result(post_data => $post_data);
|
||||
|
||||
$self->{global} = { 202 => 0, 400 => 0, 404 => 0 };
|
||||
foreach my $result (@{$response->{results}}) {
|
||||
$self->{global}->{$result->{code}}++;
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => $raw);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Submit one or several results to the API.
|
||||
|
||||
Examples:
|
||||
perl centreon_plugins --plugin=apps::centreon::restapi::plugin --mode=submit-result --hostname=10.30.2.245
|
||||
--api-username=admin --api-password=centreon --host='MyHost' --service='TheService' --status=2 --output='Hi!'
|
||||
--perfdata='france=3,brazil=0' --verbose
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--host>
|
||||
|
||||
Hostname (Mandatory).
|
||||
|
||||
=item B<--service>
|
||||
|
||||
Service description (If result's for a service).
|
||||
|
||||
=item B<--status>
|
||||
|
||||
Status in 0, 1, 2, 3 or ok, warning, critical, unknown for services,
|
||||
or in 0, 1 or up, down for hosts (Mandatory).
|
||||
|
||||
=item B<--output>
|
||||
|
||||
Short output (Mandatory).
|
||||
|
||||
=item B<--perfdata>
|
||||
|
||||
Comma separated list of perfdata (Optionnal).
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
#
|
||||
# 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::centreon::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} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'submit-result' => 'apps::centreon::restapi::mode::submitresult',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{api} = 'apps::centreon::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Interacts with Centreon RestAPI.
|
||||
|
||||
=cut
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning' },
|
||||
|
|
|
@ -65,7 +65,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-poller:s" => { name => 'filter_poller' },
|
||||
|
|
|
@ -75,7 +75,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-host-queue:s" => { name => 'filter_host_queue' },
|
||||
|
|
|
@ -282,7 +282,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"config-file:s" => { name => 'config_file' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"tablename:s@" => { name => 'tablename' },
|
||||
|
|
|
@ -56,7 +56,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
});
|
||||
|
|
|
@ -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,12 +173,12 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -206,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 {
|
||||
|
@ -235,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} = {};
|
||||
|
@ -254,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} . "'";
|
||||
|
@ -275,7 +282,7 @@ 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 .= "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 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 ''));
|
||||
|
@ -326,24 +333,28 @@ sub manage_selection {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
@ -360,6 +371,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
|
||||
|
|
|
@ -41,7 +41,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname', default => 'api.checkmy.ws'},
|
||||
"port:s" => { name => 'port', },
|
||||
|
|
|
@ -71,7 +71,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-type:s" => { name => 'filter_type' },
|
||||
|
|
|
@ -77,7 +77,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters' },
|
||||
|
|
|
@ -75,7 +75,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||
|
|
|
@ -78,7 +78,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning-status:s" => { name => 'warning_status', default => '%{status} eq "activated" && %{expiry_days} < 60' },
|
||||
|
|
|
@ -142,7 +142,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters' },
|
||||
|
|
|
@ -68,7 +68,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"filter-counters:s" => { name => 'filter_counters' },
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
|
|
|
@ -20,80 +20,96 @@
|
|||
|
||||
package apps::citrix::local::mode::license;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
use base qw(centreon::plugins::templates::counter);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
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}),
|
||||
$self->{result_values}->{prct_used_absolute},
|
||||
$self->{perfdata}->change_bytes(value => $self->{result_values}->{free_absolute}),
|
||||
$self->{result_values}->{prct_free_absolute});
|
||||
return $msg;
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'global', type => 0, skipped_code => { -10 => 1 } },
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'usage', nlabel => 'licenses.usage.count', set => {
|
||||
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 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'usage-free', display_ok => 0, nlabel => 'licenses.free.count', set => {
|
||||
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 },
|
||||
],
|
||||
}
|
||||
},
|
||||
{ label => 'usage-prct', display_ok => 0, nlabel => 'licenses.usage.percentage', set => {
|
||||
key_values => [ { name => 'prct_used' } ],
|
||||
output_template => 'Licenses Used : %.2f %%',
|
||||
perfdatas => [
|
||||
{ value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %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 =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
"critical:s" => { name => 'critical', },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->output_add(severity => 'Ok',
|
||||
short_msg => "All licenses are ok");
|
||||
|
||||
my $wmi = Win32::OLE->GetObject('winmgmts:root\CitrixLicensing');
|
||||
if (!defined($wmi)) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cant create server object:" . Win32::OLE->LastError());
|
||||
$self->{output}->add_option_msg(short_msg => 'Cant create server object:' . Win32::OLE->LastError());
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
my $count = 0;
|
||||
my $inUseCount = 0;
|
||||
my $percentUsed = 100;
|
||||
|
||||
$self->{global} = { total => 0, used => 0 };
|
||||
my $query = "Select InUseCount,Count from Citrix_GT_License_Pool";
|
||||
my $resultset = $wmi->ExecQuery($query);
|
||||
foreach my $obj (in $resultset) {
|
||||
$inUseCount = $obj->{InUseCount};
|
||||
$count = $obj->{Count};
|
||||
$percentUsed = ($inUseCount / $count) * 100;
|
||||
|
||||
my $exit = $self->{perfdata}->threshold_check(value => $percentUsed, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => $percentUsed . "% licenses are used (" . $inUseCount . "/" . $count . ")");
|
||||
$self->{output}->perfdata_add(label => 'licenses_used',
|
||||
value => $inUseCount,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning', total => $count),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical', total => $count),
|
||||
min => 0, max => $count);
|
||||
$self->{global}->{used} += $obj->{InUseCount};
|
||||
$self->{global}->{total} += $obj->{Count};
|
||||
}
|
||||
|
||||
if ($count == 0) {
|
||||
$self->{output}->output_add(severity => 'Unknown',
|
||||
short_msg => "Can't get licenses count");
|
||||
if ($self->{global}->{total} == 0) {
|
||||
$self->{output}->add_option_msg(short_msg => 'Cant get licenses count');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{output}->display();
|
||||
$self->{output}->exit();
|
||||
|
||||
$self->{global}->{prct_used} = $self->{global}->{used} * 100 / $self->{global}->{total};
|
||||
$self->{global}->{prct_free} = 100 - $self->{global}->{prct_used};
|
||||
$self->{global}->{free} = $self->{global}->{total} - $self->{global}->{used};
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -106,13 +122,10 @@ Check Citrix licenses.
|
|||
|
||||
=over 8
|
||||
|
||||
=item B<--warning>
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Threshold warning of licenses used in percent.
|
||||
|
||||
=item B<--critical>
|
||||
|
||||
Threshold critical of licenses used in percent.
|
||||
Thresholds.
|
||||
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%).
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"warning:s" => { name => 'warning', },
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue