Hi,
First of all, thank you very much for the help
I am developing a new integration with proxox.
I have taken the data from the VMs and I want it to have rule to define the status of OK, WARN, CRIT… according to the state of the machine.
I know that the problem is with the integration with the rule because if I leave it without the integration everything seems to go correctly.
The error is when I do a service discovery:
Well, this is the definition of the rule:
(I don’t pass the whole function as the above is “nonsense”)
elements={
"powered_on": DictElement(
parameter_form = ServiceState(
title = Title("Powered ON"),
prefill=DefaultValue(ServiceState.OK),
help_text = Help(
"Check result if the VM is powered on"
),
),
),
"powered_off": DictElement(
parameter_form = ServiceState(
title = Title("Powered OFF"),
prefill=DefaultValue(ServiceState.WARN),
help_text = Help(
"Check result if the VM is powered off"
),
),
),
"unknown": DictElement(
parameter_form = ServiceState(
title = Title("Powered OFF"),
prefill=DefaultValue(ServiceState.UNKNOWN),
help_text = Help(
"Check result if the VM is powered off"
),
),
),
}
this is the check function of the vm:
def check_proxmoxve_qemu(item, params, section):
data = section.get(item)
if data is None:
yield Result(
state=params["unknown"],
summary=f"VM with ID {item} no longer exists"
)
return
qemu_state = data['State']
qemu_name = data['VM Name']
if qemu_state == "running":
state_code = params["powered_on"]
elif qemu_state == "stopped":
state_code = params["powered_off"]
else:
state_code = params["unknown"]
yield Result(
state = state_code,
summary = f"{qemu_name} is {qemu_state}"
)
and the Check Plugin function:
check_plugin_ometemp = CheckPlugin(
name = "proxmoxve_qemu",
service_name = "VM %s",
discovery_function = discover_proxmoxve_qemu,
check_function = check_proxmoxve_qemu,
check_default_parameters = {
"powered_on": State.OK,
"powered_off": State.WARN,
"unknown": State.UNKNOWN
},
check_ruleset_name = "proxmoxve_qemu",
)