Skip navigation
2014

Hello,

this code permits report the vm's guest disks with less than 20% free space.

 

I would like to comment that in order to check the free space, the vmware tools must be installed and running in the virtual machines.

If you want to know (using powercli) the virtual machines that haven't installed vmware tools, you can check this.

 

ForEach ($VM in Get-VM | where-object {($_.powerstate -ne "PoweredOff") -and ($_.Extensiondata.Guest.ToolsStatus -Match ".*Ok.*")}){

 

ForEach ($Drive in $VM.Extensiondata.Guest.Disk) {

 

$Path = $Drive.DiskPath

 

#Calculations 

$Freespace = [math]::Round($Drive.FreeSpace / 1MB)

$Capacity = [math]::Round($Drive.Capacity/ 1MB)

 

$SpaceOverview = "$Freespace" + "/" + "$capacity" 

$PercentFree = [math]::Round(($FreeSpace)/ ($Capacity) * 100) 

 

#VMs with less space

if ($PercentFree -lt 20) {     

    $Output = $Output + "Vm: " + $VM.Name + "`n"

    $Output = $Output + "Disk: " + $Path + "`n"

    $OutPut = $Output + "Free(MB): " + $Freespace + "`n"

    $Output = $Output + "Free(%): " + $PercentFree + "`n"  

}

 

} # End ForEach ($Drive in in $VM.Extensiondata.Guest.Disk)

 

} # End ForEach ($VM in Get-VM)

 

$Output

 

 

(As usual, remember to use the Connect-VIServer cmdlet before!)

 

 

My powercli script is based in this two scripts:

http://www.virtu-al.net/2009/03/25/vi-toolkit-one-liner-vm-guest-disk-sizes/

vGeek: Collect disk space detail and send it in email Powercli

 

 

Best regards,

Pablo

Hello,

if you want to migrate virtual machines running in vmware server 2 to vSphere ESXi, this how-to can be helpful.

 

Additionally, this documentation can be checked:

VMware KB: Moving or copying a virtual machine within a VMware environment

VMware KB: Best practices for using and troubleshooting VMware Converter

 

 

Best regards,

Pablo

Hello,

some time ago i faced an issue with the vcenter db transaction log, because it became full every 6 hours (at fixed hours).

In the windows event log this message appeared:

 

The transaction log for database 'VIM_VCDB' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases

 

If i checked the log_reuse_wait_desc column in sys.databases just after the event log happened, i noticed that the transaction log truncation was delayed waiting for a checkpoint. This information didn't help so much ... then, i made some research to learn the way the transaction log works.

 

The MS SQL database have configured the simple recovery model, then transaction log not should be so big as when using the full recovery mode.

In simple mode the database logs the active transactions in the transaction log, and after that, it frees space (log truncation) in the log. This truncation really don't make smaller the physical transaction log, It frees space for reuse by the transaction log. To be able to make smaller the physical transaction log, the log must be shrinked. Anyway, shrinking the file don't help.

 

I found this discussion in the vmware communities. It helped me to go in the correct direction.

 

The transaction log was getting full every time the dbo.cleanup_events_tasks_proc stored procedure was executed.

(To know what stored procedure was filling the transaction log, i used this sql query)


Every 6 hours this procedure tries to delete the data from the vpx_event, vpx_event_arg, and vpx_task tables based in the "database retention policy" specified in the "vCenter server settings". When i activated the "database retention policy" (180 days), the transaction log issue started to happen.

 

I checked the vpx_event, vpx_event_arg, and vpx_task tables and i noticed that this tables had entries/rows since 2012.

 

Then, i increased temporally the transaction log size from 500 MB to 2000 MB and executed manually the dbo.cleanup_events_tasks_proc. It was executed correctly (it deleted the entries older than 180 days in the vpx_event, vpx_event_arg, and vpx_task tables) .

 

Finally, i configured the transaction log size back to 500 MB.

 

 

And no more transaction log full messages in the windows event log



 

Best regards,

Pablo

 

Additional Bibliography

VMware KB: Purging old data from the database used by VMware vCenter Server 4.x and 5.x

VMware KB: Determining where growth is occurring in the VMware vCenter Server database

How to determine SQL Server database transaction log usage

Borja_Mari Virtuoso

Selected as vEXPERT 2014!

Posted by Borja_Mari Apr 2, 2014

Hello,

this year I'm selected as a vEXPERT 2014!

 

Thanks so much for selecting me as vEXPERT.

 

Source: vExpert 2014 Announcement | VMTN Blog - VMware Blogs

 

Best regards,

Pablo