mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 15:44:21 +02:00
resourceid management (#3195)
This commit is contained in:
parent
3961d7775e
commit
3755f5bc1c
@ -691,6 +691,7 @@ sub azure_get_insights_analytics {
|
|||||||
foreach (@{$_->{rows}}) {
|
foreach (@{$_->{rows}}) {
|
||||||
$raw_results->{data}->{$j}->{tags} = @$_[$raw_results->{index}->{Tags}];
|
$raw_results->{data}->{$j}->{tags} = @$_[$raw_results->{index}->{Tags}];
|
||||||
$raw_results->{data}->{$j}->{computer} = @$_[$raw_results->{index}->{Computer}];
|
$raw_results->{data}->{$j}->{computer} = @$_[$raw_results->{index}->{Computer}];
|
||||||
|
$raw_results->{data}->{$j}->{resourceid} = @$_[$raw_results->{index}->{_ResourceId}];
|
||||||
if (!defined($options{disco})) {
|
if (!defined($options{disco})) {
|
||||||
$raw_results->{data}->{$j}->{timegenerated} = @$_[$raw_results->{index}->{TimeGenerated}];
|
$raw_results->{data}->{$j}->{timegenerated} = @$_[$raw_results->{index}->{TimeGenerated}];
|
||||||
$raw_results->{data}->{$j}->{name} = @$_[$raw_results->{index}->{Name}];
|
$raw_results->{data}->{$j}->{name} = @$_[$raw_results->{index}->{Name}];
|
||||||
|
@ -84,9 +84,10 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-computer:s' => { name => 'filter_computer' },
|
'filter-computer:s' => { name => 'filter_computer' },
|
||||||
'filter-cpu:s' => { name => 'filter_cpu' },
|
'filter-cpu:s' => { name => 'filter_cpu' },
|
||||||
'workspace-id:s' => { name => 'workspace_id' }
|
'filter-resourceid:s' => { name => 'filter_resourceid' },
|
||||||
|
'workspace-id:s' => { name => 'workspace_id' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -103,6 +104,7 @@ sub manage_selection {
|
|||||||
|
|
||||||
my $query = 'InsightsMetrics | where Namespace == "Processor" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
my $query = 'InsightsMetrics | where Namespace == "Processor" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||||
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
||||||
|
$query .= '| where _ResourceId == "' . $self->{option_results}->{filter_resourceid} . '"' if defined $self->{option_results}->{filter_resourceid} && $self->{option_results}->{filter_resourceid} ne '';
|
||||||
|
|
||||||
my $results = $options{custom}->azure_get_insights_analytics(
|
my $results = $options{custom}->azure_get_insights_analytics(
|
||||||
workspace_id => $self->{option_results}->{workspace_id},
|
workspace_id => $self->{option_results}->{workspace_id},
|
||||||
@ -164,6 +166,10 @@ perl centreon_plugins.pl --plugin=cloud::azure::management::insightsmetrics::plu
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--workspace-id>
|
||||||
|
(Mandatory)
|
||||||
|
Specify the Azure Log Analytics Workspace ID.
|
||||||
|
|
||||||
=item B<--filter-computer>
|
=item B<--filter-computer>
|
||||||
|
|
||||||
Filter on a specific Azure "computer".
|
Filter on a specific Azure "computer".
|
||||||
|
@ -32,7 +32,8 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'computer:s' => { name => 'computer' },
|
'name' => { name => 'name' },
|
||||||
|
'resource:s' => { name => 'resource' },
|
||||||
'workspace-id:s' => { name => 'workspace_id' }
|
'workspace-id:s' => { name => 'workspace_id' }
|
||||||
});
|
});
|
||||||
return $self;
|
return $self;
|
||||||
@ -42,8 +43,8 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{computer}) || $self->{option_results}->{computer} eq '') {
|
if (!defined($self->{option_results}->{resource}) || $self->{option_results}->{resource} eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify --computer option.");
|
$self->{output}->add_option_msg(short_msg => "Need to specify --resource option.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +52,12 @@ sub check_options {
|
|||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $query = 'InsightsMetrics | where Namespace == "LogicalDisk" | distinct Tags, Computer | where Computer == "' . $self->{option_results}->{computer} . '"';
|
my $query = 'InsightsMetrics | where Namespace == "LogicalDisk" | distinct Tags, _ResourceId, Computer';
|
||||||
|
if (defined($self->{option_results}->{name})) {
|
||||||
|
$query .= '| where Computer == "' . $self->{option_results}->{resource} . '"';
|
||||||
|
} else {
|
||||||
|
$query .= '| where _ResourceId == "' . $self->{option_results}->{resource} . '"';
|
||||||
|
}
|
||||||
|
|
||||||
my $results = $options{custom}->azure_get_insights_analytics(
|
my $results = $options{custom}->azure_get_insights_analytics(
|
||||||
workspace_id => $self->{option_results}->{workspace_id},
|
workspace_id => $self->{option_results}->{workspace_id},
|
||||||
@ -66,6 +72,11 @@ sub manage_selection {
|
|||||||
|
|
||||||
$self->{logicaldisk}->{$decoded_tag->{"vm.azm.ms/mountId"}}->{name} = $decoded_tag->{"vm.azm.ms/mountId"};
|
$self->{logicaldisk}->{$decoded_tag->{"vm.azm.ms/mountId"}}->{name} = $decoded_tag->{"vm.azm.ms/mountId"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scalar(keys %{$self->{logicaldisk}}) <= 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "No logical disks found. Can be: filters, cache file.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
@ -107,8 +118,30 @@ __END__
|
|||||||
|
|
||||||
List Azure Computer logical disks.
|
List Azure Computer logical disks.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
perl centreon_plugins.pl --plugin=cloud::azure::management::insightsmetrics::plugin --custommode=api --mode=list-logical-disks
|
||||||
|
--subscription=1111 --tenant=2222 --client-id=3333 --client-secret=4444 --workspace-id=5555 --verbose --resource='azure-vm1'
|
||||||
|
--name
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--workspace-id>
|
||||||
|
(Mandatory)
|
||||||
|
Specify the Azure Log Analytics Workspace ID.
|
||||||
|
|
||||||
|
=item B<--resource>
|
||||||
|
|
||||||
|
(Mandatory)
|
||||||
|
Specify the Azure VM Resource ID or name. Short name can be used if the option --name is defined.
|
||||||
|
Example: --resource='/subscriptions/1234abcd-5678-defg-9012-3456789abcde/resourcegroups/my_resourcegroup/providers/microsoft.compute/virtualmachines/azure-vm1'
|
||||||
|
|
||||||
|
=item B<--name>
|
||||||
|
|
||||||
|
(Optional)
|
||||||
|
Use only the name of the VM resource rather than the full ID.
|
||||||
|
Example: --resource='azure-vm1' --name
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
@ -148,9 +148,10 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-computer:s' => { name => 'filter_computer' },
|
'filter-computer:s' => { name => 'filter_computer' },
|
||||||
'filter-disk:s' => { name => 'filter_disk' },
|
'filter-disk:s' => { name => 'filter_disk' },
|
||||||
'workspace-id:s' => { name => 'workspace_id' }
|
'filter-resourceid:s' => { name => 'filter_resourceid' },
|
||||||
|
'workspace-id:s' => { name => 'workspace_id' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -167,6 +168,7 @@ sub manage_selection {
|
|||||||
|
|
||||||
my $query = 'InsightsMetrics | where Namespace == "LogicalDisk" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
my $query = 'InsightsMetrics | where Namespace == "LogicalDisk" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||||
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
||||||
|
$query .= '| where _ResourceId == "' . $self->{option_results}->{filter_resourceid} . '"' if defined $self->{option_results}->{filter_resourceid} && $self->{option_results}->{filter_resourceid} ne '';
|
||||||
|
|
||||||
my $results = $options{custom}->azure_get_insights_analytics(
|
my $results = $options{custom}->azure_get_insights_analytics(
|
||||||
workspace_id => $self->{option_results}->{workspace_id},
|
workspace_id => $self->{option_results}->{workspace_id},
|
||||||
@ -241,6 +243,10 @@ perl centreon_plugins.pl --plugin=cloud::azure::management::insightsmetrics::plu
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--workspace-id>
|
||||||
|
(Mandatory)
|
||||||
|
Specify the Azure Log Analytics Workspace ID.
|
||||||
|
|
||||||
=item B<--filter-computer>
|
=item B<--filter-computer>
|
||||||
|
|
||||||
Filter on a specific Azure "computer".
|
Filter on a specific Azure "computer".
|
||||||
|
@ -97,8 +97,9 @@ sub new {
|
|||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-computer:s' => { name => 'filter_computer' },
|
'filter-computer:s' => { name => 'filter_computer' },
|
||||||
'workspace-id:s' => { name => 'workspace_id' }
|
'filter-resourceid:s' => { name => 'filter_resourceid' },
|
||||||
|
'workspace-id:s' => { name => 'workspace_id' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
@ -115,6 +116,7 @@ sub manage_selection {
|
|||||||
|
|
||||||
my $query = 'InsightsMetrics | where Namespace == "Memory" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
my $query = 'InsightsMetrics | where Namespace == "Memory" | summarize arg_max(TimeGenerated, *) by Tags, Name, Computer';
|
||||||
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
$query .= '| where Computer == "' . $self->{option_results}->{filter_computer} . '"' if defined $self->{option_results}->{filter_computer} && $self->{option_results}->{filter_computer} ne '';
|
||||||
|
$query .= '| where _ResourceId == "' . $self->{option_results}->{filter_resourceid} . '"' if defined $self->{option_results}->{filter_resourceid} && $self->{option_results}->{filter_resourceid} ne '';
|
||||||
|
|
||||||
my $results = $options{custom}->azure_get_insights_analytics(
|
my $results = $options{custom}->azure_get_insights_analytics(
|
||||||
workspace_id => $self->{option_results}->{workspace_id},
|
workspace_id => $self->{option_results}->{workspace_id},
|
||||||
@ -173,6 +175,10 @@ perl centreon_plugins.pl --plugin=cloud::azure::management::insightsmetrics::plu
|
|||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--workspace-id>
|
||||||
|
(Mandatory)
|
||||||
|
Specify the Azure Log Analytics Workspace ID.
|
||||||
|
|
||||||
=item B<--filter-computer>
|
=item B<--filter-computer>
|
||||||
|
|
||||||
Filter on a specific Azure "computer".
|
Filter on a specific Azure "computer".
|
||||||
|
Loading…
x
Reference in New Issue
Block a user