Monday, 13 February 2012

How to format the output of ESXCLI commands

ESXCLI commands are a comprehensive set of commands for managing most aspects of vSphere. In vSphere 5.0, this command set has been unified. Eventually, ESXCLI commands will replace other commands in the vCLI set.

esxcli command
esxcli fcoe
esxcli hardware
esxcli iscsi
esxcli license
esxcli network
esxcli software
esxcli storage
esxcli system
esxcli vm

For a consistent look and feel for both local and remote CLI administration, the new "esxcli" command provides the ability to format the command output. Using the "--formatter" option, administrators can choose to have the command output formatted as XML, a key-value pair or a list of comma-separated values. The "esxcli" formatter enhances your ability to parse command output, helping to simplify scripting and improve report generation. In addition, you can specify which fields to include in the output. In the following example, we need to generate a report showing all the storage volume names with their free space. We start by running the storage filesystem list command, as follows: esxcli --formatter=csv storage filesystem list


The output gives us the information we need, but it is very verbose, requiring the user to use the scroll bar to see the data for all the volumes. Because we need only a summary showing the volume name and free space, we can refine our command using the --formatter and --format-param options, as follows: esxcli --formatter=csv --format-param=fields="Free,VolumeName" storage filesystem list


More information about the ESXCLI command can be found at this link

http://feedproxy.google.com/~r/Ntpronl/~3/bjYZeWs67AQ/1975-How-to-format-the-output-of-ESXCLI-commands.html


No comments:

Post a Comment