mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-25 22:55:15 +02:00
(plugin) apps::pvx::restapi - add default-value parameter (#3485)
* add default-value parameter * + fix after review
This commit is contained in:
parent
63029b9585
commit
c3e073409b
@ -45,6 +45,7 @@ sub new {
|
|||||||
if (!defined($options{noptions})) {
|
if (!defined($options{noptions})) {
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'api-key:s' => { name => 'api_key' },
|
'api-key:s' => { name => 'api_key' },
|
||||||
|
'default-value:s' => { name => 'default_value' },
|
||||||
'hostname:s' => { name => 'hostname' },
|
'hostname:s' => { name => 'hostname' },
|
||||||
'url-path:s' => { name => 'url_path' },
|
'url-path:s' => { name => 'url_path' },
|
||||||
'port:s' => { name => 'port' },
|
'port:s' => { name => 'port' },
|
||||||
@ -166,6 +167,12 @@ sub query_range {
|
|||||||
|
|
||||||
my $result = $self->get_endpoint(url_path => '/query?expr=' . $uri->encode($query));
|
my $result = $self->get_endpoint(url_path => '/query?expr=' . $uri->encode($query));
|
||||||
|
|
||||||
|
if (defined( $self->{option_results}->{default_value} ) && $options{filter} ne '' && !exists( $result->{data} )) {
|
||||||
|
$options{filter} =~ /([^\s\\]+) = \"([^\s\\]+)\"/;
|
||||||
|
push @{$result->{data}->{key}}, { value => $2 };
|
||||||
|
push @{$result->{data}->{values}}, { value => $self->{option_results}->{default_value} };
|
||||||
|
}
|
||||||
|
|
||||||
return $result->{data};
|
return $result->{data};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,6 +215,10 @@ PVX Rest API custom mode
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--default-value>
|
||||||
|
|
||||||
|
Set a default value when nothing returned by PVX API
|
||||||
|
|
||||||
=item B<--timeframe>
|
=item B<--timeframe>
|
||||||
|
|
||||||
Set timeframe in seconds (i.e. 3600 to check last hour).
|
Set timeframe in seconds (i.e. 3600 to check last hour).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user