Debian Codegraph @

src/cloud/azure/compute/vmscalesets/mode/diskio.pm

raw
1 #
2 # Copyright 2024 Centreon (http://www.centreon.com/)
3 #
4 # Centreon is a full-fledged industry-strength solution that meets
5 # the needs in IT infrastructure and application monitoring for
6 # service performance.
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 #
20
21 package cloud::azure::compute::vmscalesets::mode::diskio;
22 use base qw(cloud::azure::custom::mode);
23
24
25 use strict;
26 use warnings;
27
28 sub get_metrics_mapping {
29 my ($self, %options) = @_;
30
31 my $metrics_mapping = {
32 'Disk Read Operations/sec' => {
33 'output' => 'Disk Read Operations/sec',
34 'label' => 'disk-read-ops-persec',
35 'nlabel' => 'disk.write.ops.persec',
36 'unit' => '',
37 'min' => '0',
38 'max' => ''
39 },
40 'Disk Write Operations/sec' => {
41 'output' => 'Disk Write Operations/sec',
42 'label' => 'disk-write-ops-persec',
43 'nlabel' => 'disk.write.ops.persec',
44 'unit' => '',
45 'min' => '0',
46 'max' => ''
47 }
48 };
49
50 return $metrics_mapping;
51 }
52
53 sub new {
54 my ($class, %options) = @_;
55 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
56 bless $self, $class;
57
58 $options{options}->add_options(arguments => {
59 'filter-metric:s' => { name => 'filter_metric' },
60 'resource:s' => { name => 'resource' },
61 'resource-group:s' => { name => 'resource_group' }
62 });
63
64 return $self;
65 }
66
67 sub check_options {
68 my ($self, %options) = @_;
69 $self->SUPER::check_options(%options);
70
71 if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
72 $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
73 $self->{output}->option_exit();
74 }
75
76 my $resource = $self->{option_results}->{resource};
77 my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
78 my $resource_type = $self->{option_results}->{resource_type};
79 if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.Compute\/virtualMachineScaleSets\/(.*)$/) {
80 $resource_group = $1;
81 $resource = $2;
82 }
83
84 $self->{az_resource} = $resource;
85 $self->{az_resource_group} = $resource_group;
86 $self->{az_resource_type} = 'virtualMachineScaleSets';
87 $self->{az_resource_namespace} = 'Microsoft.Compute';
88 $self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
89 $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
90 $self->{az_aggregations} = ['Average'];
91
92 foreach my $metric (keys %{$self->{metrics_mapping}}) {
93 next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
94 && $metric !~ /$self->{option_results}->{filter_metric}/);
95 push @{$self->{az_metrics}}, $metric;
96 }
97 }
98
99 1;
100
101 __END__
102
103 =head1 MODE
104
105 Check Azure Virtual Machine Scale Sets I/O operations per second.
106
107 Example:
108
109 Using resource name:
110
111 perl centreon_plugins.pl --plugin=cloud::azure::compute::vmscalesets::plugin --mode=diskio --custommode=api
112 --resource=<vmss_id> --resource-group=<resourcegroup_id> --warning-disk-read-ops-persec=10 --critical-disk-read-ops-persec=10
113
114 Using resource ID:
115
116 perl centreon_plugins.pl --plugin=cloud::azure::compute::vmscalesets::plugin --mode=diskio --custommode=api
117 --resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Compute/virtualMachineScaleSets/<vmss_id>'
118 --warning-disk-read-ops-persec=10 --critical-disk-read-ops-persec=10
119
120 =over 8
121
122 =item B<--resource>
123
124 Set resource name or ID (required).
125
126 =item B<--resource-group>
127
128 Set resource group (required if resource's name is used).
129
130 =item B<--warning-*>
131
132 Warning threshold where '*' can be:
133 'disk-read-ops-persec', 'disk-write-ops-persec'
134
135 =item B<--critical-*>
136
137 Critical threshold where '*' can be:
138 'disk-read-ops-persec', 'disk-write-ops-persec'
139
140 =back
141
142 =cut