(plugin) cloud::azure::datafactory::factories - add new plugin (#4027)
* Adding Azure Data Factory plugin * Update * Update + fix * Update * Update * Update * Update * + change unit * Apply correct transformation Co-authored-by: Simon Bomm <sbomm@centreon.com>
This commit is contained in:
parent
531071c5f3
commit
512962338c
|
@ -0,0 +1,60 @@
|
|||
#
|
||||
# Copyright 2022 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::datafactory::factories::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.DataFactory';
|
||||
$self->{type} = 'factories';
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Data factory discovery.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--resource-group>
|
||||
|
||||
Specify resources resource group.
|
||||
|
||||
=item B<--location>
|
||||
|
||||
Specify resources location.
|
||||
|
||||
=item B<--prettify>
|
||||
|
||||
Prettify JSON output.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,229 @@
|
|||
#
|
||||
# Copyright 2022 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::datafactory::factories::mode::factoryusage;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'factory_percentage_usage' => {
|
||||
'output' => 'Factory usage',
|
||||
'label' => 'factory-percentage-usage',
|
||||
'nlabel' => 'azdatafactory.factoryusage.percentage',
|
||||
'unit' => '%',
|
||||
'min' => '0',
|
||||
'max' => '100'
|
||||
},
|
||||
'resource_percentage_usage' => {
|
||||
'output' => 'Resource usage',
|
||||
'label' => 'resource-percentage-usage',
|
||||
'nlabel' => 'azdatafactory.factoryusage.resource.percentage',
|
||||
'unit' => '%',
|
||||
'min' => '0',
|
||||
'max' => '100'
|
||||
},
|
||||
'FactorySizeInGbUnits' => {
|
||||
'output' => 'Factory size',
|
||||
'label' => 'factory-size',
|
||||
'nlabel' => 'azdatafactory.factoryusage.size.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0',
|
||||
'change_bytes' => '2'
|
||||
},
|
||||
'ResourceCount' => {
|
||||
'output' => 'Resource count',
|
||||
'label' => 'resource-count',
|
||||
'nlabel' => 'azdatafactory.factoryusage.resource.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 => {
|
||||
'api-version:s' => { name => 'api_version', default => '2018-01-01'},
|
||||
'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->{output}->add_option_msg(short_msg => "Need to specify either --resource <name> with --resource-group option or --resource <id>.");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{api_version} = (defined($self->{option_results}->{api_version}) && $self->{option_results}->{api_version} ne "") ? $self->{option_results}->{api_version} : "2018-01-01";
|
||||
|
||||
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\.DataFactory\/factories\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource = $2;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = 'factories';
|
||||
$self->{az_resource_namespace} = 'Microsoft.DataFactory';
|
||||
$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 ('FactorySizeInGbUnits', 'MaxAllowedFactorySizeInGbUnits', 'ResourceCount', 'MaxAllowedResourceCount') {
|
||||
push @{$self->{az_metrics}}, $metric;
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my %metric_results;
|
||||
my $raw_results;
|
||||
|
||||
($metric_results{$self->{az_resource}}, $raw_results) = $options{custom}->azure_get_metrics(
|
||||
aggregations => $self->{az_aggregations},
|
||||
dimension => $self->{az_dimension},
|
||||
interval => $self->{az_interval},
|
||||
metrics => $self->{az_metrics},
|
||||
resource => $self->{az_resource},
|
||||
resource_group => $self->{az_resource_group},
|
||||
resource_namespace => $self->{az_resource_namespace},
|
||||
resource_type => $self->{az_resource_type},
|
||||
timeframe => $self->{az_timeframe}
|
||||
);
|
||||
|
||||
my $datas = 0;
|
||||
$self->{metrics}->{$self->{az_resource}}->{display} = $self->{az_resource};
|
||||
foreach my $aggregation (@{$self->{az_aggregations}}) {
|
||||
next if (!defined($aggregation) && !defined($self->{option_results}->{zeroed}));
|
||||
$self->{metrics}->{$self->{az_resource}}->{statistics}->{lc($aggregation)}->{display} = lc($aggregation);
|
||||
$self->{metrics}->{$self->{az_resource}}->{statistics}->{lc($aggregation)}->{timeframe} = $self->{az_timeframe};
|
||||
foreach my $metric (@{$self->{az_metrics}}) {
|
||||
my $metric_name = lc($metric);
|
||||
$metric_name =~ s/ /_/g;
|
||||
next if (!defined($metric_results{$self->{az_resource}}->{$metric_name}->{lc($aggregation)}) && !defined($self->{option_results}->{zeroed}));
|
||||
$self->{metrics}->{$self->{az_resource}}->{statistics}->{lc($aggregation)}->{$metric} =
|
||||
defined($metric_results{$self->{az_resource}}->{$metric_name}->{lc($aggregation)}) ?
|
||||
$metric_results{$self->{az_resource}}->{$metric_name}->{lc($aggregation)} : 0;
|
||||
$datas = 1;
|
||||
}
|
||||
# Compute percentages from metrics
|
||||
next if (!defined($self->{metrics}->{$self->{az_resource}}->{statistics}->{lc($aggregation)}));
|
||||
my $metricsAggregation = $self->{metrics}->{$self->{az_resource}}->{statistics}->{lc($aggregation)};
|
||||
if (defined($metricsAggregation->{FactorySizeInGbUnits})) {
|
||||
$metricsAggregation->{FactorySizeInGbUnits} = $metricsAggregation->{FactorySizeInGbUnits} * 1024 * 1024 * 1024;
|
||||
}
|
||||
if (defined($metricsAggregation->{MaxAllowedFactorySizeInGbUnits}) || defined($self->{option_results}->{zeroed})) {
|
||||
$metricsAggregation->{MaxAllowedFactorySizeInGbUnits} = $metricsAggregation->{MaxAllowedFactorySizeInGbUnits} * 1024 * 1024 * 1024;
|
||||
my $max_allowed_factory_size_in_gb_units = $metricsAggregation->{MaxAllowedFactorySizeInGbUnits};
|
||||
if ($max_allowed_factory_size_in_gb_units > 0) {
|
||||
$metricsAggregation->{factory_percentage_usage} = ($metricsAggregation->{FactorySizeInGbUnits} / $max_allowed_factory_size_in_gb_units) * 100;
|
||||
} else {
|
||||
$metricsAggregation->{factory_percentage_usage} = 0;
|
||||
}
|
||||
$datas = 1;
|
||||
}
|
||||
if (defined($metricsAggregation->{MaxAllowedResourceCount}) || defined($self->{option_results}->{zeroed})) {
|
||||
my $max_allowed_resource_count = $metricsAggregation->{MaxAllowedResourceCount};
|
||||
if ($max_allowed_resource_count > 0) {
|
||||
$metricsAggregation->{resource_percentage_usage} = ($metricsAggregation->{ResourceCount} / $max_allowed_resource_count) * 100;
|
||||
} else {
|
||||
$metricsAggregation->{resource_percentage_usage} = 0;
|
||||
}
|
||||
$datas = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$datas) {
|
||||
$self->{output}->add_option_msg(short_msg => 'No metrics. Check your options or use --zeroed option to set 0 on undefined values');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check Azure Data Factory for factory size and resource usage.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::datafactory::factory::plugin --mode=factoryusage --custommode=api
|
||||
--resource=<factory_id> --resource-group=<resourcegroup_id>
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::datafactory::factory::plugin --mode=factoryusage --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DataFactory/factories/<factory_id>'
|
||||
|
||||
|
||||
=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-$metric$>
|
||||
|
||||
Thresholds warning ($metric$ can be: 'factory-percentage-usage', 'resource-percentage-usage', 'factory-size', 'resource-count').
|
||||
|
||||
=item B<--critical-$metric$>
|
||||
|
||||
Thresholds critical ($metric$ can be: 'factory-percentage-usage', 'resource-percentage-usage', 'factory-size', 'resource-count').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,179 @@
|
|||
#
|
||||
# Copyright 2022 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::datafactory::factories::mode::integrationruntime;
|
||||
|
||||
use base qw(cloud::azure::custom::mode);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub get_metrics_mapping {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $metrics_mapping = {
|
||||
'IntegrationRuntimeAvailableMemory' => {
|
||||
'output' => 'Available memory',
|
||||
'label' => 'available-memory',
|
||||
'nlabel' => 'azdatafactory.integrationruntime.available.memory.bytes',
|
||||
'unit' => 'B',
|
||||
'min' => '0'
|
||||
},
|
||||
'IntegrationRuntimeAvailableNodeNumber' => {
|
||||
'output' => 'Available node number',
|
||||
'label' => 'available-node-number',
|
||||
'nlabel' => 'azdatafactory.integrationruntime.available.node.number.count',
|
||||
'unit' => '',
|
||||
'min' => '0'
|
||||
},
|
||||
'IntegrationRuntimeAverageTaskPickupDelay' => {
|
||||
'output' => 'Average task pickup delay',
|
||||
'label' => 'average-task-pickup-delay',
|
||||
'nlabel' => 'azdatafactory.integrationruntime.average.pickup.delay.seconds',
|
||||
'unit' => 's',
|
||||
'min' => '0'
|
||||
},
|
||||
'IntegrationRuntimeCpuPercentage' => {
|
||||
'output' => 'Cpu percentage',
|
||||
'label' => 'cpu-percentage',
|
||||
'nlabel' => 'azdatafactory.integrationruntime.cpu.percentage.percent',
|
||||
'unit' => '%',
|
||||
'min' => '0',
|
||||
'max' => '100'
|
||||
},
|
||||
'IntegrationRuntimeQueueLength' => {
|
||||
'output' => 'Queue length',
|
||||
'label' => 'queue-length',
|
||||
'nlabel' => 'azdatafactory.integrationruntime.queue.length.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 => {
|
||||
'api-version:s' => { name => 'api_version', default => '2018-01-01'},
|
||||
'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 <name> with --resource-group option or --resource <id>.');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
$self->{api_version} = (defined($self->{option_results}->{api_version}) && $self->{option_results}->{api_version} ne "") ? $self->{option_results}->{api_version} : "2018-01-01";
|
||||
|
||||
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\.DataFactory\/factories\/(.*)$/) {
|
||||
$resource_group = $1;
|
||||
$resource = $2;
|
||||
}
|
||||
|
||||
$self->{az_resource} = $resource;
|
||||
$self->{az_resource_group} = $resource_group;
|
||||
$self->{az_resource_type} = 'factories';
|
||||
$self->{az_resource_namespace} = 'Microsoft.DataFactory';
|
||||
$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 Data Factory for factory integration runtime metrics.
|
||||
|
||||
Example:
|
||||
|
||||
Using resource name :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::datafactory::factory::plugin --mode=factoryusage --custommode=api
|
||||
--resource=<factory_id> --resource-group=<resourcegroup_id>
|
||||
|
||||
Using resource id :
|
||||
|
||||
perl centreon_plugins.pl --plugin=cloud::azure::datafactory::factory::plugin --mode=factoryusage --custommode=api
|
||||
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.DataFactory/factories/<factory_id>'
|
||||
|
||||
|
||||
=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: 'IntegrationRuntimeAvailableMemory', 'IntegrationRuntimeAvailableNodeNumber',
|
||||
'IntegrationRuntimeAverageTaskPickupDelay', 'IntegrationRuntimeCpuPercentage', 'IntegrationRuntimeQueueLength')
|
||||
(Can be a regexp).
|
||||
|
||||
=item B<--warning-$metric$>
|
||||
|
||||
Thresholds warning ($metric$ can be: 'available-memory', 'available-node-number', 'average-task-pickup-delay',
|
||||
'cpu-percentage', 'queue-length').
|
||||
|
||||
=item B<--critical-$metric$>
|
||||
|
||||
Thresholds critical ($metric$ can be: 'available-memory', 'available-node-number', 'average-task-pickup-delay',
|
||||
'cpu-percentage', 'queue-length').
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
|
@ -0,0 +1,59 @@
|
|||
#
|
||||
# Copyright 2022 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::datafactory::factories::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} } = (
|
||||
'factory-usage' => 'cloud::azure::datafactory::factories::mode::factoryusage',
|
||||
'integration-runtime' => 'cloud::azure::datafactory::factories::mode::integrationruntime',
|
||||
'discovery' => 'cloud::azure::datafactory::factories::mode::discovery'
|
||||
);
|
||||
|
||||
$self->{custom_modes}{api} = 'cloud::azure::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub init {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{options}->add_options(arguments => { });
|
||||
|
||||
$self->SUPER::init(%options);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check Microsoft Azure data factories.
|
||||
|
||||
=cut
|
Loading…
Reference in New Issue