diff --git a/centreon-plugins/apps/voip/3cx/restapi/custom/api.pm b/centreon-plugins/apps/voip/3cx/restapi/custom/api.pm index 3c3fb4e2d..b7e61acdb 100644 --- a/centreon-plugins/apps/voip/3cx/restapi/custom/api.pm +++ b/centreon-plugins/apps/voip/3cx/restapi/custom/api.pm @@ -194,6 +194,12 @@ sub request_api { 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; eval { $decoded = JSON::XS->new->utf8->decode($content); @@ -240,6 +246,20 @@ sub api_system_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; __END__ diff --git a/centreon-plugins/apps/voip/3cx/restapi/mode/system.pm b/centreon-plugins/apps/voip/3cx/restapi/mode/system.pm index d9d04ae6a..811d6a46a 100644 --- a/centreon-plugins/apps/voip/3cx/restapi/mode/system.pm +++ b/centreon-plugins/apps/voip/3cx/restapi/mode/system.pm @@ -117,6 +117,7 @@ sub manage_selection { my $single = $options{custom}->api_single_status(); my $system = $options{custom}->api_system_status(); + my $update = $options{custom}->api_update_checker(); $self->{service} = {}; foreach my $item (keys %$single) { @@ -134,6 +135,10 @@ sub manage_selection { display => 'HasUnregisteredSystemExtensions', health => $system->{HasUnregisteredSystemExtensions} ? 'false' : 'true', }; + $self->{service}->{HasUpdatesAvailable} = { + display => 'HasUpdatesAvailable', + health => scalar(@$update) ? 'false' : 'true', + }; $self->{global} = { calls_active => $system->{CallsActive}, @@ -153,7 +158,7 @@ Check system health =item B<--unknown-status> -Set warning threshold for status. +Set unknown threshold for status. Can used special variables like: %{health}, %{display} =item B<--warning-status>