diff --git a/src/centreon/plugins/mode.pm b/src/centreon/plugins/mode.pm index 2970d7ef8..9f5c2d90b 100644 --- a/src/centreon/plugins/mode.pm +++ b/src/centreon/plugins/mode.pm @@ -28,7 +28,6 @@ sub new { my ($class, %options) = @_; my $self = {}; bless $self, $class; - $self->{perfdata} = centreon::plugins::perfdata->new(output => $options{output}); %{$self->{option_results}} = (); @@ -45,7 +44,6 @@ sub new { sub init { my ($self, %options) = @_; # options{default} = { mode_xxx => { option_name => option_value }, } - %{$self->{option_results}} = %{$options{option_results}}; # Manage default value return if (!defined($options{default})); diff --git a/src/cloud/azure/custom/api.pm b/src/cloud/azure/custom/api.pm index e8cc7d64c..ac3fa02ff 100644 --- a/src/cloud/azure/custom/api.pm +++ b/src/cloud/azure/custom/api.pm @@ -930,7 +930,7 @@ sub azure_get_usagedetails_set_url { my $url = $self->{management_endpoint} . "/subscriptions/" . $self->{subscription}; $url .= "/resourceGroups/" . $options{resource_group} if (defined($options{resource_group}) && $options{resource_group} ne ''); $url .= "/providers/Microsoft.Consumption/usageDetails?\$filter=properties%2FusageStart ge %27" . $options{usage_start} . "%27 and properties%2FusageEnd le %27" . $options{usage_end} . "%27"; - $url .= "&metric=actualcost"; + $url .= "&metric=". ($options{cost_metric} || 'actualcost'); $url .= "&api-version=" . $self->{api_version}; return $url; } @@ -1261,7 +1261,7 @@ The application needs the 'Monitoring Reader' role (see https://docs.microsoft.c This custom mode is using the 'OAuth 2.0 Client Credentials Grant Flow' -For further informations, visit https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow +For further information, visit https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow =over 8 @@ -1295,7 +1295,7 @@ Set timeframe in seconds (i.e. 3600 to check last hour). =item B<--interval> -Set interval of the metric query (can be : PT1M, PT5M, PT15M, PT30M, PT1H, PT6H, PT12H, PT24H). +Set interval of the metric query (can be : C, C, C, C, C, C, C, C). =item B<--aggregation> diff --git a/src/cloud/azure/management/costs/mode/budgets.pm b/src/cloud/azure/management/costs/mode/budgets.pm index f29c10d37..8c38af8c8 100644 --- a/src/cloud/azure/management/costs/mode/budgets.pm +++ b/src/cloud/azure/management/costs/mode/budgets.pm @@ -113,6 +113,7 @@ sub new { "lookup-days:s" => { name => 'lookup_days', default => 30 }, "units:s" => { name => 'units', default => '%' }, "timeout:s" => { name => 'timeout', default => '60' }, + "cost-metric:s" => { name => "cost_metric", default => 'actualcost' } }); return $self; @@ -127,6 +128,12 @@ sub check_options { $self->{output}->option_exit(); } + $self->{option_results}->{cost_metric} = lc($self->{option_results}->{cost_metric}); + if ($self->{option_results}->{cost_metric} !~ /^(actualcost|amortized)$/) { + $self->{output}->add_option_msg(short_msg => "Invalid cost metric '" . $self->{option_results}->{cost_metric} . "'. Valid values are 'actualcost' or 'amortized'."); + $self->{output}->option_exit(); + } + $self->{lookup_days} = $self->{option_results}->{lookup_days}; } @@ -143,7 +150,8 @@ sub manage_selection { my $costs = $options{custom}->azure_get_usagedetails( resource_group => $self->{option_results}->{resource_group}, usage_start => $usage_start, - usage_end => $usage_end + usage_end => $usage_end, + cost_metric => $self->{option_results}->{cost_metric}, ); my $cost = 0; @@ -183,7 +191,7 @@ perl centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --cust You should NOT execute the plugin for a given subscription/resource group more than once a day otherwise, you might reach the Azure API calls limit if you have many. -For subscription with large ressource with usagedetail consumption that might requite many API calls, +For subscription with large resources and detailed usage consumption that might require many API calls, you may have to increase timeout. =over 8 @@ -209,8 +217,13 @@ Set warning threshold for cost). Define the conditions to match for the status to be CRITICAL. =item B<--units> + Unit of thresholds (default: '%') ('%', 'count'). +=item B<--cost-metric> + +Choose the cost metric to use (default: C) (C, C). + =back =cut diff --git a/tests/resources/spellcheck/stopwords.txt b/tests/resources/spellcheck/stopwords.txt index 1a9ed2e6c..27c11eaad 100644 --- a/tests/resources/spellcheck/stopwords.txt +++ b/tests/resources/spellcheck/stopwords.txt @@ -203,6 +203,7 @@ NTLMv2 NTP NVOS --oid +OAuth OID --oid-display --oid-extra-display