WENDELMATTOSICLOUD / vmbix

Automatically exported from code.google.com/p/vmbix
0 stars 0 forks source link

CPU hz total doesn't account for multiple cores assinged to VM #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The CPU hz total for the vm and ESX templates don't show the true total CPU. It 
seems that it only shows a the speed of a single core. This isn't a problem on 
the ESX template because the CPU load takes into account the number of cores, 
but the VM template doesn't. So when you have a VM with multiple cores assigned 
to it the CPU load calculation is off.

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
VMBIX 1.01 on RHEL 6 64bit with Zabbix 1.8.5

Please provide any additional information below.

Original issue reported on code.google.com by badger.s...@gmail.com on 7 Mar 2012 at 1:04

GoogleCodeExporter commented 8 years ago
Just make yourself a new Calculated Key that multiplies number of cores key and 
total Hz key. Something like this:

last("esx.cpu.load[{HOST.DNS},cores]") * last("esx.cpu.load[{HOST.DNS},total]")

Make a new unique key and save it. Simple as that.

Original comment by michal.b...@gmail.com on 6 Sep 2012 at 6:54

GoogleCodeExporter commented 8 years ago
This calculation only works for ESX servers and not for the virtual machine.
It is necessary to return an item that the quantity of cores for virtual 
machine.

Original comment by rafael.i...@gmail.com on 6 Sep 2012 at 3:34

GoogleCodeExporter commented 8 years ago
Add the following code to vmbix.java which will create a new item 
vm.cpu.load[{HOST.DNS},count] which will return the number of cores allocated 
to the VM

Pattern pVmCpuCount             = 
Pattern.compile("^(?:\\s*ZBXD.)?.*vm\\.cpu\\.load\\[(.+),count\\]"             
);
.
.
found = checkPattern(pVmCpuCount            ,string); if (found != null) { 
getVmCpuCount            (found, out); return; }
.
.
private void getVmCpuCount                   (String vmName,   PrintWriter out) 
throws IOException {
    long start = System.currentTimeMillis();
    VirtualMachine vm = (VirtualMachine)getManagedEntityByName(vmName,"VirtualMachine");
    Integer amount;
    if (vm == null) {
        long end = System.currentTimeMillis();
        System.out.print("No vm named '" + vmName + "' found\n");
        amount = 0;
    } else {
        VirtualMachineSummary vmSummary = vm.getSummary();
        VirtualMachineConfigSummary vmConfigSum = vmSummary.getConfig();
        amount = vmConfigSum.getNumCpu();
        if (amount == null) { amount = 0; }
        long end = System.currentTimeMillis();
    }
    out.print(amount + "\n");
    out.flush();
}

Original comment by palin...@gmail.com on 14 May 2013 at 3:00