Debian Codegraph @

src/cloud/azure/datafactory/factories/mode/integrationruntime.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::datafactory::factories::mode::integrationruntime;
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 'IntegrationRuntimeAvailableMemory' => {
33 'output' => 'Available memory',
34 'label' => 'available-memory',
35 'nlabel' => 'azdatafactory.integrationruntime.available.memory.bytes',
36 'unit' => 'B',
37 'min' => '0'
38 },
39 'IntegrationRuntimeAvailableNodeNumber' => {
40 'output' => 'Available node number',
41 'label' => 'available-node-number',
42 'nlabel' => 'azdatafactory.integrationruntime.available.node.number.count',
43 'unit' => '',
44 'min' => '0'
45 },
46 'IntegrationRuntimeAverageTaskPickupDelay' => {
47 'output' => 'Average task pickup delay',
48 'label' => 'average-task-pickup-delay',
49 'nlabel' => 'azdatafactory.integrationruntime.average.pickup.delay.seconds',
50 'unit' => 's',
51 'min' => '0'
52 },
53 'IntegrationRuntimeCpuPercentage' => {
54 'output' => 'Cpu percentage',
55 'label' => 'cpu-percentage',
56 'nlabel' => 'azdatafactory.integrationruntime.cpu.percentage.percent',
57 'unit' => '%',
58 'min' => '0',
59 'max' => '100'
60 },
61 'IntegrationRuntimeQueueLength' => {
62 'output' => 'Queue length',
63 'label' => 'queue-length',
64 'nlabel' => 'azdatafactory.integrationruntime.queue.length.count',
65 'unit' => '',
66 'min' => '0'
67 }
68 };
69
70 return $metrics_mapping;
71 }
72
73 sub new {
74 my ($class, %options) = @_;
75 my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
76 bless $self, $class;
77
78 $options{options}->add_options(arguments => {
79 'api-version:s' => { name => 'api_version', default => '2018-01-01'},
80 'filter-metric:s' => { name => 'filter_metric' },
81 'resource:s' => { name => 'resource' },
82 'resource-group:s' => { name => 'resource_group' }
83 });
84 return $self;
85 }
86
87 sub check_options {
88 my ($self, %options) = @_;
89 $self->SUPER::check_options(%options);
90
91 if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
92 $self->{output}->add_option_msg(short_msg => 'Need to specify either --resource <name> with --resource-group option or --resource <id>.');
93 $self->{output}->option_exit();
94 }
95
96 $self->{api_version} = (defined($self->{option_results}->{api_version}) && $self->{option_results}->{api_version} ne "") ? $self->{option_results}->{api_version} : "2018-01-01";
97
98 my $resource = $self->{option_results}->{resource};
99 my $resource_group = defined($self->{option_results}->{resource_group}) ? $self->{option_results}->{resource_group} : '';
100
101 if ($resource =~ /^\/subscriptions\/.*\/resourceGroups\/(.*)\/providers\/Microsoft\.DataFactory\/factories\/(.*)$/) {
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} = 'factories';
109 $self->{az_resource_namespace} = 'Microsoft.DataFactory';
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} = ['Average'];
113
114 if (defined($self->{option_results}->{aggregation})) {
115 $self->{az_aggregations} = [];
116 foreach my $stat (@{$self->{option_results}->{aggregation}}) {
117 if ($stat ne '') {
118 push @{$self->{az_aggregations}}, ucfirst(lc($stat));
119 }
120 }
121 }
122
123 foreach my $metric (keys %{$self->{metrics_mapping}}) {
124 next if (defined($self->{option_results}->{filter_metric}) && $self->{option_results}->{filter_metric} ne ''
125 && $metric !~ /$self->{option_results}->{filter_metric}/);
126 push @{$self->{az_metrics}}, $metric;
127 }
128 }
129
130 1;
131
132 __END__
133
134 =head1 MODE
135
136 Check Azure Data Factory for factory integration runtime metrics.
137
138 Example:
139
140 Using resource name:
141
142 perl centreon_plugins.pl --plugin=cloud::azure::datafactory::factory::plugin --mode=factoryusage --custommode=api
143 --resource=<factory_id> --resource-group=<resourcegroup_id>
144
145 Using resource ID:
146
147 perl centreon_plugins.pl --plugin=cloud::azure::datafactory::factory::plugin --mode=factoryusage --custommode=api
148 --resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DataFactory/factories/<factory_id>'
149
150
151 =over 8
152
153 =item B<--resource>
154
155 Set resource name or ID (required).
156
157 =item B<--resource-group>
158
159 Set resource group (required if resource's name is used).
160
161 =item B<--filter-metric>
162
163 Filter metrics (can be: 'IntegrationRuntimeAvailableMemory', 'IntegrationRuntimeAvailableNodeNumber',
164 'IntegrationRuntimeAverageTaskPickupDelay', 'IntegrationRuntimeCpuPercentage', 'IntegrationRuntimeQueueLength')
165 (can be a regexp).
166
167 =item B<--warning-$metric$>
168
169 Warning thresholds ($metric$ can be: 'available-memory', 'available-node-number', 'average-task-pickup-delay',
170 'cpu-percentage', 'queue-length').
171
172 =item B<--critical-$metric$>
173
174 Critical thresholds ($metric$ can be: 'available-memory', 'available-node-number', 'average-task-pickup-delay',
175 'cpu-percentage', 'queue-length').
176
177 =back
178
179 =cut