new(plugin): new Backbox plugin (#5166)

This commit is contained in:
sdepassio 2024-09-06 11:21:32 +02:00 committed by GitHub
parent 540abe9b51
commit cb5f5a0d5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 1020 additions and 0 deletions

View File

@ -0,0 +1,265 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::backbox::rest::custom::api;
use strict;
use warnings;
use centreon::plugins::http;
use JSON::XS;
sub new {
my ($class, %options) = @_;
my $self = {};
bless $self, $class;
if (!defined($options{output})) {
print "Class Custom: Need to specify 'output' argument.\n";
exit 3;
}
if (!defined($options{options})) {
$options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument.");
$options{output}->option_exit();
}
if (!defined($options{noptions})) {
$options{options}->add_options(arguments => {
'hostname:s' => { name => 'hostname' },
'port:s' => { name => 'port' },
'proto:s' => { name => 'proto' },
'url-path:s' => { name => 'url_path' },
'api-token:s' => { name => 'api_token' },
'timeout:s' => { name => 'timeout' }
});
}
$options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1);
$self->{output} = $options{output};
$self->{http} = centreon::plugins::http->new(%options);
return $self;
}
sub set_options {
my ($self, %options) = @_;
$self->{option_results} = $options{option_results};
}
sub set_defaults {}
sub check_options {
my ($self, %options) = @_;
$self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : '';
$self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'https';
$self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 443;
$self->{url_path} = (defined($self->{option_results}->{url_path})) ? $self->{option_results}->{url_path} : '/rest/data/token/api/';
$self->{api_token} = (defined($self->{option_results}->{api_token})) ? $self->{option_results}->{api_token} : '';
$self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 30;
if ($self->{hostname} eq '') {
$self->{output}->add_option_msg(short_msg => 'Need to specify hostname option.');
$self->{output}->option_exit();
}
if ($self->{api_token} eq '') {
$self->{output}->add_option_msg(short_msg => "Need to specify --api-token option.");
$self->{output}->option_exit();
}
return 0;
}
sub get_connection_infos {
my ($self, %options) = @_;
return $self->{hostname} . '_' . $self->{http}->get_port();
}
sub get_hostname {
my ($self, %options) = @_;
return $self->{hostname};
}
sub get_port {
my ($self, %options) = @_;
return $self->{port};
}
sub json_decode {
my ($self, %options) = @_;
$options{content} =~ s/\r//mg;
my $decoded;
eval {
$decoded = JSON::XS->new->utf8->decode($options{content});
};
if ($@) {
$self->{output}->add_option_msg(short_msg => "Cannot decode json response: $@");
$self->{output}->option_exit();
}
return $decoded;
}
sub build_options_for_httplib {
my ($self, %options) = @_;
$self->{option_results}->{hostname} = $self->{hostname};
$self->{option_results}->{port} = $self->{port};
$self->{option_results}->{proto} = $self->{proto};
$self->{option_results}->{timeout} = $self->{timeout};
}
sub settings {
my ($self, %options) = @_;
$self->build_options_for_httplib();
$self->{http}->add_header(key => 'Accept', value => 'application/json');
$self->{http}->set_options(%{$self->{option_results}});
}
sub request {
my ($self, %options) = @_;
my $endpoint = $options{full_endpoint};
if (!defined($endpoint)) {
$endpoint = $self->{url_path} . $options{endpoint};
}
$self->settings();
my $content = $self->{http}->request(
method => 'GET',
url_path => $endpoint,
get_param => $options{get_param},
header => [
'AUTH: ' . $self->{api_token}
],
warning_status => '',
unknown_status => '',
critical_status => ''
);
# Maybe there is an issue with the token. So we retry.
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
$content = $self->{http}->request(
url_path => $endpoint,
get_param => $options{get_param},
header => [
'AUTH: ' . $self->{api_token}
],
unknown_status => $self->{unknown_http_status},
warning_status => $self->{warning_http_status},
critical_status => $self->{critical_http_status}
);
}
my $decoded = $self->json_decode(content => $content);
if (!defined($decoded)) {
$self->{output}->add_option_msg(short_msg => 'Error while retrieving data (add --debug option for detailed message)');
$self->{output}->option_exit();
}
return $decoded;
}
sub get_backup_jobs_status {
my ($self, %options) = @_;
my $endpoint = 'dashboard/backupStatus';
if (!centreon::plugins::misc::is_empty($options{filter_type})) {
$endpoint .= '/' . $options{filter_type};
}
return $self->request(endpoint => $endpoint);
}
sub get_config_status {
my ($self, %options) = @_;
my $endpoint = 'dashboard/configStatus';
if (!centreon::plugins::misc::is_empty($options{filter_type})) {
$endpoint .= '/' . $options{filter_type};
}
return $self->request(endpoint => $endpoint);
}
sub get_intelli_check_status {
my ($self, %options) = @_;
my $endpoint = 'dashboard/intelliCheckStatus';
if (!centreon::plugins::misc::is_empty($options{filter_type})) {
$endpoint .= '/' . $options{filter_type};
}
if (!centreon::plugins::misc::is_empty($options{report_id})) {
$endpoint .= '/' . $options{report_id};
}
return $self->request(endpoint => $endpoint);
}
1;
__END__
=head1 NAME
Backbox API
=head1 SYNOPSIS
Backbox api
=head1 REST API OPTIONS
=over 8
=item B<--hostname>
API hostname.
=item B<--url-path>
API url path (default: '/rest/token/api')
=item B<--port>
API port (default: 443)
=item B<--proto>
Specify https if needed (default: 'https')
=item B<--api-token>
Set API token
=item B<--timeout>
Set HTTP timeout
=back
=head1 DESCRIPTION
B<custom>.
=cut

View File

@ -0,0 +1,136 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::backbox::rest::mode::backup;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub prefix_backup_output {
my ($self, %options) = @_;
return "Backup '" . $options{instance_value}->{name} . "' - ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'backups', type => 1, cb_prefix_output => 'prefix_backup_output', message_multiple => 'All backups are ok', skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{backups} = [
{ label => 'total', nlabel => 'backups.total.count', set => {
key_values => [ { name => 'total' } ],
output_template => 'total: %d',
perfdatas => [
{ value => 'total', template => '%d', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'success', nlabel => 'backups.success.count', set => {
key_values => [ { name => 'success' }, { name => 'total' } ],
output_template => 'success: %d',
perfdatas => [
{ value => 'success', template => '%d', min => 0, max => 'total', label_extra_instance => 1 }
]
}
},
{ label => 'suspect', nlabel => 'backups.suspect.count', set => {
key_values => [ { name => 'suspect' }, { name => 'total' } ],
output_template => 'suspect: %d',
perfdatas => [
{ value => 'suspect', template => '%d', min => 0, max => 'total', label_extra_instance => 1 }
]
}
},
{ label => 'failure', nlabel => 'backups.failure.count', set => {
key_values => [ { name => 'failure' }, { name => 'total' } ],
output_template => 'failure: %d',
perfdatas => [
{ value => 'failure', template => '%d', min => 0, max => 'total', label_extra_instance => 1 }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-type:s' => { name => 'filter_type' }
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $backups = $options{custom}->get_backup_jobs_status();
for $backups (@$backups) {
$self->{backups}->{$backups->{name}} = {
name => $backups->{name},
total => $backups->{totalDevices},
success => $backups->{successDevices},
suspect => $backups->{suspectDevices},
failure => $backups->{failureDevices}
};
}
}
1;
__END__
=head1 MODE
Check Backbox backups.
=over 8
=item B<--filter-type>
Filter backups by type.
=item B<--warning-failure>
Set warning threshold for 'failure'.
=item B<--critical-failure>
Set critical threshold for 'failure'.
=item B<--warning-suspect>
Set warning threshold for 'suspect'.
=item B<--critical-suspect>
Set critical threshold for 'suspect'.
=back
=cut

View File

@ -0,0 +1,126 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::backbox::rest::mode::configstatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'config', type => 0 },
];
$self->{maps_counters}->{config} = [
{ label => 'identical', nlabel => 'config.identical.count', set => {
key_values => [ { name => 'identical' } ],
output_template => 'identical: %d',
perfdatas => [
{ value => 'identical', template => '%d', min => 0 }
]
}
},
{ label => 'changed', nlabel => 'config.changed.count', set => {
key_values => [ { name => 'changed' } ],
output_template => 'changed: %d',
perfdatas => [
{ value => 'changed', template => '%d', min => 0 }
]
}
},
{ label => 'na', nlabel => 'config.na.count', set => {
key_values => [ { name => 'na' } ],
output_template => 'n/a: %d',
perfdatas => [
{ value => 'na', template => '%d', min => 0 }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-type:s' => { name => 'filter_type' }
});
return $self;
}
sub manage_selection {
my ($self, %options) = @_;
my $config = $options{custom}->get_config_status();
$self->{config} = {
identical => $config->{identical},
changed => $config->{changed},
na => $config->{na}
};
}
1;
__END__
=head1 MODE
Check Backbox configs status.
=over 8
=item B<--filter-type>
Filter configs by type.
=item B<--warning-identical>
Set warning threshold for 'identical'.
=item B<--critical-identical>
Set critical threshold for 'identical'.
=item B<--warning-changed>
Set warning threshold for 'changed'.
=item B<--critical-changed>
Set critical threshold for 'changed'.
=item B<--warning-na>
Set warning threshold for 'n/a'.
=item B<--critical-na>
Set critical threshold for 'n/a'.
=back
=cut

View File

@ -0,0 +1,152 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::backbox::rest::mode::intellicheck;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub prefix_intellicheck_output {
my ($self, %options) = @_;
return "Intellicheck " . $options{instance_value}->{id} . " '" . $options{instance_value}->{name} . "' - ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'intellichecks', type => 1, cb_prefix_output => 'prefix_intellicheck_output', message_multiple => 'All intellichecks are ok', skipped_code => { -10 => 1 } },
];
$self->{maps_counters}->{intellichecks} = [
{ label => 'total', nlabel => 'intellicheck.total.count', set => {
key_values => [ { name => 'total' } ],
output_template => 'total: %d',
perfdatas => [
{ value => 'total', template => '%d', min => 0, label_extra_instance => 1 }
]
}
},
{ label => 'success', nlabel => 'intellicheck.success.count', set => {
key_values => [ { name => 'success' }, { name => 'total' } ],
output_template => 'success: %d',
perfdatas => [
{ value => 'success', template => '%d', min => 0, max => 'total', label_extra_instance => 1 }
]
}
},
{ label => 'suspect', nlabel => 'intellicheck.suspect.count', set => {
key_values => [ { name => 'suspect' }, { name => 'total' } ],
output_template => 'suspect: %d',
perfdatas => [
{ value => 'suspect', template => '%d', min => 0, max => 'total', label_extra_instance => 1 }
]
}
},
{ label => 'failure', nlabel => 'intellicheck.failure.count', set => {
key_values => [ { name => 'failure' }, { name => 'total' } ],
output_template => 'failure: %d',
perfdatas => [
{ value => 'failure', template => '%d', min => 0, max => 'total', label_extra_instance => 1 }
]
}
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-type:s' => { name => 'filter_type' },
'report-id:s' => { name => 'report_id' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
if (!centreon::plugins::misc::is_empty($self->{option_results}->{report_id}) && centreon::plugins::misc::is_empty($self->{option_results}->{filter_type})) {
$self->{output}->add_option_msg(short_msg => "Need to specify --filter-type option.");
$self->{output}->option_exit();
}
}
sub manage_selection {
my ($self, %options) = @_;
my $intellichecks = $options{custom}->get_intelli_check_status();
for $intellichecks (@$intellichecks) {
$self->{intellichecks}->{$intellichecks->{name}} = {
name => $intellichecks->{name},
id => $intellichecks->{id},
success => $intellichecks->{successDevices},
suspect => $intellichecks->{suspectDevices},
failure => $intellichecks->{failureDevices},
total => $intellichecks->{total_devices}
};
}
}
1;
__END__
=head1 MODE
Check Backbox backups.
=over 8
=item B<--filter-type>
Filter backups by type.
=item B<--report-id>
Specify report id.
=item B<--warning-failure>
Set warning threshold for 'failure'.
=item B<--critical-failure>
Set critical threshold for 'failure'.
=item B<--warning-suspect>
Set warning threshold for 'suspect'.
=item B<--critical-suspect>
Set critical threshold for 'suspect'.
=back
=cut

View File

@ -0,0 +1,52 @@
#
# Copyright 2024 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package network::backbox::rest::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_custom);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$self->{modes} = {
'backup' => 'network::backbox::rest::mode::backup',
'configstatus' => 'network::backbox::rest::mode::configstatus',
'intellicheck' => 'network::backbox::rest::mode::intellicheck'
};
$self->{custom_modes}->{api} = 'network::backbox::rest::custom::api';
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Backbox using Rest API.
=cut

View File

@ -0,0 +1,158 @@
{
"uuid": "adb51fea-62b9-4e06-87dc-13d2b21bd3d8",
"lastMigration": 32,
"name": "Backbox",
"endpointPrefix": "",
"latency": 0,
"port": 3000,
"hostname": "",
"folders": [],
"routes": [
{
"uuid": "9276ab2a-9101-46fd-ab5b-445ba5198ba7",
"type": "http",
"documentation": "",
"method": "get",
"endpoint": "rest/data/token/api/dashboard/backupStatus",
"responses": [
{
"uuid": "970b8727-a9c3-48ca-b022-1dc13aeacf11",
"body": "[\n {\n \"name\": \"All\",\n \"successDevices\": 0,\n \"suspectDevices\": 1,\n \"failureDevices\": 4,\n \"totalDevices\": 5\n },\n {\n \"name\": \"Backup1\",\n \"successDevices\": 1,\n \"suspectDevices\": 2,\n \"failureDevices\": 3,\n \"totalDevices\": 6\n }\n]",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [],
"bodyType": "INLINE",
"filePath": "",
"databucketID": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false,
"fallbackTo404": false,
"default": true,
"crudKey": "id",
"callbacks": []
}
],
"responseMode": null
},
{
"uuid": "fe7039c5-f27e-41ce-8c17-2cc25d4a7820",
"type": "http",
"documentation": "",
"method": "get",
"endpoint": "rest/data/token/api/dashboard/configStatus",
"responses": [
{
"uuid": "bb3d0a3a-c0d1-4788-82ae-f4bc7f1957ea",
"body": "{\n \"identical\": 3,\n \"changed\": 4,\n \"na\": 5\n}",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [],
"bodyType": "INLINE",
"filePath": "",
"databucketID": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false,
"fallbackTo404": false,
"default": true,
"crudKey": "id",
"callbacks": []
}
],
"responseMode": null
},
{
"uuid": "101f818e-0ef5-4468-8c2a-f0f7ab2f1d49",
"type": "http",
"documentation": "",
"method": "get",
"endpoint": "rest/data/token/api/dashboard/intelliCheckStatus",
"responses": [
{
"uuid": "64d99a57-49cf-4ce0-8e89-70c76263bd9e",
"body": "[\n {\n \"successDevices\":3,\n \"suspectDevices\":4,\n \"failureDevices\":5,\n \"Name\":\"All\",\n \"ID\":0,\n \"total_devices\":12,\n \"id\":0,\n \"name\":\"All\"\n },\n {\n \"successDevices\":5,\n \"suspectDevices\":4,\n \"failureDevices\":3,\n \"Name\":\"IntelliCheck1\",\n \"ID\":0,\n \"total_devices\":12,\n \"id\":0,\n \"name\":\"IntelliCheck1\"\n }\n]",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [],
"bodyType": "INLINE",
"filePath": "",
"databucketID": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false,
"fallbackTo404": false,
"default": true,
"crudKey": "id",
"callbacks": []
}
],
"responseMode": null
}
],
"rootChildren": [
{
"type": "route",
"uuid": "9276ab2a-9101-46fd-ab5b-445ba5198ba7"
},
{
"type": "route",
"uuid": "fe7039c5-f27e-41ce-8c17-2cc25d4a7820"
},
{
"type": "route",
"uuid": "101f818e-0ef5-4468-8c2a-f0f7ab2f1d49"
}
],
"proxyMode": false,
"proxyHost": "",
"proxyRemovePrefix": false,
"tlsOptions": {
"enabled": false,
"type": "CERT",
"pfxPath": "",
"certPath": "",
"keyPath": "",
"caPath": "",
"passphrase": ""
},
"cors": true,
"headers": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Access-Control-Allow-Methods",
"value": "GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"
},
{
"key": "Access-Control-Allow-Headers",
"value": "Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"
}
],
"proxyReqHeaders": [
{
"key": "",
"value": ""
}
],
"proxyResHeaders": [
{
"key": "",
"value": ""
}
],
"data": [],
"callbacks": []
}

View File

@ -0,0 +1,42 @@
*** Settings ***
Documentation Check the backup status
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}backbox.json
${cmd} ${CENTREON_PLUGINS}
... --plugin=network::backbox::rest::plugin
... --custommode=api
... --hostname=${HOSTNAME}
... --port=${APIPORT}
... --proto=http
... --api-token=token
*** Test Cases ***
backups ${tc}
[Documentation] Check the backups status
[Tags] network backbox rest backup
${command} Catenate
... ${cmd}
... --mode=backup
... ${extraoptions}
Log ${cmd}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc extraoptions expected_result --
... 1 ${EMPTY} OK: All backups are ok | 'All#backups.total.count'=5;;;0; 'All#backups.success.count'=0;;;0;5 'All#backups.suspect.count'=1;;;0;5 'All#backups.failure.count'=4;;;0;5 'Backup1#backups.total.count'=6;;;0; 'Backup1#backups.success.count'=1;;;0;6 'Backup1#backups.suspect.count'=2;;;0;6 'Backup1#backups.failure.count'=3;;;0;6
... 2 --warning-failure=3 WARNING: Backup 'All' - failure: 4 | 'All#backups.total.count'=5;;;0; 'All#backups.success.count'=0;;;0;5 'All#backups.suspect.count'=1;;;0;5 'All#backups.failure.count'=4;0:3;;0;5 'Backup1#backups.total.count'=6;;;0; 'Backup1#backups.success.count'=1;;;0;6 'Backup1#backups.suspect.count'=2;;;0;6 'Backup1#backups.failure.count'=3;0:3;;0;6
... 3 --critical-failure=3 CRITICAL: Backup 'All' - failure: 4 | 'All#backups.total.count'=5;;;0; 'All#backups.success.count'=0;;;0;5 'All#backups.suspect.count'=1;;;0;5 'All#backups.failure.count'=4;;0:3;0;5 'Backup1#backups.total.count'=6;;;0; 'Backup1#backups.success.count'=1;;;0;6 'Backup1#backups.suspect.count'=2;;;0;6 'Backup1#backups.failure.count'=3;;0:3;0;6
... 4 --warning-failure=2 WARNING: Backup 'All' - failure: 4 - Backup 'Backup1' - failure: 3 | 'All#backups.total.count'=5;;;0; 'All#backups.success.count'=0;;;0;5 'All#backups.suspect.count'=1;;;0;5 'All#backups.failure.count'=4;0:2;;0;5 'Backup1#backups.total.count'=6;;;0; 'Backup1#backups.success.count'=1;;;0;6 'Backup1#backups.suspect.count'=2;;;0;6 'Backup1#backups.failure.count'=3;0:2;;0;6
... 5 --critical-failure=2 CRITICAL: Backup 'All' - failure: 4 - Backup 'Backup1' - failure: 3 | 'All#backups.total.count'=5;;;0; 'All#backups.success.count'=0;;;0;5 'All#backups.suspect.count'=1;;;0;5 'All#backups.failure.count'=4;;0:2;0;5 'Backup1#backups.total.count'=6;;;0; 'Backup1#backups.success.count'=1;;;0;6 'Backup1#backups.suspect.count'=2;;;0;6 'Backup1#backups.failure.count'=3;;0:2;0;6
... 6 --warning-suspect=1 WARNING: Backup 'Backup1' - suspect: 2 | 'All#backups.total.count'=5;;;0; 'All#backups.success.count'=0;;;0;5 'All#backups.suspect.count'=1;0:1;;0;5 'All#backups.failure.count'=4;;;0;5 'Backup1#backups.total.count'=6;;;0; 'Backup1#backups.success.count'=1;;;0;6 'Backup1#backups.suspect.count'=2;0:1;;0;6 'Backup1#backups.failure.count'=3;;;0;6
... 7 --critical-suspect=1 CRITICAL: Backup 'Backup1' - suspect: 2 | 'All#backups.total.count'=5;;;0; 'All#backups.success.count'=0;;;0;5 'All#backups.suspect.count'=1;;0:1;0;5 'All#backups.failure.count'=4;;;0;5 'Backup1#backups.total.count'=6;;;0; 'Backup1#backups.success.count'=1;;;0;6 'Backup1#backups.suspect.count'=2;;0:1;0;6 'Backup1#backups.failure.count'=3;;;0;6
... 8 --filter-type=1 OK: All backups are ok | 'All#backups.total.count'=5;;;0; 'All#backups.success.count'=0;;;0;5 'All#backups.suspect.count'=1;;;0;5 'All#backups.failure.count'=4;;;0;5 'Backup1#backups.total.count'=6;;;0; 'Backup1#backups.success.count'=1;;;0;6 'Backup1#backups.suspect.count'=2;;;0;6 'Backup1#backups.failure.count'=3;;;0;6

View File

@ -0,0 +1,42 @@
*** Settings ***
Documentation Check the config status
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}backbox.json
${cmd} ${CENTREON_PLUGINS}
... --plugin=network::backbox::rest::plugin
... --custommode=api
... --hostname=${HOSTNAME}
... --port=${APIPORT}
... --proto=http
... --api-token=token
... --mode=configstatus
*** Test Cases ***
configstatus ${tc}
[Documentation] Check the config status
[Tags] network backbox rest configstatus
${command} Catenate
... ${cmd}
... ${extraoptions}
Log ${cmd}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc extraoptions expected_result --
... 1 ${EMPTY} OK: identical: 3, changed: 4, n/a: 5 | 'config.identical.count'=3;;;0; 'config.changed.count'=4;;;0; 'config.na.count'=5;;;0;
... 2 --warning-identical=2 WARNING: identical: 3 | 'config.identical.count'=3;0:2;;0; 'config.changed.count'=4;;;0; 'config.na.count'=5;;;0;
... 3 --critical-identical=2 CRITICAL: identical: 3 | 'config.identical.count'=3;;0:2;0; 'config.changed.count'=4;;;0; 'config.na.count'=5;;;0;
... 4 --warning-changed=2 WARNING: changed: 4 | 'config.identical.count'=3;;;0; 'config.changed.count'=4;0:2;;0; 'config.na.count'=5;;;0;
... 5 --critical-changed=2 CRITICAL: changed: 4 | 'config.identical.count'=3;;;0; 'config.changed.count'=4;;0:2;0; 'config.na.count'=5;;;0;
... 6 --warning-na=2 WARNING: n/a: 5 | 'config.identical.count'=3;;;0; 'config.changed.count'=4;;;0; 'config.na.count'=5;0:2;;0;
... 7 --critical-na=2 CRITICAL: n/a: 5 | 'config.identical.count'=3;;;0; 'config.changed.count'=4;;;0; 'config.na.count'=5;;0:2;0;
... 8 --filter-type=1 OK: identical: 3, changed: 4, n/a: 5 | 'config.identical.count'=3;;;0; 'config.changed.count'=4;;;0; 'config.na.count'=5;;;0;

View File

@ -0,0 +1,44 @@
*** Settings ***
Documentation Check the intellichecks status
Resource ${CURDIR}${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}backbox.json
${cmd} ${CENTREON_PLUGINS}
... --plugin=network::backbox::rest::plugin
... --custommode=api
... --hostname=${HOSTNAME}
... --port=${APIPORT}
... --proto=http
... --api-token=token
... --mode=intellicheck
*** Test Cases ***
intellichecks ${tc}
[Documentation] Check the intellichecks status
[Tags] network backbox rest intellicheck
${command} Catenate
... ${cmd}
... ${extraoptions}
Log ${cmd}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: tc extraoptions expected_result --
... 1 ${EMPTY} OK: All intellichecks are ok | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;;;0;12 'All#intellicheck.failure.count'=5;;;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;;;0;12 'IntelliCheck1#intellicheck.failure.count'=3;;;0;12
... 2 --warning-failure=3 WARNING: Intellicheck 0 'All' - failure: 5 | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;;;0;12 'All#intellicheck.failure.count'=5;0:3;;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;;;0;12 'IntelliCheck1#intellicheck.failure.count'=3;0:3;;0;12
... 3 --critical-failure=3 CRITICAL: Intellicheck 0 'All' - failure: 5 | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;;;0;12 'All#intellicheck.failure.count'=5;;0:3;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;;;0;12 'IntelliCheck1#intellicheck.failure.count'=3;;0:3;0;12
... 4 --warning-failure=2 WARNING: Intellicheck 0 'All' - failure: 5 - Intellicheck 0 'IntelliCheck1' - failure: 3 | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;;;0;12 'All#intellicheck.failure.count'=5;0:2;;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;;;0;12 'IntelliCheck1#intellicheck.failure.count'=3;0:2;;0;12
... 5 --critical-failure=2 CRITICAL: Intellicheck 0 'All' - failure: 5 - Intellicheck 0 'IntelliCheck1' - failure: 3 | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;;;0;12 'All#intellicheck.failure.count'=5;;0:2;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;;;0;12 'IntelliCheck1#intellicheck.failure.count'=3;;0:2;0;12
... 6 --warning-suspect=1 WARNING: Intellicheck 0 'All' - suspect: 4 - Intellicheck 0 'IntelliCheck1' - suspect: 4 | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;0:1;;0;12 'All#intellicheck.failure.count'=5;;;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;0:1;;0;12 'IntelliCheck1#intellicheck.failure.count'=3;;;0;12
... 7 --critical-suspect=1 CRITICAL: Intellicheck 0 'All' - suspect: 4 - Intellicheck 0 'IntelliCheck1' - suspect: 4 | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;;0:1;0;12 'All#intellicheck.failure.count'=5;;;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;;0:1;0;12 'IntelliCheck1#intellicheck.failure.count'=3;;;0;12
... 8 --filter-type=1 OK: All intellichecks are ok | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;;;0;12 'All#intellicheck.failure.count'=5;;;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;;;0;12 'IntelliCheck1#intellicheck.failure.count'=3;;;0;12
... 9 --report-id=1 UNKNOWN: Need to specify --filter-type option.
... 10 --filter-type=1 --report-id=1 OK: All intellichecks are ok | 'All#intellicheck.total.count'=12;;;0; 'All#intellicheck.success.count'=3;;;0;12 'All#intellicheck.suspect.count'=4;;;0;12 'All#intellicheck.failure.count'=5;;;0;12 'IntelliCheck1#intellicheck.total.count'=12;;;0; 'IntelliCheck1#intellicheck.success.count'=5;;;0;12 'IntelliCheck1#intellicheck.suspect.count'=4;;;0;12 'IntelliCheck1#intellicheck.failure.count'=3;;;0;12

View File

@ -11,6 +11,7 @@
--cert-pkcs12 --cert-pkcs12
--cert-pwd --cert-pwd
--critical-bytesallocatedpercentage --critical-bytesallocatedpercentage
--critical-na
--dfsr --dfsr
--display-transform-dst --display-transform-dst
--display-transform-src --display-transform-src
@ -51,6 +52,7 @@
--urlpath --urlpath
--use-ucd --use-ucd
--warning-bytesallocatedpercentage --warning-bytesallocatedpercentage
--warning-na
-EncodedCommand -EncodedCommand
-InputFormat -InputFormat
-NoLogo -NoLogo
@ -61,6 +63,7 @@ ASAM
Alcatel Alcatel
Ansible Ansible
Avigilon Avigilon
Backbox
Centreon Centreon
cpu-utilization-1m cpu-utilization-1m
cpu-utilization-5m cpu-utilization-5m