ESXi filesystem disk usage script

So what if you would like to get a report on filesystem disk usage on esxi box. For now afaik there is no cmdlet in powercli that could do that for us. So in order to get this data you can use plink to invoke command remotely via ssh

Frist, download plink.exe from putty website.

In this example i put plink.exe on c:\ drive

$str1=’c:\plink.exe -v -pw ”v53HYfsd#$%$%^^&*” -l root ‘
$str2=’ df -h’
$outfile=’c:\fsusage.csv’
“Host Size Used Avail Use Mounted” >> $outfile
foreach($esxentry in (Get-VMHost|?{$_.Powerstate -eq “PoweredOn”})){
$esxhost=”‘”+$esxentry.name+”‘”
$command=$str1+$esxhost+$str2
$esxentry.name >> $outfile
$result=Invoke-Expression -Command $command
foreach($resultline in 1..$result.length){
$result[$resultline] >> $outfile
}
}

So, assuming you will have plink on c:\ and you will be in powercli session while connected to VC server, you can just copy/paste those lines and you will receive csv ready file in $outfile location. After this go to excel and do Data->import from text-> Select “space” as delimeter, and you are don. After that you can also select the USE column, and do conditional formatting for example.

If you want to make report for specific hosts that are in some DC folder, use the -Location switch in this line

foreach($esxentry in (Get-VMHost -Location “specific DC”|?{$_.Powerstate -eq “PoweredOn”})){

Script will only print information for hosts that are powered and and that are not in maintenance mode. You can use this solution also in different ways. Change the $str2 variable to whatever command you feel like and you can format the output to adjust it to new command. in $str1 you can give password with $ sign for example as well. In the last foreach loop i am not taking the first line [0] because it is the header which i have included in the beginning so there and the csv file is more readable because of this.  This is great base for everybody, modify it as you want and have fun 😉

PS.  If you have established the connection to esxi hosts before you can give to plink option -batch, if not don’t use it, and you will be ask the question about ssh key fingerprint

I will also write other version of this script, that covers a case where you don’t use plain password in -pw,  but ssh keys. If you know better way of getting the filesystem disk usage leave a comment!

Summary tab error message about datastores hearbeat

In the esxi host i received a message:

The number of heartbeat datastores for host is 1, which is less than required: 2

In my case i had only 1 datastore, and i did not want to see this message so in order to get rid of that i used this kb:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1006421

So basically, go to cluster HA settings, and click HA advanced settings button.

Add new advanced property:

das.ignoreinsufficienthbdatastore  with value set to true

You may not power on a virtual machine in a virtual machine esxi 4.1 in esxi 4.1

I thought i solved this some time ago but…
When powering on VM inside virtualized esxi 4.1 on esxi4.1 host i got an error
You may not power on a virtual machine in a virtual machine
I thought 2-3 weeks ago i had to deal with this issue but i forgot to test it 😉 and assumed that it will work… don’t ask.
What i did is that i put option
monitor_control.restrict_backdoor = “TRUE” in vmx.
Well , it’s not enough , now i had also to add
guestOS = “vmkernel”
monitor_control.vt32 = “TRUE”
monitor_control.restrict_backdoor = “TRUE”
When updating the vmx, you will have the guestOS option already set up, so delete it first, because esxi vm will not start and will say that it already has a variable guestos defined.
After rebooting esxi vm, it’s albe to start other vms inside.

HA agent has an error : cmd addnode failed for secondary node: Error creating ramdisk for HA agent configuration. : Unknown HA error

If you want to create ha cluster on virtualized Esxi 4 inside Esxi4 you might encounter above error. Check if you have MORE than 2048 MB ram.
Well described here:
http://communities.vmware.com/message/1723281