mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-26 23:24:27 +02:00
parent
6451399717
commit
bef7aed6f0
@ -24,27 +24,18 @@ use base qw(centreon::plugins::templates::counter);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
|
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
my $msg = sprintf("License Status '%s' [type: %s] [issued to: %s] [issue date: %s]",
|
|
||||||
|
return sprintf(
|
||||||
|
"License Status '%s' [type: %s] [issued to: %s] [issue date: %s]",
|
||||||
$self->{result_values}->{status},
|
$self->{result_values}->{status},
|
||||||
$self->{result_values}->{type},
|
$self->{result_values}->{type},
|
||||||
$self->{result_values}->{issued_to},
|
$self->{result_values}->{issued_to},
|
||||||
$self->{result_values}->{issue_date});
|
$self->{result_values}->{issue_date}
|
||||||
|
);
|
||||||
return $msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub custom_status_calc {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
|
|
||||||
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
|
|
||||||
$self->{result_values}->{type} = $options{new_datas}->{$self->{instance} . '_type'};
|
|
||||||
$self->{result_values}->{issued_to} = $options{new_datas}->{$self->{instance} . '_issued_to'};
|
|
||||||
$self->{result_values}->{issue_date} = $options{new_datas}->{$self->{instance} . '_issue_date'};
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
@ -55,13 +46,14 @@ sub set_counters {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{global} = [
|
$self->{maps_counters}->{global} = [
|
||||||
{ label => 'status', threshold => 0, set => {
|
{ label => 'status', type => 2, critical_default => '%{status} !~ /active/i', set => {
|
||||||
key_values => [ { name => 'status' }, { name => 'type' }, { name => 'issued_to' },
|
key_values => [
|
||||||
{ name => 'issue_date' } ],
|
{ name => 'status' }, { name => 'type' }, { name => 'issued_to' },
|
||||||
closure_custom_calc => $self->can('custom_status_calc'),
|
{ name => 'issue_date' }, { name => 'expiry_date_in_seconds' }
|
||||||
|
],
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
closure_custom_perfdata => sub { return 0; },
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
closure_custom_threshold_check => \&catalog_status_threshold_ng
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -73,20 +65,11 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /active/i' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
|
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -97,6 +80,7 @@ sub manage_selection {
|
|||||||
status => $result->{license}->{status},
|
status => $result->{license}->{status},
|
||||||
issued_to => $result->{license}->{issued_to},
|
issued_to => $result->{license}->{issued_to},
|
||||||
issue_date => $result->{license}->{issue_date},
|
issue_date => $result->{license}->{issue_date},
|
||||||
|
expiry_date_in_seconds => int($result->{license}->{expiry_date_in_millis} / 1000)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,13 +96,13 @@ Check license.
|
|||||||
|
|
||||||
=item B<--warning-status>
|
=item B<--warning-status>
|
||||||
|
|
||||||
Set warning threshold for status (Default: '')
|
Set warning threshold for status.
|
||||||
Can used special variables like: %{status}, %{type}, %{issued_to}.
|
Can used special variables like: %{status}, %{type}, %{issued_to}, %{expiry_date_in_seconds}.
|
||||||
|
|
||||||
=item B<--critical-status>
|
=item B<--critical-status>
|
||||||
|
|
||||||
Set critical threshold for status (Default: '%{status} !~ /active/i').
|
Set critical threshold for status (Default: '%{status} !~ /active/i').
|
||||||
Can used special variables like: %{status}, %{type}, %{issued_to}.
|
Can used special variables like: %{status}, %{type}, %{issued_to}, %{expiry_date_in_seconds}.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
@ -30,15 +30,16 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
$self->{modes} = {
|
||||||
'cluster-statistics' => 'database::elasticsearch::restapi::mode::clusterstatistics',
|
'cluster-statistics' => 'database::elasticsearch::restapi::mode::clusterstatistics',
|
||||||
'indice-statistics' => 'database::elasticsearch::restapi::mode::indicestatistics',
|
'indice-statistics' => 'database::elasticsearch::restapi::mode::indicestatistics',
|
||||||
'license' => 'database::elasticsearch::restapi::mode::license',
|
'license' => 'database::elasticsearch::restapi::mode::license',
|
||||||
'list-indices' => 'database::elasticsearch::restapi::mode::listindices',
|
'list-indices' => 'database::elasticsearch::restapi::mode::listindices',
|
||||||
'list-nodes' => 'database::elasticsearch::restapi::mode::listnodes',
|
'list-nodes' => 'database::elasticsearch::restapi::mode::listnodes',
|
||||||
'node-statistics' => 'database::elasticsearch::restapi::mode::nodestatistics',
|
'node-statistics' => 'database::elasticsearch::restapi::mode::nodestatistics'
|
||||||
);
|
};
|
||||||
$self->{custom_modes}{api} = 'database::elasticsearch::restapi::custom::api';
|
|
||||||
|
$self->{custom_modes}->{api} = 'database::elasticsearch::restapi::custom::api';
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user