proxmox api

nadir.latif

New Member
Nov 4, 2012
18
0
1
Hello. we need to monitor the resource usage on our vms. we are using proxmox api for this purpose. we are using the get_vm_list() function for getting the list of all vms on our server. an example of the return value of the function is:

Array
(
[diskread] => 0
[netin] => 1481673109
[cpu] => 0.042529058080306
[disk] => 0
[status] => running
[name] => czech.search.bipmedia.com
[netout] => 2240325794
[maxdisk] => 0
[maxmem] => 1073741824
[pid] => 2665
[diskwrite] => 0
[uptime] => 128257
[mem] => 685132929
[vmid] => 203
[cpus] => 4
)

the problem is that the function always returns value of 0 for 'disk'. in most but not all cases the value of 'maxdisk' is 0. can it be a bug in the proxmox api?. Thanks.

Nadir Latif
 
Does it help if you run

# qm rescan

Hi dietmar,

Thanks for your answer

Seems to work when using pvesh on the hypervisor, still not working with an http get on /api2/json/cluster/resources :-)
 
That use exactly the same code, so if it works with pvesh, it works also with http get.

That's what I thought!

Arf, I was looking the output for openvz containers, i've forgotten that the issue only concerns KVM, my fault :(

{
"cpu" : 0.124700074594732,
"disk" : 0,
"diskread" : 59766837055534,
"diskwrite" : 1115200129024,
"id" : "qemu/105",
"maxcpu" : 4,
"maxdisk" : 0,
"maxmem" : 12884901888,
"mem" : 12161606317,
"name" : "vm-dev",
"netin" : 44722277038,
"netout" : 35890992309,
"node" : "vm2-dev",
"type" : "qemu",
"uptime" : 1025185,
"vmid" : 105
}

I've talked to other Proxmox users, they have the same issue with Proxmox 2.2

Thank you in advance
 
Please can you also port the corresponding VM config?

Some examples:

---------------KVM Using ide0
pvesh get /cluster/resources
{
"cpu" : 0.0326173724489405,
"disk" : 0,
"diskread" : 7507189248,
"diskwrite" : 7133299200,
"id" : "qemu/108",
"maxcpu" : 2,
"maxdisk" : 0,
"maxmem" : 2147483648,
"mem" : 1877267237,
"name" : "tfwin1",
"netin" : 2026205984,
"netout" : 62704208,
"node" : "vm9-dev",
"type" : "qemu",
"uptime" : 275272,
"vmid" : 108
},

108.conf

bootdisk: ide0
cores: 2
ide0: vm2-kvm-storage1:vm-108-disk-1
memory: 2048
name: tfwin1
net0: rtl8139=76:42:F0:65:AD:74,bridge=vmbr910
ostype: win7
sockets: 1

---------------

---------------KVM Using virtio0
{
"cpu" : 0.00592370736003072,
"disk" : 0,
"diskread" : 590540800,
"diskwrite" : 1585611776,
"id" : "qemu/102",
"maxcpu" : 2,
"maxdisk" : 0,
"maxmem" : 2147483648,
"mem" : 1392262938,
"name" : "tflinux1",
"netin" : 1785301729,
"netout" : 53086506,
"node" : "vm9-dev",
"type" : "qemu",
"uptime" : 276610,
"vmid" : 102
},

102.conf

bootdisk: virtio0
cores: 2
memory: 2048
name: tflinux1
net0: rtl8139=8A:1F:9A:F3:A0:6F,bridge=vmbr910
ostype: l26
sockets: 1
virtio0: vm2-kvm-storage1:vm-102-disk-1
---------------

---------------The storage
{
"disk" : 993151983616,
"id" : "storage/vm2-dev/kvmstorage",
"maxdisk" : 1387825668096,
"node" : "vm2-dev",
"storage" : "kvmstorage",
"type" : "storage"
},
 
Size hints are still missing in the VM config. You need to run

# qm rescan

Hi,

It has updated only the maxdisk, disk is still at 0


{
"cpu" : 0.00298722721745542,
"disk" : 0,
"diskread" : 555225206,
"diskwrite" : 1781748736,
"id" : "qemu/112",
"maxcpu" : 1,
"maxdisk" : 34359738368,
"maxmem" : 2147483648,
"mem" : 901694445,
"name" : "graphite-dev",
"netin" : 53222407,
"netout" : 6677193,
"node" : "vm5-dev",
"type" : "qemu",
"uptime" : 1386840,
"vmid" : 112
},

112.conf

bootdisk: virtio0
cores: 1
ide2: share-storage1:iso/ubuntu-12.04-desktop-amd64.iso,media=cdrom
memory: 2048
name: graphite-dev
net0: rtl8139=16:D5:97:D7:C7:03,bridge=vmbr931
ostype: l26
sockets: 1
virtio0: kvmstorage:112/vm-112-disk-1.qcow2,size=32G
 
I have the exact same problem. I'm using LVM on ISCSI (shared)

root@proxmox1:~# qm rescan
root@proxmox1:~# pvesh get /nodes/proxmox2/qemu/100/status/current
{
"cpu" : 0,
"cpus" : 1,
"disk" : 0,
"diskread" : 208896,
"diskwrite" : 163840,
"ha" : 0,
"maxdisk" : 10737418240,
"maxmem" : 536870912,
"mem" : 128070795,
"name" : "VM 100",
"netin" : 0,
"netout" : 0,
"pid" : "1877",
"qmpstatus" : "running",
"status" : "running",
"uptime" : 3103
}
200 OK

root@proxmox2:/etc/pve/qemu-server# cat 100.conf
bootdisk: virtio0
cores: 1
memory: 512
net0: rtl8139=6A:28:C2:78:F5:B5
ostype: l26
sockets: 1
virtio0: sharedlvm0:vm-100-disk-1,size=10G
 
It has updated only the maxdisk, disk is still at 0

That is expected behavior. We currently do not run a guest-agent, so we don't have any information about used
space from the guest. But this is a planned feature for the future.
 
As we are now in the future, any sign of this functionality coming soon? ;)

I notice that the usage can be found in lvs say, so although I appreciate the guest-agent is the right way to do it, perhaps in the short term for LVM disks it can be picked up directly?
 
  • Like
Reactions: eill and DerDanilo
while the guest agent can show information about the disks now, it is non trivial to map that to a specific disk in the config (raid/partitions/etc)

what you can do is using the guest agent api yourself: https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/agent/get-fsinfo
this will return json from the guest agent (if its installed and new enough version)