Debian Codegraph @

src/cloud/azure/storage/storagesync/mode/recalls.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::storage::storagesync::mode::recalls;
22
23 use base qw(cloud::azure::custom::mode);
24
25 use strict;
26 use warnings;
27
28 sub get_metrics_mapping {
29 my ($self, %options) = @_;
30
31 my $metrics_mapping = {
32 'storagesyncrecallcomputedsuccessrate' => {
33 'output' => 'Cloud tiering recall success rate',
34 'label' => 'successful-recalls',
35 'nlabel' => 'storagesync.recalls.succesful.percentage',
36 'unit' => '%',
37 'min' => '0',
38 'max' => '100'
39 },
40 'storagesyncrecallednetworkbytesbyapplication' => {
41 'output' => 'Cloud tiering recall size by application',
42 'label' => 'application-recalls-size',
43 'nlabel' => 'storagesync.recalls.application.size.bytes',
44 'unit' => 'B',
45 'min' => '0',
46 'max' => ''
47 },
48 'storagesyncrecalledtotalnetworkbytes' => {
49 'output' => 'Cloud tiering recall size',
50 'label' => 'recalls-size',
51 'nlabel' => 'storagesync.recalls.size.bytes',
52 'unit' => 'B',
53 'min' => '0',
54 'max' => ''
55 },
56 'storagesyncrecalliototalsizebytes' => {
57 'output' => 'Cloud tiering recall',
58 'label' => 'total-recalls-size',
59 'nlabel' => 'storagesync.recalls.total.size.bytes',
60 'unit' => 'B',
61 'min' => '0',
62 'max' => ''
63 },
64 'storagesyncrecallthroughputbytespersecond' => {
65 'output' => 'Cloud tiering recall throughput',
66 'label' => 'throughput-recalls-size',
67 'nlabel' => 'storagesync.recalls.throughput.size.bytespersecond',
68 'unit' => 'B/s',
69 'min' => '0',
70 'max' => ''
71 }
72 };
73
74 return $metrics_mapping;
75 }
76
77 sub new {
78 my ($class, %options) = @_;
79 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
80 bless $self, $class;
81
82 $options{options}->add_options(arguments => {
83 'filter-metric:s' => { name => 'filter_metric' },
84 'resource:s' => { name => 'resource' },
85 'resource-group:s' => { name => 'resource_group' }
86 });
87
88 return $self;
89 }
90
91 sub check_options {
92 my ($self, %options) = @_;
93 $self->SUPER::check_options(%options);
94
95 if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
96 $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
97 $self->{output}->option_exit();
98 }
99 my $resource = $self->{option_results}->{resource};
100 my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
101 if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/microsoft\.storagesync\/storageSyncServices\/(.*)$/) {
102 $resource_group = $1;
103 $resource = $2;
104 }
105
106 $self->{az_resource} = $resource;
107 $self->{az_resource_group} = $resource_group;
108 $self->{az_resource_type} = 'storageSyncServices';
109 $self->{az_resource_namespace} = 'microsoft.storagesync';
110 $self->{az_timeframe} = defined($self->{option_results}->{timeframe}) ? $self->{option_results}->{timeframe} : 900;
111 $self->{az_interval} = defined($self->{option_results}->{interval}) ? $self->{option_results}->{interval} : 'PT5M';
112 $self->{az_aggregations} = ['Total'];
113 if (defined($self->{option_results}->{aggregation})) {
114 $self->{az_aggregations} = [];
115 foreach my $stat (@{$self->{option_results}->{aggregation}}) {
116 if ($stat ne '') {
117 push @{$self->{az_aggregations}}, ucfirst(lc($stat));
118 }
119 }
120 }
121
122 foreach my $metric (keys %{$self->{metrics_mapping}}) {
123 next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
124 && $metric !~ /$self->{option_results}->{filter_metric}/);
125 push @{$self->{az_metrics}}, $metric;
126 }
127 }
128
129 1;
130
131 __END__
132
133 =head1 MODE
134
135 Check Azure Storage Sync Service Files data recalls statistics.
136
137 Example:
138
139 Using resource name:
140
141 perl centreon_plugins.pl --plugin=cloud::azure::storage::storagesync::plugin --mode=recalls --custommode=api
142 --resource=<syncservice_id> --resource-group=<resourcegroup_id> --aggregation='total'
143 --warning-recalls-size='15' --critical-recalls-size='20'
144
145 Using resource ID:
146
147 perl centreon_plugins.pl --plugin=cloud::azure::storage::storagesync::plugin --mode=recalls --custommode=api
148 --resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/microsoft.storagesync/storageSyncServices/<syncservice_id>'
149 --aggregation='total' --warning-recalls-size='15' --critical-recalls-size='20'
150
151 Default aggregation: 'total' / 'minimum', 'maximum' and 'average' are valid.
152
153 =over 8
154
155 =item B<--resource>
156
157 Set resource name or ID (required).
158
159 =item B<--resource-group>
160
161 Set resource group (required if resource's name is used).
162
163 =item B<--warning-*>
164
165 Warning threshold where '*' can be:
166 'successful-recalls', 'application-recalls-size',
167 'recalls-size', 'total-recalls-size', 'throughput-recalls-size'.
168
169 =item B<--critical-*>
170
171 Critical threshold where '*' can be:
172 'successful-recalls', 'application-recalls-size', 'recalls-size',
173 'total-recalls-size', 'throughput-recalls-size'.
174
175 =back
176
177 =cut