Translate

vrijdag 17 april 2015

Extract VM details from your XenServer pool

I've been searching for a while to get the VM details like CPU/RAM/Storage from a XenServer pool....

Thanks to my collegue Daniel Zwart we have created a script that will do the trick.

See below for the script:

#!/bin/sh
IFS=$','
vmuuidlist=$(xe vm-list params=uuid is-control-domain=false is-a-snapshot=false power-state=running --minimal)
poolname=$(xe pool-list params=name-label --minimal)
echo VMName,Pool,Host,vCPUs,RAM,Storage,Description > $poolname-vminfo.csv

for vmuuid in $vmuuidlist ; do
    vmname=$(xe vm-list params=name-label uuid=$vmuuid --minimal)
    hostuuid=$(xe vm-list params=resident-on uuid=$vmuuid --minimal)
    vmdescription=$(xe vm-list params=name-description uuid=$vmuuid --minimal)
    hostname=$(xe host-list params=name-label uuid=$hostuuid --minimal)
    vcpus=$(xe vm-list params=VCPUs-number uuid=$vmuuid --minimal)
    ram=$(xe vm-list params=memory-static-max uuid=$vmuuid --minimal)
    vdiuuidlist=$(xe vbd-list vm-uuid=$vmuuid type=Disk params=vdi-uuid --minimal)
    for vdiuuid in $vdiuuidlist ; do
        vdisize=$(xe vdi-list uuid=$vdiuuid params=virtual-size --minimal)
        totalsize=$((totalsize+vdisize))
    done
    totalsize=$((totalsize/1024/1024/1024))
    vmram=$((ram/1024/1024/1024))
    echo $vmname,$poolname,$hostname,$vcpus,$vmram,$totalsize,$vmdescription
done >> $poolname-vminfo.csv

Copy this text to notepad, save it as details.sh or whatever kinda name you want it to. Copy it with WinSCP to your XenServer.

Then issue the command chmod +x details.sh so you can use it.

To verify it has added the 'x' use ls -l

Setup a putty or kitty session to your XenServer, to run the script ./details.sh

The details are added in the CSV, you can copy the CSV with WinSCP, you probably have to refresh the screen before it's visible if you didn't close the earlier made session.

If you open up the file in Excel select the first row > data > text to column > next > select comma > next... Finish.

Geen opmerkingen:

Een reactie posten