fix(salesforce): api version option (#3110)

This commit is contained in:
qgarnier 2021-09-16 10:02:01 +02:00 committed by GitHub
parent e4fc05d73f
commit 34da8733e5
2 changed files with 11 additions and 23 deletions

View File

@ -41,9 +41,9 @@ sub new {
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'timeout:s' => { name => 'timeout' },
'api-versions:s' => { name => 'api_version' }
'hostname:s' => { name => 'hostname' },
'timeout:s' => { name => 'timeout' },
'api-version:s' => { name => 'api_version' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
@ -143,9 +143,9 @@ Set hostname to query (default: 'api.status.salesforce.com')
Set HTTP timeout in seconds (Default: '10').
=item B<--api-path>
=item B<--api-version>
API base url path (Default: '/v1').
API version (Default: 'v1').
=back

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output {
my ($self, %options) = @_;
@ -50,21 +50,19 @@ sub set_counters {
];
$self->{maps_counters}->{salesforce} = [
{ label => 'status', threshold => 0, set => {
{ label => 'status', type => 2, critical_default => '%{status} !~ /OK/', set => {
key_values => [ { name => 'status' }, { name => 'active' }, { name => 'name' } ],
closure_custom_calc => \&catalog_status_calc,
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'incident', nlabel => 'salesforce.incident.current.count', set => {
key_values => [ { name => 'incident' } ],
output_template => '%s incidents currently',
perfdatas => [
{ label => 'incident', value => 'incident', template => '%s',
min => 0, label_extra_instance => 1 },
],
{ template => '%s', min => 0, label_extra_instance => 1 }
]
}
}
];
@ -77,22 +75,12 @@ sub new {
$options{options}->add_options(arguments => {
'instance:s@' => { name => 'instance' },
'alias' => { name => 'use_alias' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{status} !~ /OK/' }
'alias' => { name => 'use_alias' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
}
sub manage_selection {
my ($self, %options) = @_;