Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for excluding/ignoring VMs by Folder Managed Object ID (MOID) #809

Closed
4 of 5 tasks
atc0005 opened this issue May 25, 2023 · 3 comments · Fixed by #907
Closed
4 of 5 tasks

Add support for excluding/ignoring VMs by Folder Managed Object ID (MOID) #809

atc0005 opened this issue May 25, 2023 · 3 comments · Fixed by #907
Assignees
Labels
config contrib documentation Improvements or additions to documentation enhancement New feature or request folder virtual machine
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented May 25, 2023

Overview

Ran into a situation where I needed to filter VMs by Folder name.

Ran into a situation where I needed to filter VMs by a specific Folder. While we could attempt to match a name, we could easily run into a situation where the same name is used in multiple places all visible to the same service account. Due to this and because the vSphere Client (web) exposes Folder Managed Object ID (MOID) values in the URL we can offer support for filtering by Folder MOID values instead.

This could be used in the same way that excluding/including resource pools are currently supported.

TODO

  • contrib file updates
  • plugin documentation refresh
    • add metric descriptions
    • add coverage for new metrics
    • add coverage for new flags

References

@atc0005 atc0005 added documentation Improvements or additions to documentation enhancement New feature or request config virtual machine contrib labels May 25, 2023
@atc0005 atc0005 added this to the Future milestone May 25, 2023
@atc0005 atc0005 self-assigned this May 25, 2023
@atc0005 atc0005 pinned this issue May 25, 2023
@atc0005 atc0005 changed the title Add support for excluding/ignoring VMs by folder name Add support for excluding/ignoring VMs by Folder Managed Object ID (MOID) Jul 26, 2023
@atc0005
Copy link
Owner Author

atc0005 commented Jul 26, 2023

After giving this some thought, it's probably not a good idea to try to match on a Folder name. Instead, we should filter by a Folder MOID value as we can be reasonably confident that we'll be dealing with a single valid match (vs names which could be reused in different Folder hierarchies).

@atc0005
Copy link
Owner Author

atc0005 commented Jul 26, 2023

Worth noting (from https://vdc-repo.vmware.com/vmwb-repository/dcr-public/97e6db01-d441-472e-ad53-b48c2bb0e1e4/45347fb1-052d-44b7-b3e9-cbefc34488e3/SDK/vsphere-ws/docs/ReferenceGuide/vim.Folder.html):

A folder can contain child objects of type ChildType. Virtual machine and network entity folders can also contain additional object types. The root folder is a data center folder.

@atc0005
Copy link
Owner Author

atc0005 commented Aug 5, 2023

The initial implementation of this feature is complete and applicable plugins have been updated to use the new support:

  • check_vmware_disk_consolidation
  • check_vmware_hs2ds2vms
  • check_vmware_question
  • check_vmware_rps_memory
  • check_vmware_snapshots_age
  • check_vmware_snapshots_count
  • check_vmware_snapshots_size
  • check_vmware_tools
  • check_vmware_vcpus
  • check_vmware_vhw
  • check_vmware_vm_backup_via_ca
  • check_vmware_vm_list
  • check_vmware_vm_power_uptime

Will test for a bit to make sure nothing obvious is busted before cleaning up/merging to development and cutting a pre-release. Aiming for next week.

@atc0005 atc0005 added the folder label Aug 5, 2023
atc0005 added a commit that referenced this issue Aug 10, 2023
Update these plugins (and supporting code):

- check_vmware_disk_consolidation
- check_vmware_hs2ds2vms
- check_vmware_power_uptime
- check_vmware_question
- check_vmware_rps_memory
- check_vmware_snapshots_age
- check_vmware_snapshots_count
- check_vmware_snapshots_size
- check_vmware_tools
- check_vmware_vcpus
- check_vmware_vhw
- check_vmware_vm_backup_via_ca
- check_vmware_vm_list

with these changes:

- provide new flags to explicitly include/exclude virtual machines by given
  folder Managed Object IDs (MOIDs)
  - NOTE: these flags are *not* provided for the `check_vmware_rps_memory`
    plugin, but the metrics related to folders are listed due to the use of
    shared metrics logic
- refactoring
  - rework virtual machine filtering logic to more easily support existing
    filtering support alongside adding further options
  - use common report "trailer" to provide consistent values/formatting for
    plugins providing support for filtering and reporting metrics for virtual
    machines
  - use VMsFilterOptions and VMsFilterResults types to simplify argument
    handling and provide consistent
  - split datastore performance configuration handling into separate file
- documentation updates
  - provided detailed explanation of provided metrics
  - add coverage for new metrics

References:

- GH-809
- GH-852
@atc0005 atc0005 added folder and removed folder labels Aug 10, 2023
atc0005 added a commit that referenced this issue Aug 11, 2023
Convert remaining plugin doc metric lists to tables and fill
with metric descriptions.

This commit also removes a metrics list left behind in one of
the plugin docs from previous conversion work.

refs GH-809
atc0005 added a commit that referenced this issue Aug 16, 2023
Update these plugins (and supporting code):

- check_vmware_disk_consolidation
- check_vmware_hs2ds2vms
- check_vmware_power_uptime
- check_vmware_question
- check_vmware_rps_memory
- check_vmware_snapshots_age
- check_vmware_snapshots_count
- check_vmware_snapshots_size
- check_vmware_tools
- check_vmware_vcpus
- check_vmware_vhw
- check_vmware_vm_backup_via_ca
- check_vmware_vm_list

with these changes:

- provide new flags to explicitly include/exclude virtual machines by given
  folder Managed Object IDs (MOIDs)
  - NOTE: these flags are *not* provided for the `check_vmware_rps_memory`
    plugin, but the metrics related to folders are listed due to the use of
    shared metrics logic
- refactoring
  - rework virtual machine filtering logic to more easily support existing
    filtering support alongside adding further options
  - use common report "trailer" to provide consistent values/formatting for
    plugins providing support for filtering and reporting metrics for virtual
    machines
  - use VMsFilterOptions and VMsFilterResults types to simplify argument
    handling and provide consistent
  - split datastore performance configuration handling into separate file
- documentation updates
  - provided detailed explanation of provided metrics
  - add coverage for new metrics

References:

- GH-809
- GH-852
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config contrib documentation Improvements or additions to documentation enhancement New feature or request folder virtual machine
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant