<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>VMtoday &#187; NFS</title> <atom:link href="http://vmtoday.com/tag/nfs/feed/" rel="self" type="application/rss+xml" /><link>http://vmtoday.com</link> <description>VMware News, Views, &#38; How-To&#039;s from vExpert Josh Townsend</description> <lastBuildDate>Sat, 14 Jan 2012 03:00:43 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Obtaining VMware Guest Disk Free Space for NFS Sizing</title><link>http://vmtoday.com/2008/12/obtaining-vmware-guest-disk-free-space-for-nfs-sizing/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=obtaining-vmware-guest-disk-free-space-for-nfs-sizing</link> <comments>http://vmtoday.com/2008/12/obtaining-vmware-guest-disk-free-space-for-nfs-sizing/#comments</comments> <pubDate>Fri, 05 Dec 2008 21:31:22 +0000</pubDate> <dc:creator>Joshua Townsend</dc:creator> <category><![CDATA[VMware]]></category> <category><![CDATA[VMware How To]]></category> <category><![CDATA[NetApp]]></category> <category><![CDATA[NFS]]></category> <category><![CDATA[sizing]]></category><guid
isPermaLink="false">http://vmtoday.com/?p=11</guid> <description><![CDATA[I am often asked about sizing storage vis-à-vis how much free space within a guest VMDK eats into the overall size of the volume.  The answer can be drastically whether we are dealing with thick-provisioned VMDK&#8217;s on FC or iSCSI LUN&#8217;s, or thin provisioned VMDK&#8217;s on NFS volumes.  The amount of free space present in [...]]]></description> <content:encoded><![CDATA[<p></p><p>I am often asked about sizing storage vis-à-vis how much free space within a guest VMDK eats into the overall size of the volume.  The answer can be drastically whether we are dealing with thick-provisioned VMDK&#8217;s on FC or iSCSI LUN&#8217;s, or thin provisioned VMDK&#8217;s on NFS volumes.  The amount of free space present in guest VMDK&#8217;s also comes into effect when calculating the impact of dedupe on the volume.  Add in some flexible volumes on NetApp storage and the amount of provisioned storage in the design changes significantly.</p><p>There are several methods of obtaining the amount of free space in a guest OS, from third party systems management tools (some are vendor or OS specific) to custom scripting (some VB for your Windows hosts, etc.).  VirtualCenter also knows how much free space is within each guest VMDK, but the information is not readily displayed.</p><p>The first method of getting guest free space is using the VMware VI Toolkit for Windows.  A simple statement like what I show below will pull the info for you (<a
title="storage report listing capacity and freespace for each drive on each vm" href="http://communities.vmware.com/message/1046360" target="_blank">see Hal Rottenberg&#8217;s post on the VMware Communities Forum</a>):</p><blockquote><p><span
style="color: #808080;">PS &gt; $hdCapacity = @{ N = &#8220;Capacity (bytes)&#8221;; E = { $_.Guest.Disks | % { $_.Capacity } } }<br
/> PS &gt; $hdFreeSpace = @{ N = &#8220;FreeSpace (bytes)&#8221;; E = { $_.Guest.Disks | % { $_.FreeSpace } } }<br
/> PS &gt; Get-VM | select Name, $hdCapacity, $hdFreeSpace</span></p></blockquote><p>You can re-write the command into a single line and change the output to show Percentage Free space, for example.  The following came from <a
title="http://communities.vmware.com/message/1046360" href="http://communities.vmware.com/message/1046360" target="_blank">http://communities.vmware.com/message/1046360</a>.</p><blockquote><p><span
style="color: #808080;">Get-VM | Where { $_.PowerState -eq &#8220;PoweredOn&#8221; } | Get-VMGuest | Select VmName -ExpandProperty Disks | Select VmName, Path, @{ N=&#8221;PercFree&#8221;; E={ [math]::Round( (100 * ( $_.FreeSpace / $_.Capacity ) ),0 ) } } | Sort PercFree</span></p></blockquote><p>These examples are well and good, but there are a couple of catches &#8211; The guest must be powered up and VMware Tools must be installed and running inside each VM you want to pull statistics from.<br
/> Many people do not know that the guest disk capacity and free space statistics are also captured in the VirtualCenter database and is available for VM&#8217;s in any power state (On, Off, or Suspended), so long as VMware Tools has been installed and run at least once in the VM.  A SQL simple query will return the data too you (this could be more simple &#8211; I was pulling some additional statistics for a project I am working on):</p><blockquote><p><span
style="color: #808080;"><br
/> SELECT VPX_GUEST_DISK.VM_ID, VPX_GUEST_DISK.PATH, VPX_GUEST_DISK.CAPACITY, CONVERT(bigint, VPX_GUEST_DISK.CAPACITY) / 1048576 AS &#8216;Capacity MB&#8217;, VPX_GUEST_DISK.FREE_SPACE, CONVERT(bigint, VPX_GUEST_DISK.FREE_SPACE) / 1048576 AS &#8216;Free Space MB&#8217;,VPX_HOST.ID, VPX_HOST.DATACENTER_ID, VPX_HOST.DNS_NAME, VPX_VM.ID, VPX_VM.DATACENTER_ID, VPX_VM.FILE_NAME, VPX_VM.LOCAL_FILE_NAME, VPX_VM.POWER_STATE, VPX_VM.GUEST_OS, VPX_VM.GUEST_STATE, VPX_VM.MEM_SIZE_MB, VPX_VM.NUM_DISK, VPX_VM.DNS_NAME, VPX_VM.IS_TEMPLATE, VPX_VM.HOST_ID<br
/> FROM VPX_GUEST_DISK VPX_GUEST_DISK, VPX_HOST VPX_HOST, VPX_VM VPX_VM<br
/> WHERE VPX_VM.ID = VPX_GUEST_DISK.VM_ID AND VPX_HOST.ID = VPX_VM.HOST_ID</span></p></blockquote><p>Of course, you can always combine the power of PowerShell and the raw SQL data to create formatted output.  <a
title="Frank Hagen's Blog" href="http://FWHagen.wordpress.com" target="_blank">Frank Hagen</a> displays a method of obtaining SQL data through a PowerShell script and dumping the data to Excel for further manipulation on his blog.  I modified a few lines of Frank&#8217;s code for my purposes:</p><blockquote><p><span
style="color: #808080;">################################################<br
/> #   QuerySQL.ps1                                   # Frank W Hagen &#8211; 2008/07/15<br
/> #                                                  #   FWHagen.wordpress.com<br
/> #     Powershell script to query a SQL database    #   fwhagen.blog@gmail.com<br
/> #      and write the output to an Excel file<br
/> #<br
/> #     Usage:<br
/> #     * Create a SQL query file by putting a valid SQL query in a text file in<br
/> #       the subdirectory specified in $SQLQueryPath named &lt;$TaskName&gt;.sql<br
/> #     * Set configuration variables in config section below<br
/> #     * Run at command line:  powershell -nologo .\QuerySQL.ps1<br
/> #         OR right-click this script and Open With -&gt; Powershell.EXE<br
/> #<br
/> #     If you get a security warning running the script, see the following post:<br
/> #     http://fwhagen.wordpress.com/2007/10/29/running-local-powershell-scripts/<br
/> ########################################################</span></p><p><span
style="color: #808080;"># Function used for binding to Excel<br
/> function Invoke([object]$m, [string]$method, $parameters)<br
/> {  $m.PSBase.GetType().InvokeMember($method, [Reflection.BindingFlags]::InvokeMethod, $null, $m, $parameters, [System.Globalization.CultureInfo]&#8220;en-US&#8221;)  } </span></p><p><span
style="color: #808080;">############################################<br
/> ### Configuration information for specific query #####<br
/> $TaskName = &#8220;VIGuestDiskFree&#8221;     # Title and name of query file</span></p><p><span
style="color: #808080;">#######################################################<br
/> ### UPDATE THE FOLLOWING LINES FOR YOUR ENVIRONMENT ###<br
/> $SqlServer = &#8220;&#8221;;	# SQL Server hosting VirtualCenter Database (include \instance name if not using Default)<br
/> $SqlCatalog = &#8220;&#8221;;	# Virtual Center Database name<br
/> $SQLUserID = &#8220;&#8221;;	# SQL Server User ID if not using Integrated Security see lines 69 and 70<br
/> $SQLPassword = &#8220;&#8221;;	# SQL Server User Password if not using Integrated Security see lines 69 and 70<br
/> ### END OF CUSTOMER UPDATABLE FIELDS ###<br
/> #######################################################<br
/> $WriteOutXML = $False<br
/> $WriteOutCSV = $False<br
/> $WriteOutXLS = $True<br
/> #<br
/> # Environment Configuration<br
/> $TaskPath = &#8220;C:\Scripts\&#8221;          # Root Directory for creating reports<br
/> $SQLQueryPath = &#8220;SQLQueries\&#8221;               # Subdirectory for finding the queryfile<br
/> ######################################################</span></p><p><span
style="color: #808080;"># Timestamp the output folder and files using ISOdate<br
/> $OutPath = ($TaskPath + (Get-Date -Format yyyyMMdd) + &#8220;-&#8221; + $TaskName + &#8220;\&#8221;)<br
/> $OutFileName = ( (Get-Date -Format yyyyMMdd) + &#8220;-&#8221; + $TaskName )</span></p><p><span
style="color: #808080;"># Create the output folder                                      #TODO: Fix Call to eliminate verbose results from system<br
/> if (!$(test-path ($OutPath)))<br
/> {<br
/> New-Item -itemType directory -Name ((Get-Date -Format yyyyMMdd) + &#8220;-&#8221; + $TaskName) &gt; $null</span></p><p><span
style="color: #808080;"> if ($(test-path ($OutPath)))<br
/> {<br
/> Write-Host ($OutPath + &#8221; Created&#8221;) -ForegroundColor &#8220;darkgreen&#8221;<br
/> }<br
/> else<br
/> {<br
/> Write-Host ($OutPath + &#8221; FAILED&#8221;) -ForegroundColor &#8220;red&#8221;<br
/> }<br
/> }</span></p><p><span
style="color: #808080;"># Get the T-SQL Query from .SQL file<br
/> $SqlQuery = Get-Content ($TaskPath + $SQLQueryPath + $TaskName + &#8220;.sql&#8221;)<br
/> Write-Host (&#8220;Executing Queryfile: &#8221; + ($TaskName + &#8220;.sql&#8221;) + &#8221; &#8220;) -ForegroundColor &#8220;darkgreen&#8221;<br
/> #Write-Host ($SqlQuery) -ForegroundColor &#8220;gray&#8221;</span></p><p><span
style="color: #808080;"># Setup SQL Connection (using Integrated Security (your workstation login).  Use standard connection string format for other)<br
/> $SqlConnection = New-Object System.Data.SqlClient.SqlConnection<br
/> #$SqlConnection.ConnectionString = &#8220;Server = $SqlServer; Database = $SqlCatalog; Integrated Security = True&#8221;<br
/> $SqlConnection.ConnectionString = &#8220;Server = $SqlServer; Database = $SqlCatalog; Integrated Security = False; User ID = $SQLUserID; Password = $SQLPassword;&#8221;</span></p><p><span
style="color: #808080;"># Setup SQL Command<br
/> $SqlCmd = New-Object System.Data.SqlClient.SqlCommand<br
/> $SqlCmd.CommandText = $SqlQuery<br
/> $SqlCmd.Connection = $SqlConnection</span></p><p><span
style="color: #808080;"># Setup .NET SQLAdapter to execute and fill .NET Dataset<br
/> $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter<br
/> $SqlAdapter.SelectCommand = $SqlCmd<br
/> $DataSet = New-Object System.Data.DataSet<br
/> $DataTable = New-Object System.Data.DataTable</span></p><p><span
style="color: #808080;"># Execute and Get Row Count<br
/> $nRecs = $SqlAdapter.Fill($DataSet)</span></p><p><span
style="color: #808080;">Write-Host ($nRecs.ToString() + &#8221; Records retrieved.&#8221;) -ForegroundColor &#8220;Blue&#8221;<br
/> $SqlConnection.Close();</span></p><p><span
style="color: #808080;">if ($nRecs -gt 0)<br
/> {<br
/> # Make copy of successful query in output directory for traceability<br
/> if ($(test-path ($OutPath + $OutFileName + &#8220;.sql&#8221;)))<br
/> {<br
/> del ($OutPath + $OutFileName + &#8220;.sql&#8221;)<br
/> }<br
/> Copy-Item ($TaskPath + $SQLQueryPath + $TaskName + &#8220;.sql&#8221;) -destination ($OutPath + $OutFileName + &#8220;.sql&#8221;)</span></p><p><span
style="color: #808080;"> # Very simple to export XML<br
/> if($WriteOutXML)<br
/> {<br
/> Write-Host &#8220;Creating XML File&#8230;&#8221; -ForegroundColor &#8220;darkgreen&#8221;<br
/> if ($(test-path ($OutPath + $OutFileName + &#8220;.xml&#8221;)))<br
/> {<br
/> del ($OutPath + $OutFileName + &#8220;.xml&#8221;)<br
/> }</span></p><p><span
style="color: #808080;"> $DataSet.Tables[0].WriteXML($OutPath + $OutFileName + &#8220;.xml&#8221;);<br
/> }</span></p><p><span
style="color: #808080;"> # Very simple to export CSV<br
/> if($WriteOutCSV)<br
/> {<br
/> Write-Host &#8220;Creating CSV File&#8230;&#8221; -ForegroundColor &#8220;darkgreen&#8221;<br
/> if ($(test-path ($OutPath + $OutFileName + &#8220;.csv&#8221;)))<br
/> {<br
/> del ($OutPath + $OutFileName + &#8220;.csv&#8221;)<br
/> }</span></p><p><span
style="color: #808080;"> $DataSet.Tables[0] | Export-Csv ($OutPath + $OutFileName + &#8220;.csv&#8221;)<br
/> }</span></p><p><span
style="color: #808080;"> # Very hard to export XSL &#8211; This method writes the data to an object array and pastes the array directly into Excel  (Thanks go to a few sources on the Internet for this method)<br
/> if($WriteOutXLS)<br
/> {<br
/> Write-Host &#8220;Creating Excel File&#8230;&#8221; -ForegroundColor &#8220;darkgreen&#8221;<br
/> if ($(test-path ($OutPath + $OutFileName + &#8220;.xls&#8221;)))<br
/> {<br
/> del ($OutPath + $OutFileName + &#8220;.xls&#8221;)<br
/> }</span></p><p><span
style="color: #808080;"> $sheetIndex = 0;<br
/> $oExcel = New-Object -COM Excel.Application<br
/> $oExcel.Visible = $false<br
/> $oBooks = $oExcel.Workbooks<br
/> $oCulture= [System.Globalization.CultureInfo]&#8220;en-US&#8221;<br
/> $oBook=$oBooks.psbase.gettype().InvokeMember(&#8220;Add&#8221;,[Reflection.BindingFlags]::InvokeMethod,$null,$oBooks,$null,$oCulture)<br
/> #$oSheet = $oBook.Worksheets.Item(1)</span></p><p><span
style="color: #808080;"> $DataTable = $DataSet.Tables[0];<br
/> $nDr = $DataTable.Rows.Count + 1<br
/> $nDc = $DataTable.Columns.Count + 1</span></p><p><span
style="color: #808080;"> # Create the object array<br
/> $rawData = new-object &#8216;object[,]&#8216; $nDr,$nDc </span></p><p><span
style="color: #808080;"> # Write the field names in the first row<br
/> for ($col = 0; $col -lt $DataTable.Columns.Count; $col++)<br
/> {<br
/> $rawData[0, $col] = $DataTable.Columns[$col].ColumnName;<br
/> }</span></p><p><span
style="color: #808080;"> # Copy the dataset to the object array<br
/> for ($col = 0; $col -lt $DataTable.Columns.Count; $col++)<br
/> {<br
/> for ($row = 0; $row -lt $DataTable.Rows.Count; $row++)<br
/> {<br
/> $rawData[($row + 1), $col] = $DataTable.Rows[$row][$col];<br
/> }<br
/> }</span></p><p><span
style="color: #808080;"> # Calculate the final column letter<br
/> $finalColLetter = &#8220;&#8221;;<br
/> $colCharset = &#8220;ABCDEFGHIJKLMNOPQRSTUVWXYZ&#8221;;<br
/> $colCharsetLen = $colCharset.Length;<br
/> if ($DataTable.Columns.Count -gt $colCharsetLen)<br
/> {<br
/> $finalColLetter = $colCharset.Substring((($DataTable.Columns.Count &#8211; 1) / ($colCharsetLen &#8211; 1)), 1);<br
/> }<br
/> $finalColLetter += $colCharset.Substring(($DataTable.Columns.Count &#8211; 1) % $colCharsetLen, 1);</span></p><p><span
style="color: #808080;"> ### Export it all to Excel #####<br
/> Write-Host &#8220;Writing to Excel&#8230;&#8221; -ForegroundColor &#8220;darkgreen&#8221;</span></p><p><span
style="color: #808080;"> # Create a new Sheet<br
/> $excelSheet = $oBook.Worksheets.Item(1)</span></p><p><span
style="color: #808080;"> #$excelSheet.name = $DataTable.TableName;               #TODO: Be nice to figure out how to make this work (not critical)</span></p><p><span
style="color: #808080;"> # Create the entire range on the worksheet and dump the data into it<br
/> $excelRange = &#8220;A1:&#8221; + $finalColLetter + &#8220;&#8221; + ($DataTable.Rows.Count + 1)<br
/> $excelSheet.Range($excelRange).FormulaLocal = $rawData;</span></p><p><span
style="color: #808080;"> # Mark the first row as BOLD                            #TODO: Be nice to figure out how to make this work (not critical)<br
/> #$excelSheet.Rows[1].Font.Bold = $True;<br
/> #$excelSheet.Cells.Item(1,1).Font.Bold = $True;</span></p><p><span
style="color: #808080;"> # Save the Excel file and we&#8217;re done<br
/> Invoke $oBook SaveAs ($OutPath + $OutFileName + &#8220;.xls&#8221;) &gt; $null<br
/> Invoke $oBook Close 0 &gt;$null<br
/> $oExcel.Quit()<br
/> }<br
/> }</span></p><p><span
style="color: #808080;">Write-Host (&#8220;Complete&#8221;)</span></p></blockquote><p>I dropped the PowerShell code into a file named VIGuestDiskFree.ps1 in C:\Scripts on my Vista laptop, and the SQL query from earlier in this post to c:\scripts\sqlqueries\VIGuestDiskFree.sql.  Simply run the PowerShell script from a PowerShell command line.  The Excel output file  will be created in a date-stamped folder in C:\Scripts.  Once you have this data you can go about the business of formatting the data as an Excel Table and summing the Free Space column to find out your storage savings with thin provisioning and other storage efficiency technologies.  I have attached a .zip (<a
href="http://cloudfront.vmtoday.com/wp-content/uploads/2008/12/scripts.zip">VIGuestFreeScripts</a>) containing the scripts in this post (formatting is a bit off in WordPress).</p><p>How do you report on your storage utilization and storage efficiency efforts?  Post a comment to share your methods!</p><div
class="shr-publisher-11"></div><div
style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div
class='shareaholic-like-buttonset' style='float:none;height:30px;'><a
class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fvmtoday.com%2F2008%2F12%2Fobtaining-vmware-guest-disk-free-space-for-nfs-sizing%2F' data-shr_title='Obtaining+VMware+Guest+Disk+Free+Space+for+NFS+Sizing'></a><a
class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fvmtoday.com%2F2008%2F12%2Fobtaining-vmware-guest-disk-free-space-for-nfs-sizing%2F'></a><a
class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fvmtoday.com%2F2008%2F12%2Fobtaining-vmware-guest-disk-free-space-for-nfs-sizing%2F' data-shr_title='Obtaining+VMware+Guest+Disk+Free+Space+for+NFS+Sizing'></a></div><div
style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div>]]></content:encoded> <wfw:commentRss>http://vmtoday.com/2008/12/obtaining-vmware-guest-disk-free-space-for-nfs-sizing/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 6/18 queries in 0.088 seconds using disk: basic
Object Caching 504/514 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: cloudfront.vmtoday.com

Served from: vmtoday.com @ 2012-02-05 04:45:10 -->
