The following typical usage scenarios can help you get started with vSphere SDK for Perl.
If you want to use the SDK to retrieve performance information for a host, you can perform the following tasks.
- Check the vSphere SDK for Perl Utility Applications Reference or the apps directory for a script that retrieves performance information.
Check /usr/lib/vmware-vcli/apps on Linux and Program Files (x86)\VMware vSphere CLI\Perl\apps on Windows. All utility applications are fully supported.
The viperformance.pl script retrieves performance counters from the host.
Note: If you cannot find a utility application, examine the sample scripts. You can use sample scripts as starting points for your application. On Linux, /usr/share/doc/vmware-vcli/samples, on Windows, Program Files (x86)\VMware\VMware vSphere CLI\Perl\samples. Sample scripts are not supported. - Run the script with the --help option or without any options to see its online documentation. More detailed information is in the Utility Applications Reference included in the vSphere SDK for Perl documentation set and available from the VMware Web site.
- Run the viperformance.pl script against an ESXi host.
viperformance.pl --url https://<host>:<port>/sdk/vimService --username nemo --password fi\$h --host Aquarium --countertype net --interval 30 --samples 3
Escape characters must precede special characters in passwords. See Options Available for All SDK for Perl Commands for a complete list of connection parameters.
If you want to use the SDK for a task that none of the utility applications can perform, you can perform the following tasks.
- Check the /samples folder for a sample script that performs a similar task. The scripts in the samples folder are available for customization.
- If a script that performs a similar task is available, modify the script. If none of the scripts is suitable, write a new script using the vSphere SDK for Perl subroutines.
The following materials are available for modifying or writing scripts.
Source Description Writing vSphere SDK for Perl Scripts. In-depth discussion of scripts that includes an example. vSphere SDK for Perl Subroutine Reference. Reference to vSphere SDK for Perl subroutines. Web Services for Management Perl Library. Allows you to write scripts that retrieve CIM data from the ESX/ESXi host using CIMOM, a service that provides standard CIM management functions over a WBEM (Web-Based Enterprise Management). Credential Store Perl Library. Allows vSphere SDK for Perl applications to manage the vSphere credential store. vSphere API Reference documentation. Reference to the server-side object your script interacts with. - Follow these programming conventions when you modify or create vSphere SDK for Perl scripts.
- Use parameter names followed by parameter values, as follows.
Vim::<subroutine>(<parameter_name>=><value>, <parameter_name>=><value> ); Util::<subroutine>(<parameter_name>=><value>, <parameter_name>=><value> ); Opts::<subroutine>(<parameter_name>=><value>, <parameter_name>=><value> );
- Use the options in Options Available for All SDK for Perl Commands to specify connection information.
- Use the mechanism discussed in Step 2: (Optional) Define Script-Specific Command-Line Options for specifying additional script-specific options.
- Use parameter names followed by parameter values, as follows.