mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-25 14:44:43 +02:00
3CX check for updates
This commit is contained in:
parent
39b7cbabdc
commit
c3d1373649
@ -194,6 +194,12 @@ sub request_api {
|
|||||||
warning_status => '', unknown_status => '', critical_status => '%{http_code} < 200 or %{http_code} >= 300'
|
warning_status => '', unknown_status => '', critical_status => '%{http_code} < 200 or %{http_code} >= 300'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Some content may be strangely returned, for example : "[{\"Category\":\"provider\",\"Count\":1}]"
|
||||||
|
if ($content =~ /^"(\[.*\])"$/) {
|
||||||
|
$content = $1;
|
||||||
|
$content =~ s/\\"/"/g;
|
||||||
|
}
|
||||||
|
|
||||||
my $decoded;
|
my $decoded;
|
||||||
eval {
|
eval {
|
||||||
$decoded = JSON::XS->new->utf8->decode($content);
|
$decoded = JSON::XS->new->utf8->decode($content);
|
||||||
@ -240,6 +246,20 @@ sub api_system_status {
|
|||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub internal_update_checker {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $status = $self->request_api(method => 'GET', url_path =>'/api/UpdateChecker/GetFromParams');
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub api_update_checker {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $status = $self->internal_update_checker();
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
@ -96,8 +96,8 @@ sub new {
|
|||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"unknown-status:s" => { name => 'unknown_status', default => '' },
|
"unknown-status:s" => { name => 'unknown_status', default => '' },
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
"warning-status:s" => { name => 'warning_status', default => '%{display} =~ /HasUpdatesAvailable/ && %{health} =~ /true/' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{health} =~ /false/' },
|
"critical-status:s" => { name => 'critical_status', default => '%{display} !~ /HasUpdatesAvailable/ && %{health} =~ /false/' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -117,6 +117,7 @@ sub manage_selection {
|
|||||||
|
|
||||||
my $single = $options{custom}->api_single_status();
|
my $single = $options{custom}->api_single_status();
|
||||||
my $system = $options{custom}->api_system_status();
|
my $system = $options{custom}->api_system_status();
|
||||||
|
my $update = $options{custom}->api_update_checker();
|
||||||
|
|
||||||
$self->{service} = {};
|
$self->{service} = {};
|
||||||
foreach my $item (keys %$single) {
|
foreach my $item (keys %$single) {
|
||||||
@ -134,6 +135,10 @@ sub manage_selection {
|
|||||||
display => 'HasUnregisteredSystemExtensions',
|
display => 'HasUnregisteredSystemExtensions',
|
||||||
health => $self->{system}->{HasUnregisteredSystemExtensions} ? 'false' : 'true',
|
health => $self->{system}->{HasUnregisteredSystemExtensions} ? 'false' : 'true',
|
||||||
};
|
};
|
||||||
|
$self->{service}->{HasUpdatesAvailable} = {
|
||||||
|
display => 'HasUpdatesAvailable',
|
||||||
|
health => scalar(@$update) ? 'true' : 'false',
|
||||||
|
};
|
||||||
|
|
||||||
$self->{global} = {
|
$self->{global} = {
|
||||||
calls_active => $system->{CallsActive},
|
calls_active => $system->{CallsActive},
|
||||||
@ -158,12 +163,14 @@ Can used special variables like: %{health}, %{display}
|
|||||||
|
|
||||||
=item B<--warning-status>
|
=item B<--warning-status>
|
||||||
|
|
||||||
Set warning threshold for status.
|
Set warning threshold for status
|
||||||
|
(Default: '%{display} =~ /HasUpdatesAvailable/ && %{health} =~ /true/').
|
||||||
Can used special variables like: %{health}, %{display}
|
Can used special variables like: %{health}, %{display}
|
||||||
|
|
||||||
=item B<--critical-status>
|
=item B<--critical-status>
|
||||||
|
|
||||||
Set critical threshold for status (Default: '%{health} =~ /false/').
|
Set critical threshold for status
|
||||||
|
(Default: '%{display} !~ /HasUpdatesAvailable/ && %{health} =~ /false/').
|
||||||
Can used special variables like: %{health}, %{display}
|
Can used special variables like: %{health}, %{display}
|
||||||
|
|
||||||
=item B<--warning-*> B<--critical-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user