vSphere

 View Only
  • 1.  How do I get the size of files in a datastore?

    Posted Sep 21, 2009 02:31 PM

    I've been using the dsbrowse.pl file as a starting point to collect information about the data stores for various planned reports.

    A new requirement is to provide the size of each file found in a datastore folder.

    Does anyone have any guides, pointers, or code they can share?

    Thank you.



  • 2.  RE: How do I get the size of files in a datastore?

    Posted Sep 21, 2009 02:55 PM

    You can run a plain "du -h " on ESX.

    PS: Please award points if any of the above information is useful.



  • 3.  RE: How do I get the size of files in a datastore?

    Posted Sep 21, 2009 03:20 PM

    I don't think that will work for me. I should have been clearer in my description. I have the size of the data store and it's capacity used already.

    What I'd like to collect in addition to that is the size of eachof the files within a folder on the datastore.

    NOTE: I am running the toolkit on a dedicated (virtualized) server and connecting to the virtual center server using the Util::Connect mechanism and It is preferred if this task be done using the perl tookit and/or API.

    For example, in my output I have the following for a single datastore:

    Data Store: DataStoreNumberOne

    Type: VMFS

    Size: 599.75 GB

    Free: 92.7 GB

    Folder Path: DataStoreNumberOne -> VMNumberOne/

    Files Present:

    VMNumberOne-flat.vmdk

    VMNumberOne.vmdk

    VMNumberOne-ctk.vmdk

    vmware-6.log

    vmware-7.log

    svmware-8.log

    What I'm looking for is a process to retrieve the size for each of the files located under "Files Present" using perl and the vmware vitookit/API.

    Thank you.

    Message was edited by: LinuxMonkey to correct formatting issue.



  • 4.  RE: How do I get the size of files in a datastore?
    Best Answer

    Broadcom Employee
    Posted Sep 21, 2009 05:03 PM

    All this information is available using the vSphere API, specifically: *SearchDatastoreSubFolders_Task() which allows for all types of complex queries including specific type of files, patterns, etc.

    Take a look at this script:

    =========================================================================

    William Lam

    VMware vExpert 2009

    VMware ESX/ESXi scripts and resources at:

    VMware Code Central - Scripts/Sample code for Developers and Administrators

    VMware Developer Comuunity

    Twitter: @lamw

    If you find this information useful, please award points for "correct" or "helpful".



  • 5.  RE: How do I get the size of files in a datastore?

    Posted Sep 21, 2009 06:49 PM

    This appears to be exactly the type of example I was looking for.

    Thank you for the insight, it is appreciated.



  • 6.  RE: How do I get the size of files in a datastore?

    Broadcom Employee
    Posted Sep 21, 2009 07:10 PM

    np. Don't forget to award 'correct' or 'helpful' points :smileywink:

    =========================================================================

    William Lam

    VMware vExpert 2009

    VMware ESX/ESXi scripts and resources at:

    VMware Code Central - Scripts/Sample code for Developers and Administrators

    VMware Developer Comuunity

    Twitter: @lamw

    If you find this information useful, please award points for "correct" or "helpful".