From 2a1591a908305b6508cbc41eafc268dcebafae9e Mon Sep 17 00:00:00 2001 From: Thibault S <48209914+thibaults-centreon@users.noreply.github.com> Date: Tue, 16 Mar 2021 22:02:43 +0100 Subject: [PATCH] add(plugin): New Azure Plugins (#2656) Co-authored-by: itoussies Co-authored-by: Simon Bomm --- .../integration/eventgrid/mode/discovery.pm | 144 +++++++++++ .../integration/eventgrid/mode/events.pm | 204 +++++++++++++++ .../integration/eventgrid/mode/eventstats.pm | 232 ++++++++++++++++++ .../integration/eventgrid/mode/health.pm | 78 ++++++ .../azure/integration/eventgrid/plugin.pm | 63 +++++ .../servicebus/mode/connections.pm | 156 ++++++++++++ .../integration/servicebus/mode/discovery.pm | 60 +++++ .../integration/servicebus/mode/health.pm | 78 ++++++ .../integration/servicebus/mode/messages.pm | 178 ++++++++++++++ .../integration/servicebus/mode/requests.pm | 156 ++++++++++++ .../integration/servicebus/mode/resources.pm | 151 ++++++++++++ .../azure/integration/servicebus/plugin.pm | 65 +++++ .../management/automation/mode/discovery.pm | 60 +++++ .../management/automation/mode/health.pm | 78 ++++++ .../azure/management/automation/mode/jobs.pm | 156 ++++++++++++ .../azure/management/automation/plugin.pm | 62 +++++ .../azure/security/keyvault/mode/discovery.pm | 2 +- .../security/keyvault/mode/serviceapi.pm | 2 +- .../keyvault/mode/vaultavailability.pm | 2 +- .../security/keyvault/mode/vaultcapacity.pm | 2 +- .../cloud/azure/security/keyvault/plugin.pm | 2 +- .../cloud/azure/web/signalr/mode/discovery.pm | 60 +++++ .../cloud/azure/web/signalr/mode/errors.pm | 151 ++++++++++++ .../cloud/azure/web/signalr/mode/health.pm | 76 ++++++ .../cloud/azure/web/signalr/mode/traffic.pm | 149 +++++++++++ .../cloud/azure/web/signalr/mode/usage.pm | 149 +++++++++++ .../cloud/azure/web/signalr/plugin.pm | 64 +++++ 27 files changed, 2575 insertions(+), 5 deletions(-) create mode 100644 centreon-plugins/cloud/azure/integration/eventgrid/mode/discovery.pm create mode 100644 centreon-plugins/cloud/azure/integration/eventgrid/mode/events.pm create mode 100644 centreon-plugins/cloud/azure/integration/eventgrid/mode/eventstats.pm create mode 100644 centreon-plugins/cloud/azure/integration/eventgrid/mode/health.pm create mode 100644 centreon-plugins/cloud/azure/integration/eventgrid/plugin.pm create mode 100644 centreon-plugins/cloud/azure/integration/servicebus/mode/connections.pm create mode 100644 centreon-plugins/cloud/azure/integration/servicebus/mode/discovery.pm create mode 100644 centreon-plugins/cloud/azure/integration/servicebus/mode/health.pm create mode 100644 centreon-plugins/cloud/azure/integration/servicebus/mode/messages.pm create mode 100644 centreon-plugins/cloud/azure/integration/servicebus/mode/requests.pm create mode 100644 centreon-plugins/cloud/azure/integration/servicebus/mode/resources.pm create mode 100644 centreon-plugins/cloud/azure/integration/servicebus/plugin.pm create mode 100644 centreon-plugins/cloud/azure/management/automation/mode/discovery.pm create mode 100644 centreon-plugins/cloud/azure/management/automation/mode/health.pm create mode 100644 centreon-plugins/cloud/azure/management/automation/mode/jobs.pm create mode 100644 centreon-plugins/cloud/azure/management/automation/plugin.pm create mode 100644 centreon-plugins/cloud/azure/web/signalr/mode/discovery.pm create mode 100644 centreon-plugins/cloud/azure/web/signalr/mode/errors.pm create mode 100644 centreon-plugins/cloud/azure/web/signalr/mode/health.pm create mode 100644 centreon-plugins/cloud/azure/web/signalr/mode/traffic.pm create mode 100644 centreon-plugins/cloud/azure/web/signalr/mode/usage.pm create mode 100644 centreon-plugins/cloud/azure/web/signalr/plugin.pm diff --git a/centreon-plugins/cloud/azure/integration/eventgrid/mode/discovery.pm b/centreon-plugins/cloud/azure/integration/eventgrid/mode/discovery.pm new file mode 100644 index 000000000..c9005ec18 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/eventgrid/mode/discovery.pm @@ -0,0 +1,144 @@ +# +# 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::integration::eventgrid::mode::discovery; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use JSON::XS; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'namespace:s' => { name => 'namespace' }, + 'type:s' => { name => 'type' }, + 'resource-group:s' => { name => 'resource_group' }, + 'location:s' => { name => 'location' }, + 'prettify' => { name => 'prettify' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); + + $self->{namespace} = $self->{option_results}->{namespace}; + $self->{type} = $self->{option_results}->{type}; + $self->{location} = $self->{option_results}->{location}; + $self->{resource_group} = $self->{option_results}->{resource_group}; +} + +sub run { + my ($self, %options) = @_; + + my @disco_data; + my $disco_stats; + + $disco_stats->{start_time} = time(); + + my $resources = $options{custom}->azure_list_resources( + namespace => $self->{namespace}, + resource_type => $self->{type}, + location => $self->{location}, + resource_group => $self->{resource_group} + ); + + $disco_stats->{end_time} = time(); + $disco_stats->{duration} = $disco_stats->{end_time} - $disco_stats->{start_time}; + + foreach my $resource (@{$resources}) { + next if ($resource->{type} !~ /Microsoft\.EventGrid/); + $resource->{type} =~ s/Microsoft\.EventGrid\///; + my $resource_group = ''; + $resource_group = $resource->{resourceGroup} if (defined($resource->{resourceGroup})); + $resource_group = $1 if ($resource_group eq '' && defined($resource->{id}) && $resource->{id} =~ /resourceGroups\/(.*)\/providers/); + $resource->{resourceGroup} = $resource_group; + + foreach my $entry (keys %{$resource}) { + next if (ref($resource->{$entry}) ne "HASH"); + my @array; + foreach my $key (keys %{$resource->{$entry}}) { + push @array, { key => $key, value => $resource->{$entry}->{$key} }; + } + $resource->{$entry} = \@array; + } + push @disco_data, $resource; + } + + $disco_stats->{discovered_items} = @disco_data; + $disco_stats->{results} = \@disco_data; + + my $encoded_data; + eval { + if (defined($self->{option_results}->{prettify})) { + $encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats); + } else { + $encoded_data = JSON::XS->new->utf8->encode($disco_stats); + } + }; + if ($@) { + $encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}'; + } + + $self->{output}->output_add(short_msg => $encoded_data); + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1); + $self->{output}->exit(); +} + +1; + +__END__ + +=head1 MODE + +Resources discovery. + +=over 8 + +=item B<--namespace> + +Specify resources namespace. + +=item B<--type> + +Specify resources type. + +=item B<--resource-group> + +Specify resources resource group. + +=item B<--location> + +Specify resources location. + +=item B<--prettify> + +Prettify JSON output. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/eventgrid/mode/events.pm b/centreon-plugins/cloud/azure/integration/eventgrid/mode/events.pm new file mode 100644 index 000000000..fce495bf3 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/eventgrid/mode/events.pm @@ -0,0 +1,204 @@ +# +# 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::integration::eventgrid::mode::events; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'deadletteredcount' => { + 'output' => 'Dead Lettered Events', + 'label' => 'deadlettered-events', + 'nlabel' => 'eventgrid.deadlettered.events.count', + 'unit' => '', + 'min' => '0' + }, + 'droppedeventcount' => { + 'output' => 'Dropped Events', + 'label' => 'dropped-events', + 'nlabel' => 'eventgrid.dropped.events.count', + 'unit' => '', + 'min' => '0' + }, + 'matchedeventcount' => { + 'output' => 'Matched Events', + 'label' => 'matched-events', + 'nlabel' => 'eventgrid.matched.events.count', + 'unit' => '', + 'min' => '0' + }, + 'unmatchedeventcount' => { + 'output' => 'Unmatched Events', + 'label' => 'unmatched-events', + 'nlabel' => 'eventgrid.unmatched.events.count', + 'unit' => '', + 'min' => '0' + } + }; + + 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' }, + 'resource-type:s' => { name => 'resource_type', default => 'topics' } + }); + + 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(); + } + + if (!defined($self->{option_results}->{resource_type}) || + $self->{option_results}->{resource_type} !~ /topics|systemTopics|partnerTopic|partnerNamespaces|extensionTopics|eventSubscriptions|domains/) { + $self->{output}->add_option_msg(short_msg => 'Please specify an existing Azure Event Grid resource type'); + $self->{output}->option_exit(); + } + + my $resource = $self->{option_results}->{resource}; + my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : ''; + my $resource_type = $self->{option_results}->{resource_type}; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.EventGrid\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.EventGrid'; + $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} = ['Total']; + 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)); + } + } + } + + my $type; + if ($resource_type =~ /topics|systemTopics|partnerTopic|partnerNamespaces/) { + $type = 'topics'; + + } elsif ($resource_type eq 'extensionTopics') { + $type = 'extensionTopics'; + + } else { + $type = 'eventSubscriptions'; + } + + my $resource_mapping = { + 'topics' => [ 'deadletteredcount', 'droppedeventcount', 'matchedeventcount', 'unmatchedeventcount' ], + 'extensionTopics' => [ 'unmatchedeventcount' ], + 'eventSubscriptions' => [ 'deadletteredcount', 'droppedeventcount', 'matchedeventcount' ] + }; + + my $metrics_mapping_transformed; + foreach my $metric_type (@{$resource_mapping->{$type}}) { + $metrics_mapping_transformed->{$metric_type} = $self->{metrics_mapping}->{$metric_type}; + } + + foreach my $metric (keys %{$metrics_mapping_transformed}) { + 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 Event Grid events. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::eventgrid::plugin --mode=events --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-matched-events='20' --critical-matched-events='50' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::eventgrid::plugin --mode=events --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.EventGrid//' +--aggregation='average' --warning-matched-events='20' --critical-matched-events='50' + +Default aggregation: 'average' / 'total', 'minimum' and 'maximum' 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<--resource-type> + +Set resource type (Default: 'topics'). Can be 'topics', +'systemTopics', 'partnerTopics', 'partnerNamespaces', +'extensionTopics', 'extensionTopics', 'domains'). + +=item B<--warning-*> + +Warning threshold where '*' can be: +'matched-events', 'deadlettered-events', 'unmatched-events', +'dropped-events'. + +=item B<--critical-vault-capacity-percentage> + +Critical threshold where '*' can be: +'matched-events', 'deadlettered-events', 'unmatched-events', +'dropped-events'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/eventgrid/mode/eventstats.pm b/centreon-plugins/cloud/azure/integration/eventgrid/mode/eventstats.pm new file mode 100644 index 000000000..4d9bb7685 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/eventgrid/mode/eventstats.pm @@ -0,0 +1,232 @@ +# +# 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::integration::eventgrid::mode::eventstats; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'deliveryattemptfailcount' => { + 'output' => 'Delivery Failed Events', + 'label' => 'delivery-failed', + 'nlabel' => 'eventgrid.delivery.failed.count', + 'unit' => '', + 'min' => '0' + }, + 'deliverysuccesscount' => { + 'output' => 'Delivered Events', + 'label' => 'delivery-successful', + 'nlabel' => 'eventgrid.delivery.successfull.count', + 'unit' => '', + 'min' => '0' + }, + 'destinationprocessingdurationinms' => { + 'output' => 'Destination Processing Duration', + 'label' => 'processing-duration', + 'nlabel' => 'eventgrid.processing.duration.milliseconds', + 'unit' => 'ms', + 'min' => '0' + }, + 'publishfailcount' => { + 'output' => 'Publish Failed Events', + 'label' => 'publish-failed', + 'nlabel' => 'eventgrid.publish.failed.count', + 'unit' => '', + 'min' => '0' + }, + 'publishsuccesscount' => { + 'output' => 'Published Events', + 'label' => 'publish-successful', + 'nlabel' => 'eventgrid.publish.successfull.count', + 'unit' => '', + 'min' => '0' + }, + 'publishsuccesslatencyinms' => { + 'output' => 'Publish Success Latency', + 'label' => 'publish-latency', + 'nlabel' => 'eventgrid.public.success.latency.milliseconds', + 'unit' => 'ms', + 'min' => '0' + } + }; + + 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' }, + 'resource-type:s' => { name => 'resource_type', default => 'topics' } + }); + + 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(); + } + + if (!defined($self->{option_results}->{resource_type}) || + $self->{option_results}->{resource_type} !~ /topics|systemTopics|partnerTopic|partnerNamespaces|extensionTopics|eventSubscriptions|domains/) { + $self->{output}->add_option_msg(short_msg => 'Please specify an existing Azure Event Grid resource type'); + $self->{output}->option_exit(); + } + + my $resource = $self->{option_results}->{resource}; + my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : ''; + my $resource_type = $self->{option_results}->{resource_type}; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.EventGrid\/(.*)\/(.*)$/) { + $resource_group = $1; + $resource_type = $2; + $resource = $3; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = $resource_type; + $self->{az_resource_namespace} = 'Microsoft.EventGrid'; + $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} = ['Total']; + 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)); + } + } + } + + my $type; + if ($resource_type =~ /topics|systemTopics|partnerNamespaces|domains/) { + $type = 'topics'; + + } elsif ($resource_type eq 'partnerTopics') { + $type = 'partnerTopics'; + + } elsif ($resource_type eq 'extensionTopics') { + $type = 'extensionTopics'; + + } else { + $type = 'eventSubscriptions'; + } + + my $resource_mapping = { + 'topics' => [ + 'deliveryattemptfailcount', 'deliverysuccesscount', 'destinationprocessingdurationinms', + 'publishfailcount', 'publishsuccesscount', 'publishsuccesslatencyinms' + ], + 'partnerTopics' => [ + 'deliveryattemptfailcount', 'deliverysuccesscount', 'destinationprocessingdurationinms', + 'publishfailcount', 'publishsuccesscount' + ], + 'extensionTopics' => [ + 'publishfailcount', 'publishsuccesscount', 'publishsuccesslatencyinms' + ], + 'eventSubscriptions' => [ + 'deliveryattemptfailcount', 'deliverysuccesscount', 'destinationprocessingdurationinms' + ] + }; + + my $metrics_mapping_transformed; + foreach my $metric_type (@{$resource_mapping->{$type}}) { + $metrics_mapping_transformed->{$metric_type} = $self->{metrics_mapping}->{$metric_type}; + } + + foreach my $metric (keys %{$metrics_mapping_transformed}) { + 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 Event Grid delivery and publish events statistics. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::eventgrid::plugin --mode=events-stats --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-publish-failed='20' --critical-publish-failed='50' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::eventgrid::plugin --mode=events-stats --custommode=api +--resource='resource='/subscriptions//resourceGroups//providers/Microsoft.EventGrid//'' +--aggregation='average' --warning-publish-failed='20' --critical-publish-failed='50' + +Default aggregation: 'average' / 'total', 'minimum' and 'maximum' 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<--resource-type> + +Set resource type (Default: 'topics'). Can be 'topics', +'systemTopics', 'partnerTopics', 'partnerNamespaces', +'extensionTopics', 'extensionTopics', 'domains'). + +=item B<--warning-*> + +Warning threshold where '*' can be: +'publish-failed', 'publish-latency', 'delivery-successful', +'publish-successful', 'delivery-failed', 'processing-duration'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'publish-failed', 'publish-latency', 'delivery-successful', +'publish-successful', 'delivery-failed', 'processing-duration'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/eventgrid/mode/health.pm b/centreon-plugins/cloud/azure/integration/eventgrid/mode/health.pm new file mode 100644 index 000000000..0a740c559 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/eventgrid/mode/health.pm @@ -0,0 +1,78 @@ +# +# 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::integration::eventgrid::mode::health; + +use base qw(cloud::azure::management::monitor::mode::health); + +use strict; +use warnings; + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{az_resource_namespace} = 'Microsoft.EventGrid'; + $self->{az_resource_type} = 'namespaces'; +} + +1; + +__END__ + +=head1 MODE + +Check Event Grid namespace status. + +(Useful to determine host status) + +=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-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{status}, %{summary} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /^Unavailable$/'). +Can used special variables like: %{status}, %{summary} + +=item B<--unknown-status> + +Set unknown threshold for status (Default: '%{status} =~ /^Unknown$/'). +Can used special variables like: %{status}, %{summary} + +=item B<--ok-status> + +Set ok threshold for status (Default: '%{status} =~ /^Available$/'). +Can used special variables like: %{status}, %{summary} + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/eventgrid/plugin.pm b/centreon-plugins/cloud/azure/integration/eventgrid/plugin.pm new file mode 100644 index 000000000..19f079ba0 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/eventgrid/plugin.pm @@ -0,0 +1,63 @@ +# +# Copyright 2020 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::integration::eventgrid::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::integration::eventgrid::mode::discovery', + 'events' => 'cloud::azure::integration::eventgrid::mode::events', + 'events-stats' => 'cloud::azure::integration::eventgrid::mode::eventstats', + 'health' => 'cloud::azure::integration::eventgrid::mode::health' + }; + + $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 Event Grid. + +=cut diff --git a/centreon-plugins/cloud/azure/integration/servicebus/mode/connections.pm b/centreon-plugins/cloud/azure/integration/servicebus/mode/connections.pm new file mode 100644 index 000000000..4496b5655 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/servicebus/mode/connections.pm @@ -0,0 +1,156 @@ +# +# 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::integration::servicebus::mode::connections; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'activeconnections' => { + 'output' => 'Active Connections', + 'label' => 'active-connections', + 'nlabel' => 'servicebus.namespace.connections.active.count', + 'unit' => '', + 'min' => '0' + }, + 'connectionsclosed' => { + 'output' => 'Connections Closed', + 'label' => 'closed-connections', + 'nlabel' => 'servicebus.namespace.connections.closed.count', + 'unit' => '', + 'min' => '0' + }, + 'connectionsopened' => { + 'output' => 'Connections Opened', + 'label' => 'opened-connections', + 'nlabel' => 'servicebus.namespace.connections.opened.count', + 'unit' => '', + 'min' => '0' + }, + }; + + 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\.ServiceBus\/namespaces\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'namespaces'; + $self->{az_resource_namespace} = 'Microsoft.ServiceBus'; + $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 Service Bus connections statistics. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=connections --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-servicebus-active-connections='1000' --critical-servicebus-active-connections='2000' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=connections --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.ServiceBus/namespaces/' +--aggregation='average' --warning-servicebus-active-connections='1000' --critical-servicebus-active-connections='2000' + +Default aggregation: 'average' / 'total', 'minimum' and 'maximum' 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: +'closed-connection', 'active-connections', 'opened-connections'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'closed-connection', 'active-connections', 'opened-connections'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/servicebus/mode/discovery.pm b/centreon-plugins/cloud/azure/integration/servicebus/mode/discovery.pm new file mode 100644 index 000000000..1c4cbcfe0 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/servicebus/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::integration::servicebus::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.ServiceBus'; + $self->{type} = 'namespaces'; +} + +1; + +__END__ + +=head1 MODE + +Azure Service Bus namespaces 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/centreon-plugins/cloud/azure/integration/servicebus/mode/health.pm b/centreon-plugins/cloud/azure/integration/servicebus/mode/health.pm new file mode 100644 index 000000000..8a2ecfef7 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/servicebus/mode/health.pm @@ -0,0 +1,78 @@ +# +# 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::integration::servicebus::mode::health; + +use base qw(cloud::azure::management::monitor::mode::health); + +use strict; +use warnings; + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{az_resource_namespace} = 'Microsoft.ServiceBus'; + $self->{az_resource_type} = 'namespaces'; +} + +1; + +__END__ + +=head1 MODE + +Check Service Bus namespace status. + +(Usefull to determine host status) + +=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-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{status}, %{summary} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /^Unavailable$/'). +Can used special variables like: %{status}, %{summary} + +=item B<--unknown-status> + +Set unknown threshold for status (Default: '%{status} =~ /^Unknown$/'). +Can used special variables like: %{status}, %{summary} + +=item B<--ok-status> + +Set ok threshold for status (Default: '%{status} =~ /^Available$/'). +Can used special variables like: %{status}, %{summary} + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/servicebus/mode/messages.pm b/centreon-plugins/cloud/azure/integration/servicebus/mode/messages.pm new file mode 100644 index 000000000..cb4e0ae91 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/servicebus/mode/messages.pm @@ -0,0 +1,178 @@ +# +# 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::integration::servicebus::mode::messages; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'activemessages' => { + 'output' => 'Count of active messages in a Queue/Topic', + 'label' => 'active-messages', + 'nlabel' => 'servicebus.namespace.messages.active.count', + 'unit' => '', + 'min' => '0' + }, + 'deadletteredmessages' => { + 'output' => 'Count of dead-lettered messages in a Queue/Topic', + 'label' => 'deadlettered-messages', + 'nlabel' => 'servicebus.namespace.messages.deadlettered.count', + 'unit' => '', + 'min' => '0' + }, + 'incomingmessages' => { + 'output' => 'Incoming Messages', + 'label' => 'incoming-messages', + 'nlabel' => 'servicebus.namespace.messages.incoming.count', + 'unit' => '', + 'min' => '0' + }, + 'messages' => { + 'output' => 'Total messages', + 'label' => 'total-messages', + 'nlabel' => 'servicebus.namespace.messages.total.count', + 'unit' => '', + 'min' => '0' + }, + 'outgoingmessages' => { + 'output' => 'Outgoing Messages', + 'label' => 'outgoing-messages', + 'nlabel' => 'servicebus.namespace.messages.outgoing.count', + 'unit' => '', + 'min' => '0' + }, + 'scheduledmessages' => { + 'output' => 'Count of scheduled messages in a Queue/Topic.', + 'label' => 'scheduled-messages', + 'nlabel' => 'servicebus.namespace.messages.scheduled.count', + 'unit' => '', + 'min' => '0' + }, + + }; + + 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\.ServiceBus\/namespaces\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'namespaces'; + $self->{az_resource_namespace} = 'Microsoft.ServiceBus'; + $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 Service Bus messages metrics. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=messages --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-servicebus-active-messages='1000' --critical-servicebus-active-messages='2000' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=messages --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.ServiceBus/namespaces/' +--aggregation='average' --warning-servicebus-active-messages='1000' --critical-servicebus-active-messages='2000' + +Default aggregation: 'average' / 'total', 'minimum' and 'maximum' 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: +'active-messages', 'deadlettered-messages', 'total-messages', 'incoming-messages', 'outgoing-messages', 'scheduled-messages'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'active-messages', 'deadlettered-messages', 'total-messages', 'incoming-messages', 'outgoing-messages', 'scheduled-messages'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/servicebus/mode/requests.pm b/centreon-plugins/cloud/azure/integration/servicebus/mode/requests.pm new file mode 100644 index 000000000..b11433135 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/servicebus/mode/requests.pm @@ -0,0 +1,156 @@ +# +# 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::integration::servicebus::mode::requests; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'incomingrequests' => { + 'output' => 'Incoming Requests', + 'label' => 'incoming-requests', + 'nlabel' => 'servicebus.namespace.requests.incoming.count', + 'unit' => '', + 'min' => '0' + }, + 'successfulrequests' => { + 'output' => 'Successful Requests', + 'label' => 'successful-requests', + 'nlabel' => 'servicebus.namespace.requests.successful.count', + 'unit' => '', + 'min' => '0' + }, + 'throttledrequests' => { + 'output' => 'Throttled Requests', + 'label' => 'throttled-requests', + 'nlabel' => 'servicebus.namespace.requests.throttled.count', + 'unit' => '', + 'min' => '0' + } + }; + + 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\.ServiceBus\/namespaces\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'namespaces'; + $self->{az_resource_namespace} = 'Microsoft.ServiceBus'; + $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} = ['Total']; + 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 Service Bus requests statistics. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=requests --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-throttled-requests='300' --critical-throttled-requests='400' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=requests --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.ServiceBus/namespaces/' +--aggregation='average' --warning-throttled-requests='300' --critical-throttled-requests='400' + +Default aggregation: 'total' / 'minimum', 'maximum' and 'average' 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: +'incoming-requests', 'throttled-requests', 'successful-requests'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'incoming-requests', 'throttled-requests', 'successful-requests'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/servicebus/mode/resources.pm b/centreon-plugins/cloud/azure/integration/servicebus/mode/resources.pm new file mode 100644 index 000000000..5e9643be4 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/servicebus/mode/resources.pm @@ -0,0 +1,151 @@ +# +# 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::integration::servicebus::mode::namespaces; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'namespacecpuusage' => { + 'output' => 'CPU', + 'label' => 'cpu-usage-percentage', + 'nlabel' => 'servicebus.namespace.cpu.usage.percentage', + 'unit' => '%', + 'min' => '0', + 'max' => '100' + }, + 'namespacememoryusage' => { + 'output' => 'Memory Usage', + 'label' => 'memory-usage-percentage', + 'nlabel' => 'servicebus.namespace.memory.usage.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\.ServiceBus\/namespaces\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'namespaces'; + $self->{az_resource_namespace} = 'Microsoft.ServiceBus'; + $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} = ['Maximum']; + 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 Service Bus namespace resources statistics. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=namespaces --custommode=api +--resource= --resource-group= --aggregation='average' +--warning-cpu-usage-percentage='80' --critical-cpu-usage-percentage='90' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::integration::servicebus::plugin --mode=namespaces --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.ServiceBus/namespaces/' +--aggregation='average' --warning-cpu-usage-percentage='80' --critical-cpu-usage-percentage='90' + +Default aggregation: 'maximum' / 'total', 'minimum' and 'average' 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: +'cpu-usage-percentage', 'memory-usage-percentage'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'cpu-usage-percentage', 'memory-usage-percentage'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/integration/servicebus/plugin.pm b/centreon-plugins/cloud/azure/integration/servicebus/plugin.pm new file mode 100644 index 000000000..c598cddd6 --- /dev/null +++ b/centreon-plugins/cloud/azure/integration/servicebus/plugin.pm @@ -0,0 +1,65 @@ +# +# 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::integration::servicebus::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} = { + 'connections' => 'cloud::azure::integration::servicebus::mode::connections', + 'discovery' => 'cloud::azure::integration::servicebus::mode::discovery', + 'health' => 'cloud::azure::integration::servicebus::mode::health', + 'messages' => 'cloud::azure::integration::servicebus::mode::messages', + 'requests' => 'cloud::azure::integration::servicebus::mode::requests', + 'namespaces' => 'cloud::azure::integration::servicebus::mode::namespaces' + }; + + $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 Service Bus namespaces. + +=cut diff --git a/centreon-plugins/cloud/azure/management/automation/mode/discovery.pm b/centreon-plugins/cloud/azure/management/automation/mode/discovery.pm new file mode 100644 index 000000000..cc79f33cb --- /dev/null +++ b/centreon-plugins/cloud/azure/management/automation/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::management::automation::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.Automation'; + $self->{type} = 'automationAccounts'; +} + +1; + +__END__ + +=head1 MODE + +Azure Automation 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/centreon-plugins/cloud/azure/management/automation/mode/health.pm b/centreon-plugins/cloud/azure/management/automation/mode/health.pm new file mode 100644 index 000000000..fc306dfc6 --- /dev/null +++ b/centreon-plugins/cloud/azure/management/automation/mode/health.pm @@ -0,0 +1,78 @@ +# +# 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::integration::eventgrid::mode::health; + +use base qw(cloud::azure::management::monitor::mode::health); + +use strict; +use warnings; + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{az_resource_namespace} = 'Microsoft.EventGrid'; + $self->{az_resource_type} = 'namespaces'; +} + +1; + +__END__ + +=head1 MODE + +Check Automation namespace status. + +(Useful to determine host status) + +=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-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{status}, %{summary} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /^Unavailable$/'). +Can used special variables like: %{status}, %{summary} + +=item B<--unknown-status> + +Set unknown threshold for status (Default: '%{status} =~ /^Unknown$/'). +Can used special variables like: %{status}, %{summary} + +=item B<--ok-status> + +Set ok threshold for status (Default: '%{status} =~ /^Available$/'). +Can used special variables like: %{status}, %{summary} + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/management/automation/mode/jobs.pm b/centreon-plugins/cloud/azure/management/automation/mode/jobs.pm new file mode 100644 index 000000000..173210613 --- /dev/null +++ b/centreon-plugins/cloud/azure/management/automation/mode/jobs.pm @@ -0,0 +1,156 @@ +# +# 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::management::automation::mode::jobs; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'totaljob' => { + 'output' => 'Total Jobs', + 'label' => 'jobs-total', + 'nlabel' => 'automation.jobs.total.count', + 'unit' => '', + 'min' => '0' + }, + 'totalupdatedeploymentmachineruns' => { + 'output' => 'Total Update Deployment Machine Runs', + 'label' => 'update-deployment-machine-runs', + 'nlabel' => 'automation.machineruns.total.count', + 'unit' => '', + 'min' => '0' + }, + 'totalupdatedeploymentruns' => { + 'output' => 'Total Update Deployment Runs', + 'label' => 'update-deployment-runs', + 'nlabel' => 'automation.runs.total.count', + 'unit' => '', + 'min' => '0' + } + }; + + 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\.Automation\/automationAccounts\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'automationAccounts'; + $self->{az_resource_namespace} = 'Microsoft.Automation'; + $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} = ['Total']; + 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 Automation jobs. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::management::automation::plugin --mode=jobs --custommode=api +--resource= --resource-group= --aggregation='total' +--warning-jobs-total='20' --critical-jobs-total='50' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::management::automation::plugin --mode=jobs --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts/' +--aggregation='total' --warning-jobs-total='20' --critical-jobs-total='50' + +Default aggregation: 'average' / 'total', 'minimum' and 'maximum' 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: +'jobs-total', 'update-deployment-machine-runs', 'update-deployment-runs'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'jobs-total', 'update-deployment-machine-runs', 'update-deployment-runs'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/management/automation/plugin.pm b/centreon-plugins/cloud/azure/management/automation/plugin.pm new file mode 100644 index 000000000..5fa28edea --- /dev/null +++ b/centreon-plugins/cloud/azure/management/automation/plugin.pm @@ -0,0 +1,62 @@ +# +# Copyright 2020 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::management::automation::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} = { + 'jobs' => 'cloud::azure::management::automation::mode::jobs', + 'health' => 'cloud::azure::management::automation::mode::health', + 'discovery' => 'cloud::azure::management::automation::mode::discovery' + }; + + $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 Automation. + +=cut diff --git a/centreon-plugins/cloud/azure/security/keyvault/mode/discovery.pm b/centreon-plugins/cloud/azure/security/keyvault/mode/discovery.pm index a11c169af..73d8dfe24 100644 --- a/centreon-plugins/cloud/azure/security/keyvault/mode/discovery.pm +++ b/centreon-plugins/cloud/azure/security/keyvault/mode/discovery.pm @@ -1,5 +1,5 @@ # -# Copyright 2020 Centreon (http://www.centreon.com/) +# 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 diff --git a/centreon-plugins/cloud/azure/security/keyvault/mode/serviceapi.pm b/centreon-plugins/cloud/azure/security/keyvault/mode/serviceapi.pm index 9cdbc2f8b..27ca9e362 100644 --- a/centreon-plugins/cloud/azure/security/keyvault/mode/serviceapi.pm +++ b/centreon-plugins/cloud/azure/security/keyvault/mode/serviceapi.pm @@ -1,5 +1,5 @@ # -# Copyright 2020 Centreon (http://www.centreon.com/) +# 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 diff --git a/centreon-plugins/cloud/azure/security/keyvault/mode/vaultavailability.pm b/centreon-plugins/cloud/azure/security/keyvault/mode/vaultavailability.pm index a63f19070..1e47ed720 100644 --- a/centreon-plugins/cloud/azure/security/keyvault/mode/vaultavailability.pm +++ b/centreon-plugins/cloud/azure/security/keyvault/mode/vaultavailability.pm @@ -1,5 +1,5 @@ # -# Copyright 2020 Centreon (http://www.centreon.com/) +# 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 diff --git a/centreon-plugins/cloud/azure/security/keyvault/mode/vaultcapacity.pm b/centreon-plugins/cloud/azure/security/keyvault/mode/vaultcapacity.pm index abb5e1320..52f903860 100644 --- a/centreon-plugins/cloud/azure/security/keyvault/mode/vaultcapacity.pm +++ b/centreon-plugins/cloud/azure/security/keyvault/mode/vaultcapacity.pm @@ -1,5 +1,5 @@ # -# Copyright 2020 Centreon (http://www.centreon.com/) +# 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 diff --git a/centreon-plugins/cloud/azure/security/keyvault/plugin.pm b/centreon-plugins/cloud/azure/security/keyvault/plugin.pm index d638ad7e1..c7b99b646 100644 --- a/centreon-plugins/cloud/azure/security/keyvault/plugin.pm +++ b/centreon-plugins/cloud/azure/security/keyvault/plugin.pm @@ -1,5 +1,5 @@ # -# Copyright 2020 Centreon (http://www.centreon.com/) +# 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 diff --git a/centreon-plugins/cloud/azure/web/signalr/mode/discovery.pm b/centreon-plugins/cloud/azure/web/signalr/mode/discovery.pm new file mode 100644 index 000000000..b8dcb0a1e --- /dev/null +++ b/centreon-plugins/cloud/azure/web/signalr/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::web::signalr::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.SignalRService'; + $self->{type} = 'SignalR'; +} + +1; + +__END__ + +=head1 MODE + +Azure Web SignalR 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/centreon-plugins/cloud/azure/web/signalr/mode/errors.pm b/centreon-plugins/cloud/azure/web/signalr/mode/errors.pm new file mode 100644 index 000000000..1ee066678 --- /dev/null +++ b/centreon-plugins/cloud/azure/web/signalr/mode/errors.pm @@ -0,0 +1,151 @@ +# +# 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::web::signalr::mode::errors; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'systemerrors' => { + 'output' => 'System Errors', + 'label' => 'system-errors', + 'nlabel' => 'signalr.errors.system.percentage', + 'unit' => '%', + 'min' => '0', + 'max' => '100' + }, + 'usererrors' => { + 'output' => 'User Errors', + 'label' => 'user-errors', + 'nlabel' => 'signalr.errors.user.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\.SignalRService\/SignalR\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'SignalR'; + $self->{az_resource_namespace} = 'Microsoft.SignalRService'; + $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} = ['Maximum']; + 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 Web SignalR errors. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::web::signalr::plugin --mode=errors --custommode=api +--resource= --resource-group= --aggregation='maximum' +--warning-connection-count='800' --warning-connection-count='900' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::web::signalr::plugin --mode=errors --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.SignalRService/SignalR/' +--aggregation='maximum' --warning-connection-count='800' --warning-connection-count='900' + +Default aggregation: 'maximum' / 'minimum', 'total' and 'average' 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: +'system-errors', 'user-errors'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'system-errors', 'user-errors'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/web/signalr/mode/health.pm b/centreon-plugins/cloud/azure/web/signalr/mode/health.pm new file mode 100644 index 000000000..f823234b9 --- /dev/null +++ b/centreon-plugins/cloud/azure/web/signalr/mode/health.pm @@ -0,0 +1,76 @@ +# +# 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::web::signalr::mode::errors; + +use base qw(cloud::azure::management::monitor::mode::health); + +use strict; +use warnings; + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{az_resource_namespace} = 'Microsoft.SignalRService'; + $self->{az_resource_type} = 'SignalR'; +} + +1; + +__END__ + +=head1 MODE + +Check SignalR health status. + +=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-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{status}, %{summary} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} =~ /^Unavailable$/'). +Can used special variables like: %{status}, %{summary} + +=item B<--unknown-status> + +Set unknown threshold for status (Default: '%{status} =~ /^Unknown$/'). +Can used special variables like: %{status}, %{summary} + +=item B<--ok-status> + +Set ok threshold for status (Default: '%{status} =~ /^Available$/'). +Can used special variables like: %{status}, %{summary} + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/web/signalr/mode/traffic.pm b/centreon-plugins/cloud/azure/web/signalr/mode/traffic.pm new file mode 100644 index 000000000..830797e76 --- /dev/null +++ b/centreon-plugins/cloud/azure/web/signalr/mode/traffic.pm @@ -0,0 +1,149 @@ +# +# 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::web::signalr::mode::traffic; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'inboundtraffic' => { + 'output' => 'Inbound Traffic', + 'label' => 'inbound-traffic', + 'nlabel' => 'signalr.traffic.inbound.bytes', + 'unit' => 'B', + 'min' => '0', + }, + 'outboundtraffic' => { + 'output' => 'Outbound Traffic', + 'label' => 'outbound-traffic', + 'nlabel' => 'signalr.traffic.outbound.bytes', + 'unit' => 'B', + 'min' => '0', + } + }; + + 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\.SignalRService\/SignalR\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'SignalR'; + $self->{az_resource_namespace} = 'Microsoft.SignalRService'; + $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} = ['Total']; + 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 Web SignalR traffic. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::web::signalr::plugin --mode=traffic --custommode=api +--resource= --resource-group= --aggregation='total' +--warning-inbound-traffic='80000' --warning-connection-count='90000' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::web::signalr::plugin --mode=traffic --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.SignalRService/SignalR/' +--aggregation='total' --warning-inbound-traffic='80000' --warning-connection-count='90000' + +Default aggregation: 'total' / 'minimum', 'maximum' and 'average' 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: +'inbound-traffic', 'outbound-traffic'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'inbound-traffic', 'outbound-traffic'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/web/signalr/mode/usage.pm b/centreon-plugins/cloud/azure/web/signalr/mode/usage.pm new file mode 100644 index 000000000..e4f8fc0f3 --- /dev/null +++ b/centreon-plugins/cloud/azure/web/signalr/mode/usage.pm @@ -0,0 +1,149 @@ +# +# 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::web::signalr::mode::usage; + +use base qw(cloud::azure::custom::mode); + +use strict; +use warnings; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'connectioncount' => { + 'output' => 'Connection Count', + 'label' => 'connection-count', + 'nlabel' => 'signalr.connections.count', + 'unit' => '', + 'min' => '0', + }, + 'messagecount' => { + 'output' => 'Message Count', + 'label' => 'message-count', + 'nlabel' => 'signalr.messages.count', + 'unit' => '', + 'min' => '0' + } + }; + + 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\.SignalRService\/SignalR\/(.*)$/) { + $resource_group = $1; + $resource = $2; + } + + $self->{az_resource} = $resource; + $self->{az_resource_group} = $resource_group; + $self->{az_resource_type} = 'SignalR'; + $self->{az_resource_namespace} = 'Microsoft.SignalRService'; + $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} = ['Total']; + 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 Web SignalR usage. + +Example: + +Using resource name : + +perl centreon_plugins.pl --plugin=cloud::azure::web::signalr::plugin --mode=usage --custommode=api +--resource= --resource-group= --aggregation='total' +--warning-connection-count='800' --warning-connection-count='900' + +Using resource id : + +perl centreon_plugins.pl --plugin=cloud::azure::web::signalr::plugin --mode=usage --custommode=api +--resource='/subscriptions//resourceGroups//providers/Microsoft.SignalRService/SignalR/' +--aggregation='total' --warning-connection-count='800' --warning-connection-count='900' + +Default aggregation: 'total' / 'minimum', 'maximum' and 'average' 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: +'message-count', connection-count'. + +=item B<--critical-*> + +Critical threshold where '*' can be: +'message-count', connection-count'. + +=back + +=cut diff --git a/centreon-plugins/cloud/azure/web/signalr/plugin.pm b/centreon-plugins/cloud/azure/web/signalr/plugin.pm new file mode 100644 index 000000000..22663fb6c --- /dev/null +++ b/centreon-plugins/cloud/azure/web/signalr/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::web::signalr::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::web::signalr::mode::discovery', + 'errors' => 'cloud::azure::web::signalr::mode::errors', + 'health' => 'cloud::azure::web::signalr::mode::health', + 'usage' => 'cloud::azure::web::signalr::mode::usage', + 'traffic' => 'cloud::azure::web::signalr::mode::traffic' + }; + + $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 SignalR resources. + +=cut