Hello!
I'm trying to sum up all my running Hyper-V virtual machines.
Have original item linked to "Windows by Zabbix agent"-template with the following info:
Name: Number of virtual machines
Type: Zabbix Agent
Key: wmi.getall[root\cimv2,"Select Name from Win32_PerfFormattedData_BalancerStats_HyperVDynami cMemoryVM"]
Type of information: Text
This returns a JSON-array with all the names of the machines, and i use preprocessing to count the machines.
This short JavaScript code:
Code:
const data = JSON.parse(value);
var length = 0;
for (var k in data)
if (data.hasOwnProperty(k))
length++;
return length;
The problem is when I'm trying to sum up all the running VM's in one item with the "Calculated item"-item.
Zabbix documentation for 6.4 states that this is the correct way to use aggregate functions:
aggregate_function(foreach_function(/host/key?[group="host group"],timeperiod))
I have created a new host named Aggregate Checks (with Zabbix-agent as agent-type and address 127.0.0.1) and created a new "Calculated Item" with the following settings:
Name: Sum of all virtual machines
Key: wmisumallvms
Type of information: Text
Formula: sum(last_foreach(/*/wmi.getall[root\cimv2,"Select Name from Win32_PerfFormattedData_BalancerStats_HyperVDynami cMemoryVM"]?[group="Hypervisors"]))
This returns the following error:
Cannot evaluate expression: no input data for function at "sum(last_foreach(/*/wmi.getall[root\cimv2,"Select Name from Win32_PerfFormattedData_BalancerStats_HyperVDynami cMemoryVM"]?[group="Hypervisors"]))"
I have also tried to create the item in the "Windows by Zabbix agent"-template, which throws the same error.
Maybe someone here has been through the same process as me, and can shed some light on it.
Hagle
For less hurt, I would set default to "last"..
but I really cannot tell right now, what goes on there...
Comment