Commit 84dcd8ac authored by lchrdn's avatar lchrdn
Browse files

adding filesharequota and some fixes

parent 7c256bd1
#
# 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::classicstorage::storageaccount::mode::listresources;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"resource-group:s" => { name => 'resource_group' },
"location:s" => { name => 'location' },
"filter-name:s" => { name => 'filter_name' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub manage_selection {
my ($self, %options) = @_;
$self->{resources} = $options{custom}->azure_list_resources(
namespace => 'Microsoft.ClassicStorage',
resource_type => 'storageAccounts',
location => $self->{option_results}->{location},
resource_group => $self->{option_results}->{resource_group}
);
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $resource (@{$self->{resources}}) {
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne ''
&& $resource->{name} !~ /$self->{option_results}->{filter_name}/);
my $resource_group = '-';
$resource_group = $resource->{resourceGroup} if (defined($resource->{resourceGroup}));
$resource_group = $1 if (defined($resource->{id}) && $resource->{id} =~ /resourceGroups\/(.*)\/providers/);
my @tags;
foreach my $tag (keys %{$resource->{tags}}) {
push @tags, $tag . ':' . $resource->{tags}->{$tag};
}
$self->{output}->output_add(long_msg => sprintf("[name = %s][resourcegroup = %s][location = %s][id = %s][tags = %s]",
$resource->{name},
$resource_group,
$resource->{location},
$resource->{id},
join(',', @tags),
));
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List storage accounts:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['name', 'resourcegroup', 'location', 'id', 'tags']);
}
sub disco_show {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $resource (@{$self->{resources}}) {
my $resource_group = '-';
$resource_group = $resource->{resourceGroup} if (defined($resource->{resourceGroup}));
$resource_group = $1 if (defined($resource->{id}) && $resource->{id} =~ /resourceGroups\/(.*)\/providers/);
my @tags;
foreach my $tag (keys %{$resource->{tags}}) {
push @tags, $tag . ':' . $resource->{tags}->{$tag};
}
$self->{output}->add_disco_entry(
name => $resource->{name},
resourcegroup => $resource_group,
location => $resource->{location},
id => $resource->{id},
tags => join(',', @tags),
);
}
}
1;
__END__
=head1 MODE
List classic storage account resources.
=over 8
=item B<--resource-group>
Set resource group.
=item B<--location>
Set resource location.
=item B<--filter-name>
Filter resource name (Can be a regexp).
=back
=cut
......@@ -32,9 +32,26 @@ sub new {
$self->{version} = '0.1';
%{ $self->{modes} } = (
'account-used-capacity' => 'cloud::azure::common::storageaccount::accountusedcapacity',
'blob-capacity' => 'cloud::azure::common::storageaccount::blobcapacity',
'blob-container-count' => 'cloud::azure::common::storageaccount::blobcontainercount',
'blob-count' => 'cloud::azure::common::storageaccount::blobcount',
'discovery' => 'cloud::azure::classicstorage::storageaccount::mode::discovery',
'file-count' => 'cloud::azure::common::storageaccount::filecount',
'file-capacity' => 'cloud::azure::common::storageaccount::filecapacity',
'file-count' => 'cloud::azure::common::storageaccount::filecount',
'file-share-count' => 'cloud::azure::common::storageaccount::filesharecount',
'file-share-quota' => 'cloud::azure::common::storageaccount::filesharecount',
'health' => 'cloud::azure::common::storageaccount::health',
'list-resources' => 'cloud::azure::classicstorage::storageaccount::mode::listresources',
'queue-capacity' => 'cloud::azure::common::storageaccount::queuecapacity',
'queue-count' => 'cloud::azure::common::storageaccount::queuecount',
'queue-message-count' => 'cloud::azure::common::storageaccount::queuemessagecount',
'table-capacity' => 'cloud::azure::common::storageaccount::tablecapacity',
'table-count' => 'cloud::azure::common::storageaccount::tablecount',
'table-entity-count' => 'cloud::azure::common::storageaccount::tableentitycount',
'transactions-availability' => 'cloud::azure::common::storageaccount::transactionsavailability',
'transactions-count' => 'cloud::azure::common::storageaccount::transactionscount',
'transactions-latency' => 'cloud::azure::common::storageaccount::transactionslatency',
'transactions-throughput' => 'cloud::azure::common::storageaccount::transactionsthroughput',
);
$self->{custom_modes}{azcli} = 'cloud::azure::custom::azcli';
......@@ -58,7 +75,7 @@ __END__
=head1 PLUGIN DESCRIPTION
Check Microsoft Azure storage account.
Check Microsoft Azure classic storage account.
=over 8
......
......@@ -18,7 +18,7 @@
# limitations under the License.
#
package cloud::azure::common::storageaccount::filesharecount;
package cloud::azure::common::storageaccount::filesharequota;
use base qw(centreon::plugins::templates::counter);
......@@ -96,8 +96,13 @@ sub check_options {
}
}
foreach my $metric ('FileShareQuota') {
push @{$self->{az_metrics}}, $metric;
if ($self->{az_resource}[0] =~ /Microsoft\.ClassicStorage/) {
foreach my $metric ('FileShareQuota') {
push @{$self->{az_metrics}}, $metric;
}
}
foreach my $metric ('FileShareCapacityQuota') {
push @{$self->{az_metrics}}, $metric;
}
}
......
......@@ -35,10 +35,11 @@ sub new {
'blob-capacity' => 'cloud::azure::common::storageaccount::blobcapacity',
'blob-container-count' => 'cloud::azure::common::storageaccount::blobcontainercount',
'blob-count' => 'cloud::azure::common::storageaccount::blobcount',
'discovery' => 'cloud::azure::common::storageaccount::discovery',
'discovery' => 'cloud::azure::storage::storageaccount::mode::discovery',
'file-capacity' => 'cloud::azure::common::storageaccount::filecapacity',
'file-count' => 'cloud::azure::storage::storageaccount::mode::filecount', # apparemment renvoie tjr rien
'file-count' => 'cloud::azure::common::storageaccount::filecount',
'file-share-count' => 'cloud::azure::common::storageaccount::filesharecount',
'file-share-quota' => 'cloud::azure::common::storageaccount::filesharequota',
'health' => 'cloud::azure::common::storageaccount::health',
'list-resources' => 'cloud::azure::storage::storageaccount::mode::listresources',
'queue-capacity' => 'cloud::azure::common::storageaccount::queuecapacity',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment