add(plugin): Azure App Service (#2669)

* add(plugin)azure

* nlabel fixes, memory mode fix

* commom/appservice creation folder
This commit is contained in:
itoussies 2021-03-25 20:47:38 +01:00 committed by GitHub
parent e157f003c1
commit 5c6abd70a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1825 additions and 0 deletions

View File

@ -0,0 +1,184 @@
#
# 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::common::appservice::mode::appusage;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'appconnections' => {
'output' => 'Connections',
'label' => 'connections',
'nlabel' => 'appservice.connections.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'currentassemblies' => {
'output' => 'Current Assemblies',
'label' => 'assemblies',
'nlabel' => 'appservice.assemblies.current.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'handles' => {
'output' => 'Handle Count',
'label' => 'handle',
'nlabel' => 'appservice.handle.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'threads' => {
'output' => 'Thread Count',
'label' => 'thread',
'nlabel' => 'appservice.thread.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'totalappdomains' => {
'output' => 'Total App Domains',
'label' => 'app-domains',
'nlabel' => 'appservice.appdomains.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'totalappdomainsunloaded' => {
'output' => 'Total App Domains Unloaded',
'label' => 'app-domain-unloaded',
'nlabel' => 'appservice.appdomains.unloaded.count',
'unit' => '',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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 app usage.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=app-usage --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='total'
--warning-thread='80' --critical-thread='90'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=app-usage --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='average' --warning-thread='80' --critical-thread='90'
Default aggregation: 'average' / 'minimum', 'maximum' and 'total' 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:
'connections', 'assemblies', 'handle', 'thread', 'app-domains',
'app-domain-unloaded'.
=item B<--critical-*>
Critical threshold where '*' can be:.
'connections', 'assemblies', 'handle', 'thread', 'app-domains',
'app-domain-unloaded'.
=back
=cut

View File

@ -0,0 +1,140 @@
#
# 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::common::appservice::mode::cputime;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'cputime' => {
'output' => 'CPU Time',
'label' => 'cpu-time',
'nlabel' => 'appservice.cpu.consumed.seconds',
'unit' => 's',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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 CPU time consumed by the app.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=cpu-time --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='total'
--warning-cpu-time='80' --critical-cpu-time='90'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=cpu-time --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='total' --warning-cpu-time='80' --critical-cpu-time='90'
Default aggregation: 'total' / 'minimum', 'maximum' and 'average' 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-time>
Consumed CPU time warning threshold.
=item B<--critical-cpu-time>
Consumed CPU time critical threshold.
=back
=cut

View File

@ -0,0 +1,150 @@
#
# 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::common::appservice::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' => 'appservice.data.in.bytes',
'unit' => 'B',
'min' => '0',
'max' => ''
},
'bytessent' => {
'output' => 'Data Out',
'label' => 'data-out',
'nlabel' => 'appservice.data.out.bytes',
'unit' => 'B',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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 bandwith consumed by the app.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=data --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='total'
--warning-data-in='80000' --critical-data-in='90000'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=data --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='total' --warning-data-in='80000' --critical-data-in='90000'
Default aggregation: 'total' / 'minimum', 'maximum' and 'average' 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::common::appservice::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} = 'sites';
}
1;
__END__
=head1 MODE
Azure App Service discovery.
=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,140 @@
#
# 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::common::appservice::mode::filesystem;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'filesystemusage' => {
'output' => 'File System Usage',
'label' => 'usage',
'nlabel' => 'appservice.filesystem.usage.bytes',
'unit' => 'B',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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} : 'PT6H';
$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 file system usage.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=filesystem-usage --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='average'
--warning-usage='80000' --critical-usage='90000'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=filesystem-usage --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='average' --warning-usage='80000' --critical-usage='90000'
Default aggregation: 'average' / 'minimum', 'maximum' and 'total' 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-usage>
File system usage warning threshold.
=item B<--critical-usage>
File system usage critical threshold.
=back
=cut

View File

@ -0,0 +1,158 @@
#
# 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::common::appservice::mode::gcusage;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'gen0collections' => {
'output' => 'Gen 0 Garbage Collections',
'label' => 'gc-gen0',
'nlabel' => 'appservice.gc.gen0.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'gen1collections' => {
'output' => 'Gen 1 Garbage Collections',
'label' => 'gc-gen2',
'nlabel' => 'appservice.gc.gen1.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'Gen2collections' => {
'output' => 'Gen 2 Garbage Collections',
'label' => 'gc-gen2',
'nlabel' => 'appservice.gc.gen2.count',
'unit' => '',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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 garbage collector.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=gc-usage --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='total'
--warning-gc-gen0='80' --critical-gc-gen0='90'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=gc-usage --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='total' --warning-gc-gen0='80' --critical-gc-gen0='90'
Default aggregation: 'total' / 'minimum', 'maximum' and 'average' 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:
'gc-gen0', 'gc-gen1', 'gc-gen2'.
=item B<--critical-*>
Critical threshold where '*' can be:.
'gc-gen0', 'gc-gen1', 'gc-gen2'.
=back
=cut

View File

@ -0,0 +1,76 @@
#
# 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::common::appservice::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} = 'sites';
}
1;
__END__
=head1 MODE
Check Azure App Service health 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: '').
Special variables that can be used: %{status}, %{summary}.
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} =~ /^Unavailable$/').
Special variables that can be used: %{status}, %{summary}.
=item B<--unknown-status>
Set unknown threshold for status (Default: '%{status} =~ /^Unknown$/').
Special variables that can be used: %{status}, %{summary}.
=item B<--ok-status>
Set ok threshold for status (Default: '%{status} =~ /^Available$/').
Special variables that can be used: %{status}, %{summary}.
=back
=cut

View File

@ -0,0 +1,224 @@
#
# 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::common::appservice::mode::httprequests;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'requests' => {
'output' => 'Requests',
'label' => 'requests',
'nlabel' => 'appservice.http.request.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'requestsinapplicationqueue' => {
'output' => 'Requests In Application Queue',
'label' => 'requests-queue',
'nlabel' => 'appservice.http.request.queue.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http101' => {
'output' => 'Http 101',
'label' => 'http-101',
'nlabel' => 'appservice.htpp.request.101.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http2xx' => {
'output' => 'Http 2xx',
'label' => 'http-2xx',
'nlabel' => 'appservice.htpp.request.2xx.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http3xx' => {
'output' => 'Http 3xx',
'label' => 'http-3xx',
'nlabel' => 'appservice.htpp.request.3xx.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http4xx' => {
'output' => 'Http 4xx',
'label' => 'http-4xx',
'nlabel' => 'appservice.htpp.request.4xx.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http401' => {
'output' => 'Http 401',
'label' => 'http-401',
'nlabel' => 'appservice.htpp.request.401.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http403' => {
'output' => 'Http 403',
'label' => 'http-403',
'nlabel' => 'appservice.htpp.request.403.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http404' => {
'output' => 'Http 404',
'label' => 'http-404',
'nlabel' => 'appservice.htpp.request.404.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http406' => {
'output' => 'Http 406',
'label' => 'http-406',
'nlabel' => 'appservice.htpp.request.406.count',
'unit' => '',
'min' => '0',
'max' => ''
},
'http5xx' => {
'output' => 'Http 5xx',
'label' => 'http-5xx',
'nlabel' => 'appservice.htpp.request.5xx.count',
'unit' => '',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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 HTTP requests count.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=http-requests --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='total'
--warning-requests='80' --critical-requests='90'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=http-requests --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='total' --warning-requests='80' --critical-requests='90'
Default aggregation: 'total' / 'minimum', 'maximum' and 'average' 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:
'requests', 'requests-queue', 'http-101', 'http-2xx', 'http-3xx', 'http-4xx',
'http-401','http-403', 'http-404', 'http-406', 'http-5xx'.
=item B<--critical-*>
Critical threshold where '*' can be:.
'requests', 'requests-queue', 'http-101', 'http-2xx', 'http-3xx', 'http-4xx',
'http-401','http-403', 'http-404', 'http-406', 'http-5xx'.
=back
=cut

View File

@ -0,0 +1,184 @@
#
# 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::common::appservice::mode::iooperations;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'iootherbytespersecond' => {
'output' => 'IO Other Bytes Per Second',
'label' => 'other-bytes',
'nlabel' => 'appservice.bytes.other.bytespersecond',
'unit' => 'B/s',
'min' => '0',
'max' => ''
},
'iootheroperationspersecond' => {
'output' => 'IO Other Operations Per Second',
'label' => 'other-operations',
'nlabel' => 'appservice.operations.other.bytespersecond',
'unit' => 'B/s',
'min' => '0',
'max' => ''
},
'ioreadbytespersecond' => {
'output' => 'IO Read Bytes Per Second',
'label' => 'read-bytes',
'nlabel' => 'appservice.bytes.read.bytespersecond',
'unit' => 'B/s',
'min' => '0',
'max' => ''
},
'ioreadoperationspersecond' => {
'output' => 'IO Read Operations Per Second',
'label' => 'read-operations',
'nlabel' => 'appservice.operations.read.bytespersecond',
'unit' => 'B/s',
'min' => '0',
'max' => ''
},
'iowritebytespersecond' => {
'output' => 'IO Write Bytes Per Second',
'label' => 'write-bytes',
'nlabel' => 'appservice.bytes.write.bytespersecond',
'unit' => 'B/s',
'min' => '0',
'max' => ''
},
'iowriteoperationspersecond' => {
'output' => 'IO Write Operations Per Second',
'label' => 'write-operations',
'nlabel' => 'appservice.operations.write.bytespersecond',
'unit' => 'B/s',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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 I/O operations by the app.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=io-operations --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='total'
--warning-write-bytes='80000' --critical-write-bytes='90000'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=io-operations --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='total' --warning-write-bytes='80000' --critical-write-bytes='90000'
Default aggregation: 'total' / 'minimum', 'maximum' and 'average' 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:
'other-bytes', 'other-operations', 'read-bytes', 'read-operations',
'write-bytes', 'write-operations'.
=item B<--critical-*>
Critical threshold where '*' can be:.
'other-bytes', 'other-operations', 'read-bytes', 'read-operations',
'write-bytes', 'write-operations'.
=back
=cut

View File

@ -0,0 +1,158 @@
#
# 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::common::appservice::mode::memory;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'averagememoryworkingset' => {
'output' => 'Average memory working set',
'label' => 'app-average-memory',
'nlabel' => 'appservice.memory.average.usage.bytes',
'unit' => 'B',
'min' => '0',
'max' => '',
},
'memoryworkingset' => {
'output' => 'Memory working set',
'label' => 'app-memory',
'nlabel' => 'appservice.memory.usage.bytes',
'unit' => 'B',
'min' => '0',
'max' => '',
},
'privatebytes' => {
'output' => 'Private Bytes',
'label' => 'app-private-bytes',
'nlabel' => 'appservice.memory.privatebytes.usage.bytes',
'unit' => 'B',
'min' => '0',
'max' => '',
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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 app memory usage.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=memory --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='average'
--warning-app-memory='80' --critical-app-memory='90'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=memory --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='average' --warning-app-memory='80'' --critical-app-memory='90'
Default aggregation: 'average' / 'minimum', 'maximum' and 'total' 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:
'app-average-memory', 'app-memory', 'app-private-bytes'.
=item B<--critical-*>
Critical threshold where '*' can be:.
'app-average-memory', 'app-memory', 'app-private-bytes'.
=back
=cut

View File

@ -0,0 +1,140 @@
#
# 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::common::appservice::mode::responsetime;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'httpresponsetime' => {
'output' => 'Response Time',
'label' => 'response-time',
'nlabel' => 'appservice.http.response.time.seconds',
'unit' => 's',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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 HTTP response time.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=response-time --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='average'
--warning-response-time='80' --critical-response-time='90'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=response-time --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='total' --warning-response-time='80' --critical-response-time='90'
Default aggregation: 'average' / 'minimum', 'maximum' and 'total' 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-response-time>
Response time warning threshold.
=item B<--critical-response-time>
Response time critical threshold.
=back
=cut

View File

@ -0,0 +1,140 @@
#
# 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::common::appservice::mode::status;
use base qw(cloud::azure::custom::mode);
use strict;
use warnings;
sub get_metrics_mapping {
my ($self, %options) = @_;
my $metrics_mapping = {
'healthcheckstatus' => {
'output' => 'Health check status',
'label' => 'status',
'nlabel' => 'appservice.status.count',
'unit' => '',
'min' => '0',
'max' => ''
}
};
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\/sites\/(.*)$/) {
$resource_group = $1;
$resource = $2;
}
$self->{az_resource} = $resource;
$self->{az_resource_group} = $resource_group;
$self->{az_resource_type} = 'sites';
$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} : 'PT6H';
$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 app health status.
Example:
Using resource name :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=status --custommode=api
--resource=<sites_id> --resource-group=<resourcegroup_id> --aggregation='average'
--warning-status='80000'' --critical-status='90000'
Using resource id :
perl centreon_plugins.pl --plugin=cloud::azure::common::appservice::plugin --mode=filesystem-status --custommode=api
--resource='/subscriptions/<subscription_id>/resourceGroups/<resourcegroup_id>/providers/Microsoft.Web/sites/<sites_id>'
--aggregation='average' --warning-status='80000' --critical-status='90000'
Default aggregation: 'average' / 'minimum', 'maximum' and 'total' 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-status>
App status warning threshold.
=item B<--critical-status>
App status critical threshold.
=back
=cut

View File

@ -0,0 +1,71 @@
#
# 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::appservice::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} = {
'data' => 'cloud::azure::common::appservice::mode::data',
'health' => 'cloud::azure::common::appservice::mode::health',
'memory' => 'cloud::azure::common::appservice::mode::memory',
'status' => 'cloud::azure::common::appservice::mode::status',
'cpu-time' => 'cloud::azure::common::appservice::mode::cputime',
'gc-usage' => 'cloud::azure::common::appservice::mode::gcusage',
'app-usage' => 'cloud::azure::common::appservice::mode::appusage',
'discovery' => 'cloud::azure::common::appservice::mode::discovery',
'io-operations' => 'cloud::azure::common::appservice::mode::iooperations',
'http-requests' => 'cloud::azure::common::appservice::mode::httprequests',
'response-time' => 'cloud::azure::common::appservice::mode::responsetime',
'filesystem-usage' => 'cloud::azure::common::appservice::mode::filesystem'
};
$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 App Service.
=cut