centreon-plugins
centreon-plugins copied to clipboard
3 new modes to Azure/Management/Costs plugin
Description
PLEASE MAKE SURE THAT THE BRANCH PR INCLUDES JIRA TICKET ID (for centreon-internal)
Please include a short resume of the changes and what is the purpose of PR. Any relevant information should be added to help:
- QA Team (Quality Assurance) with tests.
- reviewers to understand what are the stakes of the pull request.
Fixes # (issue)
Type of change
- [ ] Patch fixing an issue (non-breaking change)
- [X] New functionality (non-breaking change)
- [ ] Breaking change (patch or feature) that might cause side effects breaking part of the Software
Target serie
- [X] 21.04.x
- [X] 21.10.x
- [X] 22.04.x
- [X] 22.10.x (master)
How this pull request can be tested ?
Please describe the procedure to verify that the goal of the PR is matched. Provide clear instructions so that it can be correctly tested.
New modes for the Azure "costs" plugin:
- Mode to identify orphan ressources like snapshots, managed disks, NICs, NSGs, public IPs, route tables
- Mode to identify ressources with Hybrid Benefits not enabled (VMs, SQL VMs, SQL Database, SQL Elastic Pools)
- Mode to check the presence of a tag on a particular type of ressource (VMs only for now but other type might be added in the future). This is useful to be sure that VMs have a start/stop tag for exemple.
Note that for orphan and hybrid-benefits modes, there are call to several rest API that have incompatible api-version between them so it's not possible to use the global variable api-version give in parameter. That's why i proposed a way to override the API version on some functions on the custom/api.pm file.
Note2: i also updated some functions on the custom/api.pm file to use the nextlink the 1 API call is not enough (that occurs if many objects are returned).
Checklist
Orphan Resources:
/usr/lib/centreon/plugins/centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --custommode='api' --mode='orphan-resource' --subscription='xxxx' --tenant='xxxx' --client-id='xxxx' --client-secret='xxxx' CRITICAL: Found 1 orphan snapshot(s) ( OSdiskxxxx ) No orphan managed disk found on 70 total disk(s) No orphan NIC found on 50 total NIC(s) No orphan NSG found on 6 total NSG(s) No orphan public IP found on 1 total public IP(s) No orphan route table found on 12 total route table(s)
/usr/lib/centreon/plugins/centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --custommode='api' --mode='orphan-resource' --subscription='xxxx' --tenant='xxxx' --client-id='xxxx' --client-secret='xxxx' --no-snapshots OK: No orphan resource found No orphan managed disk found on 70 total disk(s) No orphan NIC found on 50 total NIC(s) No orphan NSG found on 6 total NSG(s) No orphan public IP found on 1 total public IP(s) No orphan route table found on 12 total route table(s)
/usr/lib/centreon/plugins/centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --custommode='api' --mode='orphan-resource' --subscription='xxxx' --tenant='xxxx' --client-id='xxxx' --client-secret='xxxx' --exclude-name='OSdisk' OK: No orphan resource found No orphan managed disk found on 70 total disk(s) No orphan NIC found on 50 total NIC(s) No orphan NSG found on 6 total NSG(s) No orphan public IP found on 1 total public IP(s) No orphan route table found on 12 total route table(s) No orphan snapshot found on 1 total snapshot(s)
Hybrid Benefits:
/usr/lib/centreon/plugins/centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --custommode='api' --mode='hybrid-benefits' --subscription='xxxx' --tenant='xxxx' --client-id='xxxx' --client-secret='xxxx' CRITICAL: Found 2 SQL database(s) with SqlDatabaseHybridBenefits not enabled ( sqldb-xxxx sqldb-yyyyy ) VmHybridBenefits is enabled on all 11 VM(s) SqlVmHybridBenefits is enabled on all 3 SQL VM(s)
/usr/lib/centreon/plugins/centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --custommode='api' --mode='hybrid-benefits' --subscription='xxxx' --tenant='xxxx' --client-id='xxxx' --client-secret='xxxx' --no-sql-database-hybrid-benefits OK: Everything is OK VmHybridBenefits is enabled on all 11 VM(s) SqlVmHybridBenefits is enabled on all 3 SQL VM(s) SqlElasticPoolHybridBenefits is enabled on all 0 eligible SQL elastic pool(s)
/usr/lib/centreon/plugins/centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --custommode='api' --mode='hybrid-benefits' --subscription='xxxx' --tenant='xxxx' --client-id='xxxx' --client-secret='xxxx' --exclude-name='sqldb-.*' OK: Everything is OK VmHybridBenefits is enabled on all 11 VM(s) SqlVmHybridBenefits is enabled on all 3 SQL VM(s) SqlDatabaseHybridBenefits is enabled on all 2 eligible SQL database(s) SqlElasticPoolHybridBenefits is enabled on all 0 eligible SQL elastic pool(s)
Tags:
/usr/lib/centreon/plugins//centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --custommode='api' --mode='tag-on-resources' --subscription='xxxx' --tenant='xxxx' --client-id='xxxx' --client-secret='xxxx' --vms --tag-name='startstoptag' --api-version='2022-08-01' CRITICAL: Found 3 VM(s) with no startstoptag tag ( vm1 vm2 vm3 )
/usr/lib/centreon/plugins//centreon-plugins/centreon_plugins.pl --plugin=cloud::azure::management::costs::plugin --custommode='api' --mode='tag-on-resources' --subscription='xxxx' --tenant='xxxx' --client-id='xxxx' --client-secret='xxxx' --vms --tag-name='startstoptag' --api-version='2022-08-01' --exclude-name='vm.*' OK: Everything is OK All 12 VM(s) have a startstoptag tag
Community contributors & Centreon team
- [X] I have followed the coding style guidelines provided by Centreon
- [X] I have commented my code, especially new classes, functions or any legacy code modified. (docblock)
- [X] I have commented my code, especially hard-to-understand areas of the PR.
- [X] I have rebased my development branch on the base branch (master, maintenance).
Hi @matoy ,
Thanks, I will review this next week once the release is done (happening this Tuesday). Will keep you posted.
Best
I will really check this now 😅
Btw, you can follow up on my work and test from this branch: https://github.com/centreon/centreon-plugins/tree/MON-15596-extend-azure-management-costs-%23finops-community-review-packaging-
thank you for your comments i modified my branch and yours.
Replaced by https://github.com/centreon/centreon-plugins/pull/4019
Thx