mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-24 22:25:02 +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
@ -44,18 +44,19 @@ 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' },
|
||||||
'hostname:s' => { name => 'hostname' },
|
'default-value:s' => { name => 'default_value' },
|
||||||
'url-path:s' => { name => 'url_path' },
|
'hostname:s' => { name => 'hostname' },
|
||||||
'port:s' => { name => 'port' },
|
'url-path:s' => { name => 'url_path' },
|
||||||
'proto:s' => { name => 'proto' },
|
'port:s' => { name => 'port' },
|
||||||
'credentials' => { name => 'credentials' },
|
'proto:s' => { name => 'proto' },
|
||||||
'basic' => { name => 'basic' },
|
'credentials' => { name => 'credentials' },
|
||||||
'username:s' => { name => 'username' },
|
'basic' => { name => 'basic' },
|
||||||
'password:s' => { name => 'password' },
|
'username:s' => { name => 'username' },
|
||||||
'timeout:s' => { name => 'timeout', default => 10 },
|
'password:s' => { name => 'password' },
|
||||||
'timeframe:s' => { name => 'timeframe' },
|
'timeout:s' => { name => 'timeout', default => 10 },
|
||||||
'timezone:s' => { name => 'timezone', default => 'UTC' }
|
'timeframe:s' => { name => 'timeframe' },
|
||||||
|
'timezone:s' => { name => 'timezone', default => 'UTC' }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
|
||||||
@ -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