mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-24 06:05:17 +02:00
commit
f70d5f6703
@ -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__
|
||||||
|
@ -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 => $system->{HasUnregisteredSystemExtensions} ? 'false' : 'true',
|
health => $system->{HasUnregisteredSystemExtensions} ? 'false' : 'true',
|
||||||
};
|
};
|
||||||
|
$self->{service}->{HasUpdatesAvailable} = {
|
||||||
|
display => 'HasUpdatesAvailable',
|
||||||
|
health => scalar(@$update) ? 'false' : 'true',
|
||||||
|
};
|
||||||
|
|
||||||
$self->{global} = {
|
$self->{global} = {
|
||||||
calls_active => $system->{CallsActive},
|
calls_active => $system->{CallsActive},
|
||||||
@ -153,7 +158,7 @@ Check system health
|
|||||||
|
|
||||||
=item B<--unknown-status>
|
=item B<--unknown-status>
|
||||||
|
|
||||||
Set warning threshold for status.
|
Set unknown threshold for status.
|
||||||
Can used special variables like: %{health}, %{display}
|
Can used special variables like: %{health}, %{display}
|
||||||
|
|
||||||
=item B<--warning-status>
|
=item B<--warning-status>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user