From 55e796633a4a906ce6e158a45c77553aa0a83a17 Mon Sep 17 00:00:00 2001 From: matoy Date: Tue, 18 May 2021 19:25:39 +0200 Subject: [PATCH 01/17] new plugin for Azure CDN with 4 modes + discovery [xxxcdn]# /usr/lib/centreon/plugins//centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --custommode='api' --list-mode Plugin Description: Check Microsoft Azure CDP profile service. Global Options: --mode Choose a mode. --dyn-mode Specify a mode with the path (separated by '::'). --list-mode List available modes. --mode-version Check minimal version of mode. If not, unknown error. --version Display plugin version. --custommode Choose a custom mode. --list-custommode List available custom modes. --multiple Multiple custom mode objects (required by some specific modes) --pass-manager Use a password manager. Modes Meta: multi Modes Available: discovery hit-ratio latency request response [xxxcdn]# /usr/lib/centreon/plugins//centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --custommode='api' --mode='discovery' --subscription='xxx' --tenant='xxx' --client-id='xxx' --client-secret='' --resource-group='xxx' {"end_time":1621344000,"start_time":1621344000,"duration":0,"discovered_items":1,"results":[{"location":"global","sku":[{"value":"Standard_Microsoft","key":"name"}],"name":"xxx","resourceGroup":"xxx","type":"microsoft.cdn/profiles","id":"/subscriptions/xxx/resourceGroups/xxx/providers/microsoft.cdn/profiles/xxx","tags":[]}]} [xxxcdn]# /usr/lib/centreon/plugins//centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --custommode='api' --mode='hit-ratio' --subscription='xxx' --tenant='xxx' --client-id='xxx' --client-secret='' --resource-group='xxx' --resource='xxx' OK: Instance 'xxx' Statistic 'average' Metrics Byte Hit Ratio: 95.27% | 'xxx~average#cdn.byte.hit.percentage'=95.27%;;;0;100 [xxxcdn]# /usr/lib/centreon/plugins//centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --custommode='api' --mode='latency' --subscription='xxx' --tenant='xxx' --client-id='xxx' --client-secret='***' --resource-group='xxx' --resource='xxx' OK: Instance 'xxx' Statistic 'average' Metrics Total Latency: 1428.45ms | 'xxx~average#cdn.latency.total.milliseconds'=1428.45ms;;;0; [xxxcdn]# /usr/lib/centreon/plugins//centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --custommode='api' --mode='request' --subscription='xxx' --tenant='xxx' --client-id='xxx' --client-secret='***' --resource-group='xxx' --resource='xxx' OK: Instance 'xxx' Statistic 'count' Metrics Request count: 118.00 | 'xxx~count#cdn.request.count'=118.00;;;0; [xxxcdn]# /usr/lib/centreon/plugins//centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --custommode='api' --mode='response' --subscription='xxx' --tenant='xxx' --client-id='xxx' --client-secret='***' --resource-group='xxx' --resource='xxx' OK: Instance 'xxx' Statistic 'average' Metrics Response Size: 1092832.38Bytes | 'xxx~average#cdn.response.size'=1092832.38Bytes;;;0; --- cloud/azure/network/cdn/mode/discovery.pm | 60 +++++++++ cloud/azure/network/cdn/mode/hitratio.pm | 143 ++++++++++++++++++++++ cloud/azure/network/cdn/mode/latency.pm | 143 ++++++++++++++++++++++ cloud/azure/network/cdn/mode/request.pm | 143 ++++++++++++++++++++++ cloud/azure/network/cdn/mode/response.pm | 143 ++++++++++++++++++++++ cloud/azure/network/cdn/plugin.pm | 64 ++++++++++ 6 files changed, 696 insertions(+) create mode 100644 cloud/azure/network/cdn/mode/discovery.pm create mode 100644 cloud/azure/network/cdn/mode/hitratio.pm create mode 100644 cloud/azure/network/cdn/mode/latency.pm create mode 100644 cloud/azure/network/cdn/mode/request.pm create mode 100644 cloud/azure/network/cdn/mode/response.pm create mode 100644 cloud/azure/network/cdn/plugin.pm diff --git a/cloud/azure/network/cdn/mode/discovery.pm b/cloud/azure/network/cdn/mode/discovery.pm new file mode 100644 index 000000000..696168be0 --- /dev/null +++ b/cloud/azure/network/cdn/mode/discovery.pm @@ -0,0 +1,60 @@ +# +# Copyright 2021 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 cloud::azure::network::cdn::mode::discovery; + +use base qw(cloud::azure::management::monitor::mode::discovery); + +use strict; +use warnings; + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{namespace} = 'Microsoft.Cdn'; + $self->{type} = 'profiles'; +} + +1; + +__END__ + +=head1 MODE + +Azure CDN discovery. + +=over 8 + +=item B<--resource-group> + +Specify resource group. + +=item B<--location> + +Specify location. + +=item B<--prettify> + +Prettify JSON output. + +=back + +=cut diff --git a/cloud/azure/network/cdn/mode/hitratio.pm b/cloud/azure/network/cdn/mode/hitratio.pm new file mode 100644 index 000000000..af6622789 --- /dev/null +++ b/cloud/azure/network/cdn/mode/hitratio.pm @@ -0,0 +1,143 @@ +# +# Copyright 2021 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 cloud::azure::network::cdn::mode::hitratio; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'bytehitratio' => { + 'output' => 'Byte Hit Ratio', + 'label' => 'byte-hit-percentage', + 'nlabel' => 'cdn.byte.hit.percentage', + 'unit' => '%', + 'min' => '0', + 'max' => '100' + } + }; + + return $metrics_mapping; +} + +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-metric:s' => { name => 'filter_metric' }, + 'resource:s' => { name => 'resource' }, + 'resource-group:s' => { name => 'resource_group' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + my $resource = $self->{option_results}->{resource}; + my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : ''; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Cdn\/profiles\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'profiles'; + $self->{az_resource_namespace} = 'Microsoft.Cdn'; + $self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; + $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M'; + $self->{az_aggregations} = ['Average']; + if (defined($self->{option_results}->{aggregation})) { + $self->{az_aggregations} = []; + foreach my $stat (@{$self->{option_results}->{aggregation}}) { + if ($stat ne '') { + push @{$self->{az_aggregations}}, ucfirst(lc($stat)); + } + } + } + + foreach my $metric (keys %{$self->{metrics_mapping}}) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{az_metrics}}, $metric; + } +} + +1; + +__END__ + +=head1 MODE + +Check Azure CDN byte hit ratio. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=hit-ratio --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-byte-hit-percentage='20:' --critical-byte-hit-percentage='10:' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=hit-ratio --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.Cdn/profiles/' +--aggregation='average' --warning-byte-hit-percentage='20:' --critical-byte-hit-percentage='10:' + +Default aggregation: 'average' / 'minimum', 'maximum' and 'total' are valid. + +=over 8 + +=item B<--resource> + +Set resource name or id (Required). + +=item B<--resource-group> + +Set resource group (Required if resource's name is used). + +=item B<--warning-*> + +Warning threshold where '*' can be: +'byte-hit-percentage'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'byte-hit-percentage'. + +=back + +=cut diff --git a/cloud/azure/network/cdn/mode/latency.pm b/cloud/azure/network/cdn/mode/latency.pm new file mode 100644 index 000000000..5dc9ec0dd --- /dev/null +++ b/cloud/azure/network/cdn/mode/latency.pm @@ -0,0 +1,143 @@ +# +# Copyright 2021 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 cloud::azure::network::cdn::mode::latency; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'totallatency' => { + 'output' => 'Total Latency', + 'label' => 'total-latency', + 'nlabel' => 'cdn.latency.total.milliseconds', + 'unit' => 'ms', + 'min' => '0', + 'max' => '' + } + }; + + return $metrics_mapping; +} + +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-metric:s' => { name => 'filter_metric' }, + 'resource:s' => { name => 'resource' }, + 'resource-group:s' => { name => 'resource_group' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + my $resource = $self->{option_results}->{resource}; + my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : ''; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Cdn\/profiles\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'profiles'; + $self->{az_resource_namespace} = 'Microsoft.Cdn'; + $self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; + $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M'; + $self->{az_aggregations} = ['Average']; + if (defined($self->{option_results}->{aggregation})) { + $self->{az_aggregations} = []; + foreach my $stat (@{$self->{option_results}->{aggregation}}) { + if ($stat ne '') { + push @{$self->{az_aggregations}}, ucfirst(lc($stat)); + } + } + } + + foreach my $metric (keys %{$self->{metrics_mapping}}) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{az_metrics}}, $metric; + } +} + +1; + +__END__ + +=head1 MODE + +Check Azure CDN latency. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=latency --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-total-latency='50' --critical-total-latency='100' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=latency --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.Cdn/profiles/' +--aggregation='average' --warning-total-latency='50' --critical-total-latency='100' + +Default aggregation: 'average' / 'minimum', 'maximum' and 'total' are valid. + +=over 8 + +=item B<--resource> + +Set resource name or id (Required). + +=item B<--resource-group> + +Set resource group (Required if resource's name is used). + +=item B<--warning-*> + +Warning threshold where '*' can be: +'total-latency'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'total-latency'. + +=back + +=cut diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/request.pm new file mode 100644 index 000000000..b15df9c1f --- /dev/null +++ b/cloud/azure/network/cdn/mode/request.pm @@ -0,0 +1,143 @@ +# +# Copyright 2021 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 cloud::azure::network::cdn::mode::request; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'requestcount' => { + 'output' => 'Request count', + 'label' => 'request-count', + 'nlabel' => 'cdn.request.count', + 'unit' => '', + 'min' => '0', + 'max' => '' + } + }; + + return $metrics_mapping; +} + +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-metric:s' => { name => 'filter_metric' }, + 'resource:s' => { name => 'resource' }, + 'resource-group:s' => { name => 'resource_group' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + my $resource = $self->{option_results}->{resource}; + my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : ''; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Cdn\/profiles\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'profiles'; + $self->{az_resource_namespace} = 'Microsoft.Cdn'; + $self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; + $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M'; + $self->{az_aggregations} = ['Count']; + if (defined($self->{option_results}->{aggregation})) { + $self->{az_aggregations} = []; + foreach my $stat (@{$self->{option_results}->{aggregation}}) { + if ($stat ne '') { + push @{$self->{az_aggregations}}, ucfirst(lc($stat)); + } + } + } + + foreach my $metric (keys %{$self->{metrics_mapping}}) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{az_metrics}}, $metric; + } +} + +1; + +__END__ + +=head1 MODE + +Check Azure CDN request count. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=request --custommode=api +--resource= --resource-group= --aggregation='count' +--warning-request-count='2000' --critical-request-count='3000' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=request --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.Cdn/profiles/' +--aggregation='count' --warning-request-count='800' --critical-request-count='900' + +Default aggregation: 'count' / 'minimum', 'maximum' and 'total' are valid. + +=over 8 + +=item B<--resource> + +Set resource name or id (Required). + +=item B<--resource-group> + +Set resource group (Required if resource's name is used). + +=item B<--warning-*> + +Warning threshold where '*' can be: +'request-count'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'request-count'. + +=back + +=cut diff --git a/cloud/azure/network/cdn/mode/response.pm b/cloud/azure/network/cdn/mode/response.pm new file mode 100644 index 000000000..b2166e9c5 --- /dev/null +++ b/cloud/azure/network/cdn/mode/response.pm @@ -0,0 +1,143 @@ +# +# Copyright 2021 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 cloud::azure::network::cdn::mode::response; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'responsesize' => { + 'output' => 'Response Size', + 'label' => 'response-size', + 'nlabel' => 'cdn.response.size', + 'unit' => 'Bytes', + 'min' => '0', + 'max' => '' + } + }; + + return $metrics_mapping; +} + +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-metric:s' => { name => 'filter_metric' }, + 'resource:s' => { name => 'resource' }, + 'resource-group:s' => { name => 'resource_group' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource with --resource-group option or --resource .'); + $self->{output}->option_exit(); + } + my $resource = $self->{option_results}->{resource}; + my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : ''; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Cdn\/profiles\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'profiles'; + $self->{az_resource_namespace} = 'Microsoft.Cdn'; + $self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900; + $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M'; + $self->{az_aggregations} = ['Average']; + if (defined($self->{option_results}->{aggregation})) { + $self->{az_aggregations} = []; + foreach my $stat (@{$self->{option_results}->{aggregation}}) { + if ($stat ne '') { + push @{$self->{az_aggregations}}, ucfirst(lc($stat)); + } + } + } + + foreach my $metric (keys %{$self->{metrics_mapping}}) { + next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne '' + && $metric !~ /$self->{option_results}->{filter_metric}/); + push @{$self->{az_metrics}}, $metric; + } +} + +1; + +__END__ + +=head1 MODE + +Check Azure CDN response size. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=response --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-response-size='8000000' --critical-response-size='9000000' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=response --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.Cdn/profiles/' +--aggregation='average' --warning-response-size='8000000' --critical-response-size='9000000' + +Default aggregation: 'average / 'minimum', 'maximum' and 'total' are valid. + +=over 8 + +=item B<--resource> + +Set resource name or id (Required). + +=item B<--resource-group> + +Set resource group (Required if resource's name is used). + +=item B<--warning-*> + +Warning threshold where '*' can be: +'response-size'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'response-size'. + +=back + +=cut diff --git a/cloud/azure/network/cdn/plugin.pm b/cloud/azure/network/cdn/plugin.pm new file mode 100644 index 000000000..003ee7083 --- /dev/null +++ b/cloud/azure/network/cdn/plugin.pm @@ -0,0 +1,64 @@ +# +# Copyright 2021 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 cloud::azure::network::cdn::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} = '0.1'; + $self->{modes} = { + 'discovery' => 'cloud::azure::network::cdn::mode::discovery', + 'hit-ratio' => 'cloud::azure::network::cdn::mode::hitratio', + 'request' => 'cloud::azure::network::cdn::mode::request', + 'response' => 'cloud::azure::network::cdn::mode::response', + 'latency' => 'cloud::azure::network::cdn::mode::latency' + }; + + $self->{custom_modes}->{azcli} = 'cloud::azure::custom::azcli'; + $self->{custom_modes}->{api} = 'cloud::azure::custom::api'; + return $self; +} + +sub init { + my ($self, %options) = @_; + + $self->{options}->add_options(arguments => { + 'api-version:s' => { name => 'api_version', default => '2018-01-01' } + }); + + $self->SUPER::init(%options); +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Microsoft Azure CDP profile service. + +=cut From 27ce2843dd9cbe03bd846bf88934e63078ea44c8 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 19 May 2021 11:27:05 +0200 Subject: [PATCH 02/17] Update plugin.pm --- cloud/azure/network/cdn/plugin.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/plugin.pm b/cloud/azure/network/cdn/plugin.pm index 003ee7083..8cec950e8 100644 --- a/cloud/azure/network/cdn/plugin.pm +++ b/cloud/azure/network/cdn/plugin.pm @@ -59,6 +59,6 @@ __END__ =head1 PLUGIN DESCRIPTION -Check Microsoft Azure CDP profile service. +Check Microsoft Azure CDN profile service. =cut From 5c1b15a37bee0d53ee8486b64a5826676915a546 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:10:55 +0200 Subject: [PATCH 03/17] Update cloud/azure/network/cdn/mode/hitratio.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/hitratio.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cloud/azure/network/cdn/mode/hitratio.pm b/cloud/azure/network/cdn/mode/hitratio.pm index af6622789..86893324e 100644 --- a/cloud/azure/network/cdn/mode/hitratio.pm +++ b/cloud/azure/network/cdn/mode/hitratio.pm @@ -133,10 +133,9 @@ Set resource group (Required if resource's name is used). Warning threshold where '*' can be: 'byte-hit-percentage'. -=item B<--critical-*> +=item B<--critical-byte-hit-percentage> -Critical threshold where '*' can be: -'byte-hit-percentage'. +Critical threshold. =back From e7cb7b6c7a39afd59007014621f2e0655c155e8d Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:12:07 +0200 Subject: [PATCH 04/17] Update cloud/azure/network/cdn/mode/hitratio.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/hitratio.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cloud/azure/network/cdn/mode/hitratio.pm b/cloud/azure/network/cdn/mode/hitratio.pm index 86893324e..12cd9aab2 100644 --- a/cloud/azure/network/cdn/mode/hitratio.pm +++ b/cloud/azure/network/cdn/mode/hitratio.pm @@ -128,10 +128,9 @@ Set resource name or id (Required). Set resource group (Required if resource's name is used). -=item B<--warning-*> +=item B<--warning-byte-hit-percentage> -Warning threshold where '*' can be: -'byte-hit-percentage'. +Warning threshold. =item B<--critical-byte-hit-percentage> From a1e8f3b33d635a39d8e52133a8a3f3e69f43bf26 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:12:15 +0200 Subject: [PATCH 05/17] Update cloud/azure/network/cdn/mode/latency.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/latency.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cloud/azure/network/cdn/mode/latency.pm b/cloud/azure/network/cdn/mode/latency.pm index 5dc9ec0dd..eff780efb 100644 --- a/cloud/azure/network/cdn/mode/latency.pm +++ b/cloud/azure/network/cdn/mode/latency.pm @@ -128,10 +128,9 @@ Set resource name or id (Required). Set resource group (Required if resource's name is used). -=item B<--warning-*> +=item B<--warning-total-latency> -Warning threshold where '*' can be: -'total-latency'. +Warning threshold. =item B<--critical-*> From 9b1480fd18c7fd94edb389c41cebb7295dbbcd91 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:12:25 +0200 Subject: [PATCH 06/17] Update cloud/azure/network/cdn/mode/latency.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/latency.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cloud/azure/network/cdn/mode/latency.pm b/cloud/azure/network/cdn/mode/latency.pm index eff780efb..a1d9a58a1 100644 --- a/cloud/azure/network/cdn/mode/latency.pm +++ b/cloud/azure/network/cdn/mode/latency.pm @@ -132,10 +132,9 @@ Set resource group (Required if resource's name is used). Warning threshold. -=item B<--critical-*> +=item B<--critical-total-latency> -Critical threshold where '*' can be: -'total-latency'. +Critical threshold. =back From c7115716f10e55e497884345f4c3f4b808ba4c13 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:12:35 +0200 Subject: [PATCH 07/17] Update cloud/azure/network/cdn/mode/request.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/request.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/request.pm index b15df9c1f..dda9074b7 100644 --- a/cloud/azure/network/cdn/mode/request.pm +++ b/cloud/azure/network/cdn/mode/request.pm @@ -18,7 +18,7 @@ # limitations under the License. # -package cloud::azure::network::cdn::mode::request; +package cloud::azure::network::cdn::mode::requests; use base qw(cloud::azure::custom::mode); From 033b4f648caee00cb630b02073fe96d07d0abf74 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:12:46 +0200 Subject: [PATCH 08/17] Update cloud/azure/network/cdn/mode/request.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/request.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/request.pm index dda9074b7..06358d5c5 100644 --- a/cloud/azure/network/cdn/mode/request.pm +++ b/cloud/azure/network/cdn/mode/request.pm @@ -32,7 +32,7 @@ sub get_metrics_mapping { 'requestcount' => { 'output' => 'Request count', 'label' => 'request-count', - 'nlabel' => 'cdn.request.count', + 'nlabel' => 'cdn.requests.count', 'unit' => '', 'min' => '0', 'max' => '' From 7b6b73d7995da7037b0811fe80f681803ed512fe Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:12:59 +0200 Subject: [PATCH 09/17] Update cloud/azure/network/cdn/mode/request.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/request.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/request.pm index 06358d5c5..4b4684325 100644 --- a/cloud/azure/network/cdn/mode/request.pm +++ b/cloud/azure/network/cdn/mode/request.pm @@ -36,6 +36,22 @@ sub get_metrics_mapping { 'unit' => '', 'min' => '0', 'max' => '' + }, + 'percentage4xx' => { + 'output' => 'Percentage of 4XX', + 'label' => '4xx-requests-percentage', + 'nlabel' => 'cdn.requests.4xx.percentage', + 'unit' => '%', + 'min' => '0', + 'max' => '100' + }, + 'percentage5xx' => { + 'output' => 'Percentage of 5XX', + 'label' => '5xx-requests-percentage', + 'nlabel' => 'cdn.requests.5xx.percentage', + 'unit' => '%', + 'min' => '0', + 'max' => '100' } }; From 2cd4f505d000527bad50f49358f2cfac47bd9701 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:13:12 +0200 Subject: [PATCH 10/17] Update cloud/azure/network/cdn/mode/request.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/request.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/request.pm index 4b4684325..12f15f235 100644 --- a/cloud/azure/network/cdn/mode/request.pm +++ b/cloud/azure/network/cdn/mode/request.pm @@ -122,7 +122,7 @@ Example: Using resource name : -perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=request --custommode=api +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=requests --custommode=api --resource= --resource-group= --aggregation='count' --warning-request-count='2000' --critical-request-count='3000' From 8512a3f78fcc23c20b9f51e352480e156eb748d1 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:13:24 +0200 Subject: [PATCH 11/17] Update cloud/azure/network/cdn/mode/request.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/request.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/request.pm index 12f15f235..2d292bb6c 100644 --- a/cloud/azure/network/cdn/mode/request.pm +++ b/cloud/azure/network/cdn/mode/request.pm @@ -128,7 +128,7 @@ perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=requ Using resource id : -perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=request --custommode=api +perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=requests --custommode=api --resource='/subscriptions//resourceGroups//providers/Microsoft.Cdn/profiles/' --aggregation='count' --warning-request-count='800' --critical-request-count='900' From c7d32d0250326e04c5bf9b8a09079197de387ebe Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:13:36 +0200 Subject: [PATCH 12/17] Update cloud/azure/network/cdn/mode/request.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/request.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/request.pm index 2d292bb6c..c38d4821a 100644 --- a/cloud/azure/network/cdn/mode/request.pm +++ b/cloud/azure/network/cdn/mode/request.pm @@ -147,7 +147,7 @@ Set resource group (Required if resource's name is used). =item B<--warning-*> Warning threshold where '*' can be: -'request-count'. +'requests-count', '4xx-requests-percentage',, '5xx-requests-percentage', 'firewall-requests-count'. =item B<--critical-*> From 7e5b03cf26751be0dc04c9c902ad7d7b5b335d28 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:13:53 +0200 Subject: [PATCH 13/17] Update cloud/azure/network/cdn/mode/request.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/request.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/request.pm index c38d4821a..8b02ce792 100644 --- a/cloud/azure/network/cdn/mode/request.pm +++ b/cloud/azure/network/cdn/mode/request.pm @@ -152,7 +152,7 @@ Warning threshold where '*' can be: =item B<--critical-*> Critical threshold where '*' can be: -'request-count'. +'requests-count', '4xx-requests-percentage',, '5xx-requests-percentage', 'firewall-requests-count'. =back From 19b8c7e08f4d8800f7b8481c2fa103d0247cc45f Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:14:09 +0200 Subject: [PATCH 14/17] Update cloud/azure/network/cdn/mode/response.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/response.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/mode/response.pm b/cloud/azure/network/cdn/mode/response.pm index b2166e9c5..47ec3c531 100644 --- a/cloud/azure/network/cdn/mode/response.pm +++ b/cloud/azure/network/cdn/mode/response.pm @@ -32,7 +32,7 @@ sub get_metrics_mapping { 'responsesize' => { 'output' => 'Response Size', 'label' => 'response-size', - 'nlabel' => 'cdn.response.size', + 'nlabel' => 'cdn.response.size.bytes', 'unit' => 'Bytes', 'min' => '0', 'max' => '' From b6888c85256ff9d2312e6a0b0b29892447e15cbd Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:14:23 +0200 Subject: [PATCH 15/17] Update cloud/azure/network/cdn/plugin.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/plugin.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud/azure/network/cdn/plugin.pm b/cloud/azure/network/cdn/plugin.pm index 8cec950e8..8517b873e 100644 --- a/cloud/azure/network/cdn/plugin.pm +++ b/cloud/azure/network/cdn/plugin.pm @@ -33,9 +33,9 @@ sub new { $self->{modes} = { 'discovery' => 'cloud::azure::network::cdn::mode::discovery', 'hit-ratio' => 'cloud::azure::network::cdn::mode::hitratio', - 'request' => 'cloud::azure::network::cdn::mode::request', + 'latency' => 'cloud::azure::network::cdn::mode::latency', + 'requests' => 'cloud::azure::network::cdn::mode::requests', 'response' => 'cloud::azure::network::cdn::mode::response', - 'latency' => 'cloud::azure::network::cdn::mode::latency' }; $self->{custom_modes}->{azcli} = 'cloud::azure::custom::azcli'; From ac7fa3bbf0a617223978d296dd172c7da31d0836 Mon Sep 17 00:00:00 2001 From: matoy Date: Wed, 9 Jun 2021 18:14:39 +0200 Subject: [PATCH 16/17] Update cloud/azure/network/cdn/mode/response.pm Co-authored-by: itoussies <65223458+itoussies@users.noreply.github.com> --- cloud/azure/network/cdn/mode/response.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/azure/network/cdn/mode/response.pm b/cloud/azure/network/cdn/mode/response.pm index 47ec3c531..1ce36ecff 100644 --- a/cloud/azure/network/cdn/mode/response.pm +++ b/cloud/azure/network/cdn/mode/response.pm @@ -33,7 +33,7 @@ sub get_metrics_mapping { 'output' => 'Response Size', 'label' => 'response-size', 'nlabel' => 'cdn.response.size.bytes', - 'unit' => 'Bytes', + 'unit' => 'B', 'min' => '0', 'max' => '' } From 17d5a5a6eb870aba05d95e1d4bd06f1d50158ac4 Mon Sep 17 00:00:00 2001 From: itoussies <65223458+itoussies@users.noreply.github.com> Date: Thu, 10 Jun 2021 19:34:35 +0200 Subject: [PATCH 17/17] Update and rename request.pm to requests.pm --- cloud/azure/network/cdn/mode/{request.pm => requests.pm} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename cloud/azure/network/cdn/mode/{request.pm => requests.pm} (96%) diff --git a/cloud/azure/network/cdn/mode/request.pm b/cloud/azure/network/cdn/mode/requests.pm similarity index 96% rename from cloud/azure/network/cdn/mode/request.pm rename to cloud/azure/network/cdn/mode/requests.pm index 8b02ce792..d6439b602 100644 --- a/cloud/azure/network/cdn/mode/request.pm +++ b/cloud/azure/network/cdn/mode/requests.pm @@ -31,7 +31,7 @@ sub get_metrics_mapping { my $metrics_mapping = { 'requestcount' => { 'output' => 'Request count', - 'label' => 'request-count', + 'label' => 'requests-count', 'nlabel' => 'cdn.requests.count', 'unit' => '', 'min' => '0', @@ -124,13 +124,13 @@ Using resource name : perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=requests --custommode=api --resource= --resource-group= --aggregation='count' ---warning-request-count='2000' --critical-request-count='3000' +--warning-requests-count='2000' --critical-requests-count='3000' Using resource id : perl centreon_plugins.pl --plugin=cloud::azure::network::cdn::plugin --mode=requests --custommode=api --resource='/subscriptions//resourceGroups//providers/Microsoft.Cdn/profiles/' ---aggregation='count' --warning-request-count='800' --critical-request-count='900' +--aggregation='count' --warning-requests-count='800' --critical-requests-count='900' Default aggregation: 'count' / 'minimum', 'maximum' and 'total' are valid.