mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-31 01:24:35 +02:00
New pack LatenceTech : mode twamp
Co-authored-by: thibaults-centreon <tscheitenberger@centreon.com>
This commit is contained in:
parent
2029f2b885
commit
bcdd56ced2
138
src/apps/monitoring/latencetech/restapi/mode/twamp.pm
Normal file
138
src/apps/monitoring/latencetech/restapi/mode/twamp.pm
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2025 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 apps::monitoring::latencetech::restapi::mode::twamp;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, cb_prefix_output => 'prefix_output' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'twamp-forward', nlabel => 'twamp.forwarddelta.time.milliseconds', set => {
|
||||||
|
key_values => [ { name => 'TWAMPfwdDelta' }, { name => 'display' } ],
|
||||||
|
output_template => 'TWAMP Forward Delta: %.2fms',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'TWAMPfwdDelta', template => '%.2f',
|
||||||
|
min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'twamp-reverse', nlabel => 'twamp.reversedelta.time.milliseconds', set => {
|
||||||
|
key_values => [ { name => 'TWAMPRevDelta' }, { name => 'display' } ],
|
||||||
|
output_template => 'TWAMP Reverse Delta: %.2fms',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'TWAMPRevDelta', template => '%.2f',
|
||||||
|
min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'twamp-processing', nlabel => 'twamp.processingdelta.time.milliseconds', set => {
|
||||||
|
key_values => [ { name => 'TWAMPProcDelta' }, { name => 'display' } ],
|
||||||
|
output_template => 'TWAMP Processing Delta: %.2fms',
|
||||||
|
perfdatas => [
|
||||||
|
{ value => 'TWAMPProcDelta', template => '%.2f',
|
||||||
|
min => 0, unit => 'ms', label_extra_instance => 1, instance_use => 'display' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Agent '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
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 => {});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::check_options(%options);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{global} = {};
|
||||||
|
my $results = $options{custom}->request_api(endpoint => '/twamp');
|
||||||
|
$self->{global}->{display} = $results->{agentID};
|
||||||
|
foreach my $kpi (keys %{$results}) {
|
||||||
|
$self->{global}->{$kpi} = $results->{$kpi};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check agent TWAMP statistics.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--agent-id>
|
||||||
|
|
||||||
|
Set the ID of the agent (mandatory option).
|
||||||
|
|
||||||
|
=item B<--warning-twamp-forward>
|
||||||
|
|
||||||
|
Warning thresholds for TWAMP forward delta time (in milliseconds).
|
||||||
|
|
||||||
|
=item B<--critical-twamp-forward>
|
||||||
|
|
||||||
|
Critical thresholds for TWAMP forward delta time (in milliseconds).
|
||||||
|
|
||||||
|
=item B<--warning-twamp-reverse>
|
||||||
|
|
||||||
|
Warning thresholds for TWAMP reverse delta time (in milliseconds).
|
||||||
|
|
||||||
|
=item B<--critical-twamp-reverse>
|
||||||
|
|
||||||
|
Critical thresholds for TWAMP reverse delta time (in milliseconds).
|
||||||
|
|
||||||
|
=item B<--warning-twamp-processing>
|
||||||
|
|
||||||
|
Warning thresholds for TWAMP processing delta time (in milliseconds).
|
||||||
|
|
||||||
|
=item B<--critical-twamp-processing>
|
||||||
|
|
||||||
|
Critical thresholds for TWAMP processing delta time (in milliseconds).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
@ -36,7 +36,8 @@ sub new {
|
|||||||
'forecast' => 'apps::monitoring::latencetech::restapi::mode::forecast',
|
'forecast' => 'apps::monitoring::latencetech::restapi::mode::forecast',
|
||||||
'latency' => 'apps::monitoring::latencetech::restapi::mode::latency',
|
'latency' => 'apps::monitoring::latencetech::restapi::mode::latency',
|
||||||
'radio' => 'apps::monitoring::latencetech::restapi::mode::radio',
|
'radio' => 'apps::monitoring::latencetech::restapi::mode::radio',
|
||||||
'throughput' => 'apps::monitoring::latencetech::restapi::mode::throughput'
|
'throughput' => 'apps::monitoring::latencetech::restapi::mode::throughput',
|
||||||
|
'twamp' => 'apps::monitoring::latencetech::restapi::mode::twamp'
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->{custom_modes}->{api} = 'apps::monitoring::latencetech::restapi::custom::api';
|
$self->{custom_modes}->{api} = 'apps::monitoring::latencetech::restapi::custom::api';
|
||||||
|
@ -386,6 +386,35 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responseMode": null
|
"responseMode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uuid": "b7c86f2c-4e28-4834-bd84-3d5bfef56e19",
|
||||||
|
"type": "http",
|
||||||
|
"documentation": "",
|
||||||
|
"method": "get",
|
||||||
|
"endpoint": "api/v1/twamp",
|
||||||
|
"responses": [
|
||||||
|
{
|
||||||
|
"uuid": "33177ab5-ec9a-4b4a-b519-c4e25fbc96c7",
|
||||||
|
"body": "{\n \"CustomerID\": \"0\",\n \"agentID\": \"2\",\n \"time\": \"2025-07-25T14:13:08.975Z\",\n \"TWAMPfwdDelta\": 12.92,\n \"TWAMPRevDelta\": -4.19,\n \"TWAMPProcDelta\": 0.11\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": [
|
"rootChildren": [
|
||||||
@ -412,6 +441,10 @@
|
|||||||
{
|
{
|
||||||
"type": "route",
|
"type": "route",
|
||||||
"uuid": "232fe410-d4af-42c9-8efa-919b0c576625"
|
"uuid": "232fe410-d4af-42c9-8efa-919b0c576625"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "route",
|
||||||
|
"uuid": "b7c86f2c-4e28-4834-bd84-3d5bfef56e19"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"proxyMode": false,
|
"proxyMode": false,
|
||||||
|
51
tests/apps/monitoring/latencetech/restapi/twamp.robot
Normal file
51
tests/apps/monitoring/latencetech/restapi/twamp.robot
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
*** Settings ***
|
||||||
|
Documentation Check the LatenceTech twamp mode with api custom mode
|
||||||
|
|
||||||
|
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
|
||||||
|
|
||||||
|
Suite Setup Start Mockoon ${MOCKOON_JSON}
|
||||||
|
Suite Teardown Stop Mockoon
|
||||||
|
Test Timeout 120s
|
||||||
|
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${MOCKOON_JSON} ${CURDIR}${/}mockoon.json
|
||||||
|
|
||||||
|
${cmd} ${CENTREON_PLUGINS}
|
||||||
|
... --plugin=apps::monitoring::latencetech::restapi::plugin
|
||||||
|
... --custommode=api
|
||||||
|
... --mode=twamp
|
||||||
|
... --hostname=${HOSTNAME}
|
||||||
|
... --api-key=key
|
||||||
|
... --port=${APIPORT}
|
||||||
|
... --proto=http
|
||||||
|
|
||||||
|
|
||||||
|
*** Test Cases ***
|
||||||
|
Twamp ${tc}
|
||||||
|
[Documentation] Check the agent forecast statistics
|
||||||
|
[Tags] apps monitoring latencetech restapi
|
||||||
|
|
||||||
|
${command} Catenate
|
||||||
|
... ${cmd}
|
||||||
|
... --customer-id=0
|
||||||
|
... --agent-id=2
|
||||||
|
... ${extraoptions}
|
||||||
|
Log ${cmd}
|
||||||
|
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
|
||||||
|
|
||||||
|
Examples: tc extraoptions expected_result --
|
||||||
|
... 1 ${EMPTY}
|
||||||
|
... OK: Agent '2' TWAMP Forward Delta: 12.92ms, TWAMP Reverse Delta: -4.19ms, TWAMP Processing Delta: 0.11ms | '2#twamp.forwarddelta.time.milliseconds'=12.92ms;;;0; '2#twamp.reversedelta.time.milliseconds'=-4.19ms;;;0; '2#twamp.processingdelta.time.milliseconds'=0.11ms;;;0;
|
||||||
|
... 2 --warning-twamp-forward=10
|
||||||
|
... WARNING: Agent '2' TWAMP Forward Delta: 12.92ms | '2#twamp.forwarddelta.time.milliseconds'=12.92ms;0:10;;0; '2#twamp.reversedelta.time.milliseconds'=-4.19ms;;;0; '2#twamp.processingdelta.time.milliseconds'=0.11ms;;;0;
|
||||||
|
... 3 --critical-twamp-forward=12.5
|
||||||
|
... CRITICAL: Agent '2' TWAMP Forward Delta: 12.92ms | '2#twamp.forwarddelta.time.milliseconds'=12.92ms;;0:12.5;0; '2#twamp.reversedelta.time.milliseconds'=-4.19ms;;;0; '2#twamp.processingdelta.time.milliseconds'=0.11ms;;;0;
|
||||||
|
... 4 --warning-twamp-reverse=-4.5
|
||||||
|
... WARNING: Agent '2' TWAMP Reverse Delta: -4.19ms | '2#twamp.forwarddelta.time.milliseconds'=12.92ms;;;0; '2#twamp.reversedelta.time.milliseconds'=-4.19ms;0:-4.5;;0; '2#twamp.processingdelta.time.milliseconds'=0.11ms;;;0;
|
||||||
|
... 5 --critical-twamp-reverse=-5
|
||||||
|
... CRITICAL: Agent '2' TWAMP Reverse Delta: -4.19ms | '2#twamp.forwarddelta.time.milliseconds'=12.92ms;;;0; '2#twamp.reversedelta.time.milliseconds'=-4.19ms;;0:-5;0; '2#twamp.processingdelta.time.milliseconds'=0.11ms;;;0;
|
||||||
|
... 6 --warning-twamp-processing=0.05
|
||||||
|
... WARNING: Agent '2' TWAMP Processing Delta: 0.11ms | '2#twamp.forwarddelta.time.milliseconds'=12.92ms;;;0; '2#twamp.reversedelta.time.milliseconds'=-4.19ms;;;0; '2#twamp.processingdelta.time.milliseconds'=0.11ms;0:0.05;;0;
|
||||||
|
... 7 --critical-twamp-processing=0.1
|
||||||
|
... CRITICAL: Agent '2' TWAMP Processing Delta: 0.11ms | '2#twamp.forwarddelta.time.milliseconds'=12.92ms;;;0; '2#twamp.reversedelta.time.milliseconds'=-4.19ms;;;0; '2#twamp.processingdelta.time.milliseconds'=0.11ms;;0:0.1;0;
|
Loading…
x
Reference in New Issue
Block a user