add(plugin): Azure App Service Plan (#2765)

This commit is contained in:
Thibault S 2021-05-05 22:17:36 +02:00 committed by GitHub
parent d92d4309b6
commit a03662289f
8 changed files with 1013 additions and 0 deletions

View File

@ -0,0 +1,141 @@
#
# Copyright 2021 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::web::appserviceplan::mode::cpu;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'cpupercentage' => {
'output' => 'CPU Percentage',
'label' => 'cpu-usage-percentage',
'nlabel' => 'appserviceplan.cpu.usage.percentage',
'unit' => '%',
'min' => '0',
'max' => '100'
}
};
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 => {
'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();
}
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\.Web\/serverFarms\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'serverFarms';
$self->{az_resource_namespace} = 'Microsoft.Web';
$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 App Service Plan CPU statistics.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=cpu --custommode=api
--resource=<appsvcplan_id> --resource-group=<resourcegroup_id> --aggregation='average'
--warning-cpu-usage-percentage='80' --critical-cpu-usage-percentage='90'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=cpu --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/serverFarms/<appsvcplan_id>'
--aggregation='average' --warning-cpu-usage-percentage='80' --critical-cpu-usage-percentage='90'
Default aggregation: 'average' / 'total', 'minimum' and 'maximum' are valid.
=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-cpu-usage-percentage>
Warning threshold.
=item B<--critical-cpu-usage-percentage>
Critical threshold.
=back
=cut

View File

@ -0,0 +1,149 @@
#
# Copyright 2021 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::web::appserviceplan::mode::data;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'bytesreceived' => {
'output' => 'Data In',
'label' => 'data-in',
'nlabel' => 'appserviceplan.data.in.bytes',
'unit' => 'B',
'min' => '0'
},
'bytessent' => {
'output' => 'Data Out',
'label' => 'data-out',
'nlabel' => 'appserviceplan.data.out.bytes',
'unit' => 'B',
'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 => {
'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();
}
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\.Web\/serverFarms\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'serverFarms';
$self->{az_resource_namespace} = 'Microsoft.Web';
$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} = ['Total'];
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 App Service Plan data statistics.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=data --custommode=api
--resource=<appsvcplan_id> --resource-group=<resourcegroup_id> --aggregation='total'
--warning-data-in='10000' --critical-data-in='20000'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=data --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/serverFarms/<appsvcplan_id>'
--aggregation='total' --warning-data-in='10000' --critical-data-in='20000'
Default aggregation: 'total' / 'average', 'minimum' and 'maximum' are valid.
=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-*>
Warning threshold where '*' can be:
'data-in', 'data-out'.
=item B<--critical-*>
Critical threshold where '*' can be:
'data-in', 'data-out'.
=back
=cut

View File

@ -0,0 +1,60 @@
#
# Copyright 2021 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::web::appserviceplan::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.Web';
$self->{type} = 'serverfarms';
}
1;
__END__
=head1 MODE
Discover Azure Web App Service Plan resources.
=over 8
=item B<--resource-group>
Specify resource group.
=item B<--location>
Specify location.
=item B<--prettify>
Prettify JSON output.
=back
=cut

View File

@ -0,0 +1,78 @@
#
# Copyright 2021 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::web::appserviceplan::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.Web';
$self->{az_resource_type} = 'serverfarms';
}
1;
__END__
=head1 MODE
Check Azure Web App Service Plan status.
(Useful to determine host 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>
Set warning threshold for status (Default: '').
Can used special variables like: %{status}, %{summary}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} =~ /^Unavailable$/').
Can used special variables like: %{status}, %{summary}
=item B<--unknown-status>
Set unknown threshold for status (Default: '%{status} =~ /^Unknown$/').
Can used special variables like: %{status}, %{summary}
=item B<--ok-status>
Set ok threshold for status (Default: '%{status} =~ /^Available$/').
Can used special variables like: %{status}, %{summary}
=back
=cut

View File

@ -0,0 +1,141 @@
#
# Copyright 2021 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::web::appserviceplan::mode::memory;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'memorypercentage' => {
'output' => 'Memory Percentage',
'label' => 'memory-percentage',
'nlabel' => 'appserviceplan.memory.percentage',
'unit' => '%',
'min' => '0',
'max' => '100'
}
};
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 => {
'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();
}
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\.Web\/serverFarms\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'serverFarms';
$self->{az_resource_namespace} = 'Microsoft.Web';
$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 App Service Plan memory statistics.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=memory --custommode=api
--resource=<appsvcplan_id> --resource-group=<resourcegroup_id> --aggregation='average'
--warning-memory-percentage='80' --critical-memory-percentage='90'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=memory --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/serverFarms/<appsvcplan_id>'
--aggregation='average' --warning-memory-percentage='80' --critical-memory-percentage='90'
Default aggregation: 'average' / 'total', 'minimum' and 'maximum' are valid.
=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-memory-percentage>
Warning threshold.
=item B<--critical-memory-percentage>
Critical threshold.
=back
=cut

View File

@ -0,0 +1,176 @@
#
# Copyright 2021 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::web::appserviceplan::mode::socket;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'socketinboundall' => {
'output' => 'SocketInboundAll',
'label' => 'socket-inbound-all',
'nlabel' => 'appserviceplan.socket.inboundall.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'socketoutboundall' => {
'output' => 'SocketOutboundAll',
'label' => 'socket-outbound-all',
'nlabel' => 'appserviceplan.socket.outboundall.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'socketloopback' => {
'output' => 'SocketLoopback',
'label' => 'socket-loopback',
'nlabel' => 'appserviceplan.socket.loopback.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'socketoutboundestablished' => {
'output' => 'SocketOutboundEstablished',
'label' => 'socket-outbound-established',
'nlabel' => 'appserviceplan.socket.outboundestablished.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'socketoutboundtimewait' => {
'output' => 'SocketOutboundTimeWait',
'label' => 'socket-outbound-timewait',
'nlabel' => 'appserviceplan.socket.outboundtimewait.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
};
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 => {
'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();
}
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\.Web\/serverFarms\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'serverFarms';
$self->{az_resource_namespace} = 'Microsoft.Web';
$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 App Service Plan socket statistics.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=socket --custommode=api
--resource=<appsvcplan_id> --resource-group=<resourcegroup_id> --aggregation='average'
--warning-socket-outbound-timewait='10000' --critical-socket-outbound-timewait='20000'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=socket --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/serverFarms/<appsvcplan_id>'
--aggregation='average' --warning-socket-outbound-timewait='10000' --critical-socket-outbound-timewait='20000'
Default aggregation: 'average' / 'total', 'minimum' and 'maximum' are valid.
=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-*>
Warning threshold where '*' can be:
'socket-loopback', 'socket-outbound-established', 'socket-inbound-all', 'socket-outbound-all', 'socket-outbound-timewait'.
=item B<--critical-*>
Critical threshold where '*' can be:
'socket-loopback', 'socket-outbound-established', 'socket-inbound-all', 'socket-outbound-all', 'socket-outbound-timewait'.
=back
=cut

View File

@ -0,0 +1,202 @@
#
# Copyright 2021 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::web::appserviceplan::mode::tcpconnections;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'tcpclosewait' => {
'output' => 'TCP Close Wait',
'label' => 'tcp-closewait',
'nlabel' => 'appserviceplan.connections.tcp.closewait.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'tcpclosing' => {
'output' => 'TCP Closing',
'label' => 'tcp-closing',
'nlabel' => 'appserviceplan.connections.tcp.closing.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'tcpfinwait1' => {
'output' => 'TCP Fin Wait 1',
'label' => 'tcp-fin-wait1',
'nlabel' => 'appserviceplan.connections.tcp.finwait1.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'tcpfinwait2' => {
'output' => 'TCP Fin Wait 2',
'label' => 'tcp-fin-wait2',
'nlabel' => 'appserviceplan.connections.tcp.finwait2.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'tcplastack' => {
'output' => 'TCP Last Ack',
'label' => 'tcp-ack-last',
'nlabel' => 'appserviceplan.connections.tcp.lastack.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'tcpsynreceived' => {
'output' => 'TCP Syn Received',
'label' => 'tcp-syn-received',
'nlabel' => 'appserviceplan.connections.tcp.synreceived.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'tcpsynsent ' => {
'output' => 'TCP Syn Sent',
'label' => 'tcp-syn-sent',
'nlabel' => 'appserviceplan.connections.tcp.synsent.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
'tcptimewait ' => {
'output' => 'TCP Time Wait',
'label' => 'tcp-timewait',
'nlabel' => 'appserviceplan.connections.tcp.timewait.count',
'unit' => '',
'min' => '0',
'template' => '%d'
},
};
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 => {
'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();
}
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\.Web\/serverFarms\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'serverFarms';
$self->{az_resource_namespace} = 'Microsoft.Web';
$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 App Service Plan TCP connections statistics.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=tcp-connections --custommode=api
--resource=<appsvcplan_id> --resource-group=<resourcegroup_id> --aggregation='average'
--warning-tcp-closewait='1000' --critical-tcp-closewait='2000'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::web::appserviceplan::plugin --mode=tcp-connections --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/serverFarms/<appsvcplan_id>'
--aggregation='average' --warning-tcp-closewait='1000' --critical-tcp-closewait='2000'
Default aggregation: 'average' / 'total', 'minimum' and 'maximum' are valid.
=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-*>
Warning threshold where '*' can be:
'tcp-timewait', 'tcp-syn-sent', 'tcp-syn-received', 'tcp-ack-last', 'tcp-fin-wait2', 'tcp-fin-wait1',
'tcp-closewait', 'tcp-closing'.
=item B<--critical-*>
Critical threshold where '*' can be:
'tcp-timewait', 'tcp-syn-sent', 'tcp-syn-received', 'tcp-ack-last', 'tcp-fin-wait2', 'tcp-fin-wait1',
'tcp-closewait', 'tcp-closing'.
=back
=cut

View File

@ -0,0 +1,66 @@
#
# Copyright 2021 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::web::appserviceplan::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} = {
'cpu' => 'cloud::azure::web::appserviceplan::mode::cpu',
'data' => 'cloud::azure::web::appserviceplan::mode::data',
'discovery' => 'cloud::azure::web::appserviceplan::mode::discovery',
'health' => 'cloud::azure::web::appserviceplan::mode::health',
'memory' => 'cloud::azure::web::appserviceplan::mode::memory',
'socket' => 'cloud::azure::web::appserviceplan::mode::socket',
'tcp-connections' => 'cloud::azure::web::appserviceplan::mode::tcpconnections'
};
$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 => '2018-01-01' },
});
$self->SUPER::init(%options);
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Microsoft Azure Web App Service Plan resources.
=cut