diff --git a/src/cloud/azure/custom/api.pm b/src/cloud/azure/custom/api.pm index ac3fa02ffc..cfd3efde5b 100644 --- a/src/cloud/azure/custom/api.pm +++ b/src/cloud/azure/custom/api.pm @@ -1149,6 +1149,51 @@ sub azure_list_sqlvms { return $full_response; } +sub azure_list_resource_metrics_set_url { + my ($self, %options) = @_; + + my $url = $self->{management_endpoint}; + $url .= "/" . $options{resource} . "/providers/microsoft.insights/metricDefinitions"; + $url .= (defined($options{force_api_version}) && $options{force_api_version} ne '') ? "?api-version=" . $options{force_api_version} : "?api-version=" . $self->{api_version}; + return $url; +} + +sub azure_list_resource_metrics { + my ($self, %options) = @_; + + my $full_response = []; + my $full_url = $self->azure_list_resource_metrics_set_url(%options); + while (1) { + my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => ''); + foreach (@{$response->{value}}) { + push @$full_response, $_; + } + + last if (!defined($response->{nextLink})); + $full_url = $response->{nextLink}; + } + + return $full_response; +} + +sub azure_list_virtualhubs_set_url { + my ($self, %options) = @_; + + my $url = $self->{management_endpoint} . "/subscriptions/" . $self->{subscription} . "/resourcegroups/" . + $options{resource_group} . "/providers/Microsoft.Network/virtualHubs?api-version=" . $self->{api_version}; + + return $url; +} + +sub azure_list_virtualhubs { + my ($self, %options) = @_; + + my $full_url = $self->azure_list_virtualhubs_set_url(%options); + my $response = $self->request_api(method => 'GET', full_url => $full_url, hostname => ''); + + return $response->{value}; +} + sub azure_list_sqlelasticpools_set_url { my ($self, %options) = @_; diff --git a/src/cloud/azure/custom/azcli.pm b/src/cloud/azure/custom/azcli.pm index a0eb74acf1..927114f82d 100644 --- a/src/cloud/azure/custom/azcli.pm +++ b/src/cloud/azure/custom/azcli.pm @@ -600,6 +600,45 @@ sub azure_get_publicip { return $self->execute(cmd_options => $cmd_options); } +sub azure_list_resource_metrics_set_cmd { + my ($self, %options) = @_; + + return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); + + my $cmd_options = "monitor metrics list-definitions --resource '$options{resource}' --only-show-errors --output json"; + + return $cmd_options; +} + +sub azure_list_resource_metrics { + my ($self, %options) = @_; + + my $cmd_options = $self->azure_list_resource_metrics_set_cmd(%options); + my $raw_results = $self->execute(cmd_options => $cmd_options); + + return $raw_results; +} + +sub azure_list_virtualhubs_set_cmd { + my ($self, %options) = @_; + + return if (defined($self->{option_results}->{command_options}) && $self->{option_results}->{command_options} ne ''); + + my $cmd_options = "network vhub list --resource-group '$options{resource_group}' --only-show-errors --output json "; + $cmd_options .= " --subscription '$self->{subscription}'" if (defined($self->{subscription}) && $self->{subscription} ne ''); + + return $cmd_options; +} + +sub azure_list_virtualhubs { + my ($self, %options) = @_; + + my $cmd_options = $self->azure_list_virtualhubs_set_cmd(%options); + my $raw_results = $self->execute(cmd_options => $cmd_options); + + return $raw_results; +} + 1; __END__ diff --git a/src/cloud/azure/network/virtualhub/mode/discovery.pm b/src/cloud/azure/network/virtualhub/mode/discovery.pm new file mode 100644 index 0000000000..66f3ff6c91 --- /dev/null +++ b/src/cloud/azure/network/virtualhub/mode/discovery.pm @@ -0,0 +1,60 @@ +# +# Copyright 2024 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package cloud::azure::network::virtualhub::mode::discovery; + +use base qw(cloud::azure::common::discovery); + +use strict; +use warnings; + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->{namespace} = 'Microsoft.Network'; + $self->{type} = 'virtualHubs'; +} + +1; + +__END__ + +=head1 MODE + +Virtual Hub 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/src/cloud/azure/network/virtualhub/mode/health.pm b/src/cloud/azure/network/virtualhub/mode/health.pm new file mode 100644 index 0000000000..53d6064dba --- /dev/null +++ b/src/cloud/azure/network/virtualhub/mode/health.pm @@ -0,0 +1,76 @@ +# +# Copyright 2024 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package cloud::azure::network::virtualhub::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.Network'; + $self->{az_resource_type} = 'virtualHubs'; +} + +1; + +__END__ + +=head1 MODE + +Check Virtual Hub 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> + +Define the conditions to match for the status to be WARNING (default: ''). +You can use the following variables: C<%{status}>, C<%{summary}>. + +=item B<--critical-status> + +Define the conditions to match for the status to be CRITICAL (default: C<'%{status} =~ /^Unavailable$/'>). +You can use the following variables: C<%{status}>, C<%{summary}>. + +=item B<--unknown-status> + +Define the conditions to match for the status to be UNKNOWN (default: C<'%{status} =~ /^Unknown$/'>). +You can use the following variables: C<%{status}>, C<%{summary}>. + +=item B<--ok-status> + +Define the conditions to match for the status to be OK (default: C<'%{status} =~ /^Available$/''>). +You can use the following variables: C<%{status}>, C<%{summary}>. + +=back + +=cut diff --git a/src/cloud/azure/network/virtualhub/mode/hubstatus.pm b/src/cloud/azure/network/virtualhub/mode/hubstatus.pm new file mode 100644 index 0000000000..915784ae4b --- /dev/null +++ b/src/cloud/azure/network/virtualhub/mode/hubstatus.pm @@ -0,0 +1,185 @@ +# +# Copyright 2024 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package cloud::azure::network::virtualhub::mode::hubstatus; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); +use centreon::plugins::constants qw(:counters :values); +use centreon::plugins::misc qw/is_excluded/; + +sub custom_status_output { + my ($self, %options) = @_; + + my $msg = sprintf("Provisioning State '%s' [Routing state: %s]", + $self->{result_values}->{provisioning_state}, + $self->{result_values}->{routing_state}); + return $msg; +} + +sub prefix_hub_output { + my ($self, %options) = @_; + + my $output = sprintf("Virtual Hub '%s' (%s) ", + $options{instance_value}->{name}, + $options{instance_value}->{address_prefix}); + + if (defined($options{instance_value}->{virtual_wan})) { + $output .= "Virtual WAN '" . $options{instance_value}->{virtual_wan} . "' "; + } + + return $output; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { + name => 'hubs', + type => COUNTER_TYPE_INSTANCE, + cb_prefix_output => 'prefix_hub_output', + message_multiple => 'All Virtual Hubs are ok' + }, + ]; + + $self->{maps_counters}->{hubs} = [ + { + label => 'status', + type => COUNTER_KIND_TEXT, + critical_default => '%{provisioning_state} ne "Succeeded" || %{routing_state} ne "Provisioned"', + set => { + key_values => + [ + { name => 'provisioning_state' }, + { name => 'routing_state' }, + { name => 'address_prefix' }, + { name => 'name' }, + { name => 'virtual_wan' } + ], + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub {return 0;}, + closure_custom_threshold_check => \&catalog_status_threshold_ng, + } + }, + ]; +} + +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 => { + 'api-version:s' => { name => 'api_version', default => '2025-05-01' }, + "resource-group:s" => { name => 'resource_group' }, + "include-name:s" => { name => 'include_name' }, + "exclude-name:s" => { name => 'exclude_name' } + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + if (!defined($self->{option_results}->{resource_group}) || $self->{option_results}->{resource_group} eq '') { + $self->{output}->option_exit(short_msg => "Need to specify --resource-group option"); + } + +} + +sub manage_selection { + my ($self, %options) = @_; + + $self->{hubs} = {}; + my $hubs = $options{custom}->azure_list_virtualhubs(resource_group => $self->{option_results}->{resource_group}); + foreach my $hub (@{$hubs}) { + next if is_excluded($hub->{name}, + $self->{option_results}->{include_name}, + $self->{option_results}->{exclude_name}); + + $self->{hubs}->{$hub->{id}} = { + name => $hub->{name}, + provisioning_state => ($hub->{provisioningState}) ? + $hub->{provisioningState} : $hub->{properties}->{provisioningState}, + routing_state => ($hub->{routingState}) ? $hub->{routingState} : $hub->{properties}->{routingState}, + address_prefix => ($hub->{addressPrefix}) ? $hub->{addressPrefix} : $hub->{properties}->{addressPrefix}, + }; + + my $virtual_wan = ($hub->{virtualWan}) ? $hub->{virtualWan} : $hub->{properties}->{virtualWan}; + if (exists($virtual_wan->{id})) { + my ($name) = $virtual_wan->{id} =~ m{/virtualWans/([^/]+)}; + $self->{hubs}->{$hub->{id}}->{virtual_wan} = $name; + } + } + + if (scalar(keys %{$self->{hubs}}) <= 0) { + $self->{output}->option_exit(short_msg => "No Virtual Hub found."); + } +} + +1; + +__END__ + +=head1 MODE + +Check Virtual Hub status. + +Example: +C + +=over 8 + +=item B<--resource-group> + +Set resource group (required). + +=item B<--include-name> + +Filter Virtual Hub by name (can be a regexp). + +=item B<--exclude-name> + +Exclude Virtual Hub by name (can be a regexp). + +=item B<--unknown-status> + +Define the conditions to match for the status to be UNKNOWN (default: ''). +You can use the following variables: %{provisioning_state}, %{routing_state}>, %{display} + +=item B<--warning-status> + +Define the conditions to match for the status to be WARNING (default: ''). +You can use the following variables: %{provisioning_state}, %{routing_state}>, %{display} + +=item B<--critical-status> + +Define the conditions to match for the status to be CRITICAL (default: C<'%{provisioning_state} ne "Succeeded" || %{routing_state} ne "Provisioned"'>). +You can use the following variables: %{provisioning_state}, %{routing_state}, %{display} + +=back + +=cut diff --git a/src/cloud/azure/network/virtualhub/mode/hubtraffic.pm b/src/cloud/azure/network/virtualhub/mode/hubtraffic.pm new file mode 100644 index 0000000000..c0aaa8a283 --- /dev/null +++ b/src/cloud/azure/network/virtualhub/mode/hubtraffic.pm @@ -0,0 +1,324 @@ +# +# Copyright 2024 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package cloud::azure::network::virtualhub::mode::hubtraffic; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); +use centreon::plugins::constants qw(:counters :values); +use centreon::plugins::misc qw/is_excluded/; + +sub get_metrics_mapping { + my ($self, %options) = @_; + + my $metrics_mapping = { + 'RoutingInfrastructureUnits' => { + 'output' => 'Units consumed', + 'label' => 'units-consumed', + 'nlabel' => 'azvirtualhub.infrastructure.units.consumed.count', + 'unit' => '', + 'min' => '0', + 'max' => '', + 'template' => '%d', + 'output_template' => '%d', + 'display_ok' => 0, + }, + 'SpokeVMUtilization' => { + 'output' => 'Spoke VM Utilization', + 'label' => 'spoke-vm-utilization', + 'nlabel' => 'azvirtualhub.spoke.vm.utilization.percentage', + 'unit' => '%', + 'min' => '0', + 'max' => '100', + 'template' => '%.2f', + 'output_template' => '%.2f %%', + 'display_ok' => 0 + }, + 'VirtualHubDataProcessed' => { + 'output' => 'Data processed', + 'label' => 'data-processed', + 'nlabel' => 'azvirtualhub.data.processed.bytes', + 'unit' => 'B', + 'min' => '0', + 'max' => '', + 'template' => '%d', + 'output_template' => '%d %s', + 'output_change_bytes' => 1, + 'display_ok' => 1 + }, + 'CountOfRoutesLearnedFromPeer' => { + 'output' => 'Count Of Routes Learned From Peer', + 'label' => 'route-learned-from-peer', + 'nlabel' => 'azvirtualhub.route.learned.from.peer.count', + 'unit' => '', + 'min' => '0', + 'max' => '', + 'template' => '%d', + 'output_template' => '%d', + 'display_ok' => 0, + }, + 'CountOfRoutesAdvertisedToPeer' => { + 'output' => 'Count Of Routes Advertised To Peer', + 'label' => 'route-advertised-to-peer', + 'nlabel' => 'azvirtualhub.route.advertised.to.peer.count', + 'unit' => '', + 'min' => '0', + 'max' => '', + 'template' => '%d', + 'output_template' => '%d', + 'display_ok' => 0, + }, + }; + + return $metrics_mapping; +} + +sub prefix_metric_output { + my ($self, %options) = @_; + + return "Virtual Hub '" . $options{instance_value}->{display} . "' [" . $options{instance_value}->{stat} . "] "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { + name => 'metric', + type => COUNTER_TYPE_INSTANCE, + cb_prefix_output => 'prefix_metric_output', + message_multiple => "All virtual hub metrics are ok", + skipped_code => { NO_VALUE() => 1 } } + ]; + + $self->{metrics_mapping} = $self->get_metrics_mapping; + + foreach my $aggregation ('minimum', 'maximum', 'average', 'total') { + foreach my $metric_name (keys %{$self->{metrics_mapping}}) { + my $metric_label = $self->{metrics_mapping}{$metric_name}->{label}; + my $metric = $self->{metrics_mapping}{$metric_name}; + my $entry = { + label => $metric_label . '-' . $aggregation, + nlabel => $metric->{nlabel}, + display_ok =>, $metric->{display_ok}, + set => { + key_values => + [ + { name => $metric_label . '_' . $aggregation }, + { name => 'display' }, + { name => 'stat' } + ], + output_template => $metric_label . '_' . $aggregation . ': ' . $metric->{output_template}, + perfdatas => + [ + { + value => $metric_label . '_' . $aggregation, + template => $metric->{template}, + label_extra_instance => 1, + unit => $metric->{unit}, + min => $metric->{min}, + max => $metric->{max} + }, + ], + } + }; + push @{$self->{maps_counters}->{metric}}, $entry; + } + } +} + +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 => { + "resource:s@" => { name => 'resource' }, + "resource-group:s" => { name => 'resource_group' }, + "filter-metric:s" => { name => 'filter_metric' } + }); + + 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}->option_exit(short_msg => + 'Need to specify either --resource with --resource-group option or --resource .'); + } else { + foreach my $tmp_resource (@{$self->{az_resource}}) { + if ($tmp_resource !~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Network\/virtualHubs\/(.*)$/) { + if (!defined($self->{option_results}->{resource_group}) || $self->{option_results}->{resource_group} eq '') { + $self->{output}->option_exit(short_msg => + 'Need to specify --resource-group together with --resource .'); + } + } + } + } + + $self->{az_subscription_id} = $self->{option_results}->{subscription}; + $self->{az_resource} = $self->{option_results}->{resource}; + $self->{az_resource_group} = $self->{option_results}->{resource_group} if (defined($self->{option_results}->{resource_group}));; + $self->{az_resource_type} = 'virtualHubs'; + $self->{az_resource_namespace} = 'Microsoft.Network'; + $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', 'maximum', 'minimum', 'total' ]; +} + +sub manage_selection { + my ($self, %options) = @_; + + my %metric_results; + foreach my $resource (@{$self->{az_resource}}) { + my $resource_group = $self->{az_resource_group}; + my $resource_name = $resource; + if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Network\/virtualHubs\/(.*)$/) { + $resource_group = $1; + $resource_name = $2; + } else { + $resource = '/subscriptions/' . $self->{az_subscription_id} . '/resourceGroups/' + . $resource_group . '/providers/Microsoft.Network/virtualHubs/' . $resource_name; + } + + my $metrics = $options{custom}->azure_list_resource_metrics(resource => $resource); + my %metric_values = map { + $_->{name}->{value} => $_; + } @$metrics; + + foreach my $metric (keys %{$self->{metrics_mapping}}) { + my $metric_label_name = $self->{metrics_mapping}{$metric}->{label}; + next if is_excluded($metric_label_name, $self->{option_results}->{filter_metric}); + + next unless exists $metric_values{$metric}; + + push @{$self->{az_metrics}}, $metric; + } + + ($metric_results{$resource_name}, undef, undef) = $options{custom}->azure_get_metrics( + resource => $resource_name, + resource_group => $resource_group, + resource_type => $self->{az_resource_type}, + resource_namespace => $self->{az_resource_namespace}, + metrics => $self->{az_metrics}, + aggregations => $self->{az_aggregations}, + timeframe => $self->{az_timeframe}, + interval => $self->{az_interval}, + ); + + foreach my $metric (@{$self->{az_metrics}}) { + my $metric_name = lc($metric); + $metric_name =~ s/ /_/g; + my $metric_label_name = $self->{metrics_mapping}{$metric}->{label}; + my $aggregations = []; + + if (defined($self->{option_results}->{aggregation})) { + foreach my $stat (@{$self->{option_results}->{aggregation}}) { + if ($stat ne '') { + push @{$aggregations}, ucfirst(lc($stat)); + } + } + } else { + push @{$aggregations}, lc($metric_values{$metric}->{primaryAggregationType}); + } + + foreach my $aggregation (@{$aggregations}) { + my $metric_def = $metric_values{$metric}; + my %agg_lookup = map {lc($_) => 1} @{$metric_def->{supportedAggregationTypes}}; + + next if !exists $agg_lookup{lc($aggregation)}; + next if (!defined($metric_results{$resource_name}->{$metric_name}->{lc($aggregation)}) && !defined($self->{option_results}->{zeroed})); + + $self->{metric}->{$resource_name . "_" . lc($aggregation)}->{display} = $resource_name; + $self->{metric}->{$resource_name . "_" . lc($aggregation)}->{timeframe} = $self->{az_timeframe}; + $self->{metric}->{$resource_name . "_" . lc($aggregation)}->{stat} = lc($aggregation); + $self->{metric}->{$resource_name . "_" . lc($aggregation)}->{$metric_label_name . "_" . lc($aggregation)} = + defined($metric_results{$resource_name}->{$metric_name}->{lc($aggregation)}) ? + $metric_results{$resource_name}->{$metric_name}->{lc($aggregation)} : + 0; + } + } + } + + if (scalar(keys %{$self->{metric}}) <= 0) { + $self->{output}->option_exit(short_msg => + 'No metrics. Check your options or use --zeroed option to set 0 on undefined values'); + } +} + +1; + +__END__ + +=head1 MODE + +Check Virtual Hub traffic metrics. + +Example: + +Using resource name: + +perl centreon_plugins.pl --plugin=cloud::azure::network::virtualhub::plugin --custommode=azcli --mode=hub-traffic +--resource=MyResource --resource-group=MYRGROUP --warning-units-consumed-maximum='10' +--verbose + +Using resource ID: + +perl centreon_plugins.pl --plugin=cloud::azure::network::virtualhub::plugin --custommode=azcli --mode=hub-traffic +--resource='/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Network/virtualHubs/xxx' +--warning-units-consumed-maximum='10' --verbose + +=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<--filter-metric> + +Filter metrics (can be: C, C, C, C, C) +(can be a regexp). + +=item B<--warning-$metric$-$aggregation$> + +Warning thresholds ($metric$ can be: C, C, C, C, C). + +=item B<--critical-$metric$-$aggregation$> + +Critical thresholds ($metric$ can be: C, C, C, C, C). + +=back + +=cut diff --git a/src/cloud/azure/network/virtualhub/plugin.pm b/src/cloud/azure/network/virtualhub/plugin.pm new file mode 100644 index 0000000000..6bdcd57ba5 --- /dev/null +++ b/src/cloud/azure/network/virtualhub/plugin.pm @@ -0,0 +1,63 @@ +# +# Copyright 2024 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package cloud::azure::network::virtualhub::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::virtualhub::mode::discovery', + 'health' => 'cloud::azure::network::virtualhub::mode::health', + 'hub-traffic' => 'cloud::azure::network::virtualhub::mode::hubtraffic', + 'hub-status' => 'cloud::azure::network::virtualhub::mode::hubstatus', + ); + + $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 => '2024-02-01' }, + }); + + $self->SUPER::init(%options); +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check Microsoft Azure Virtual Hubs. + +=cut