Table of Contents
Check OpenNebula virtual machines
Script: check_onevm
check_onevm is a plugin to show count of vms in OpenNebula - listed by state and by host.
The version 1.4 identifies these status values:
- back:Backup:The VM backup is in progress
- boot:Boot:OpenNebula is waiting for the hypervisor to create the VM.
- clea:Cleanup-resubmit:The VM is waiting for the drivers to clean the host after a onevm recover –recreate action
- clon:Cloning:The VM is waiting for one or more disk images to finish the initial copy to the repository (image state still in lock)
- done:Done:The VM is done. VMs in this state won’t be shown with onevm list but are kept in the database for accounting purposes. You can still get their information with the onevm show command.
- drsz:Disk Resize:The VM disk resize is in progress
- epil:Epilog:In this phase the system cleans up the Host used to virtualize the VM, and additionally disk images to be saved are copied back to the system datastore.
- fail:Failed:The VM failed.
- hold:Hold:The owner has held the VM and it will not be scheduled until it is released. It can be, however, deployed manually.
- hotp:Hotplug:A disk attach/detach, nic attach/detach operation is in process.
- migr:Migrate:The VM is migrating from one resource to another. This can be a life migration or cold migration (the VM is saved, powered-off or powered-off hard and VM files are transferred to the new resource).
- pend:Pending:By default a VM starts in the pending state, waiting for a resource to run on. It will stay in this state until the scheduler decides to deploy it, or the user deploys it using the onevm deploy command.
- poff:PowerOff:Same as suspended, but no checkpoint file is generated. Note that the files are left in the host to later boot the VM there. When the VM guest is shutdown, OpenNebula will put the VM in this state.
- prol:Prolog:The system is transferring the VM files (disk images and the recovery file) to the host in which the virtual machine will be running.
- rest:Restore:The VM disks are restored from backup image
- runn:Running:The VM is running (note that this stage includes the internal virtualized machine booting and shutting down phases). In this state, the virtualization driver will periodically monitor it.
- save:Save:The system is saving the VM files after a migration, stop or suspend operation.
- shut:Shutdown:OpenNebula has sent the VM the shutdown ACPI signal, and is waiting for it to complete the shutdown process. If after a timeout period the VM does not disappear, OpenNebula will assume that the guest OS ignored the ACPI signal and the VM state will be changed to running, instead of done.
- snap:Snapshot:A system snapshot is being taken.
- stop:Stopped:The VM is stopped. VM state has been saved and it has been transferred back along with the disk images to the system datastore.
- susp:Suspended:Same as stopped, but the files are left in the host to later resume the VM there (i.e. there is no need to re-schedule the VM).
- unde:Undeployed:The VM is shut down. The VM disks are transferred to the system datastore. The VM can be resumed ater.
- unkn:Unknown:The VM couldn’t be reached, it is in an unknown state.
See https://docs.opennebula.io/6.10/management_and_operations/vm_management/vm_instances.html
It counts:
- all vms
- running vms
- failed vms
- unknown status
- all other
It returns the status
- OK: all found vms have the state running
- Warning:
- not all VMs are running
- Status “unknown” was found
- Critical: a failed vm was found
Requirements
The icinga user needs sudo permissions on onevm
.
icingaclient ALL=(ALL) NOPASSWD: /bin/onevm
Standalone installation
From this repository ypu need next to this script:
-
inc_pluginfunctions
shared function for all IML checks written in bash
Syntax
$ check_onevm
(without parameters)
Parameters
./check_onevm -h
______________________________________________________________________
CHECK_ONEVM
v1.4
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_onevm.html
______________________________________________________________________
Show count of vms in OpenNebula - listed by state and by host.
It will go to warning if a non running state was found.
It will go to critical if a vm is on failure.
SYNTAX:
check_onevm
-h or --help show this help.
PARAMETERS:
None.
Examples
Without parameter:
./check_onevm
OK: OpenNebula VMs - Total: 32 .. running: 32 .. other: 0
>>>>>> By state
--- Running (runn): 32
The VM is running (note that this stage includes the internal virtualized machine booting and shutting down phases). In this state, the virtualization driver will periodically monitor it.
>>>>>> By host:
--- kvm1.ecample.com: 8
--- kvm2.ecample.com: 6
--- kvm3.ecample.com: 8
--- kvm4.ecample.com: 5
--- kvm5.ecample.com: 5
|total=32;; running=32;; fail=0;; unknown=0;; other=0;;
If no vm was created yet the result is OK.
/check_onevm
OK: OpenNebula VMs - Total: 0 .. running: 0, Fail: 0, unknown: 0 .. other: 0
Info: no vm was created yet.
|total=0;; running=0;; fail=0;; unknown=0;; other=0;; root@admin:one plugins#