Check_pve.py - Multiple VM´s


#1

Hi there,
i just added sucessfully the check_pve.py by nbuchwitz to my distributet icinga2 setup, but im wondering which kind of syntax var definition is right to get all vms checked.

PVE host object (vars.pve_resource_name = “VMname”)

object Host “server.domain.tld” {
import “proxmox-host”

address = “23.5.42.23”

vars.owner = “deepthought*”

vars.pve_resource_name = “VMname”

vars.pve_storage[“Backup”] = {
pve_unit = “%”
pve_warning = 80
pve_critical = 90
}

vars.pve_storage[“local”] = {
pve_unit = “%”
pve_warning = 80
pve_critical = 90
}

// Ignore these disks in health check (USB sticks, SD cards, etc.)
vars.pve_ignore_disks = [ “sdn”, “sdg” ]
}

In this case i only get the data of the VM named “VMname” in this example. Is there a way to automatic check all active VM´s?
Or just manually add the, but how without overwriting itself?

If anybody is @ 35C3 with the right hint, i`ll get u a Flora/Club mate or tschunk if u like - just call DECT 7823 :slight_smile:


(Aflatto) #2

You’ll need to write an apply rule that uses this definition as the conditional, some thing like

assign where host.vars.pve_resource_name = true


(Nicolai) #3

If you’re using the director, you could use the icingaweb2-module-pve for importing all VMs and create VM checks based on a sync rule. Without the director there are several possibilities:

Hostname matches the VM name

Create a Host template and set vars.pve_resource_name = host.name

OR

Rreate a custom check command which does the assingnment.

Create a service apply rule as mentioned above.

Other naming schema

Append the custom var vars.pve_resource_name to all of your VMs and fill with the internal VM name and create a service apply rule as mentioned above.

OR

Create a dictionary inside your PVE definition which holds all your VM names and iterate which an apply rule.


#4

Happy New Year & thanks for the all reply & and all the possibil ways to do it :smiley:

Now it`s time to set it up =)