hostServiceManagement.pl

Version 1

    Table of Contents

    • Author

    • Description

    • Category

    • Features

    • Requirements

    • Version Support

    • Sample Execution

    • Sample Output

    • Email Reports

     

    Author

    William Lam

     

    Description

     

    This script allows you to start, stop and restart some of the basic services that are exposed via the vSphere API: sshd,ntpd,vmware-webAccess,vmware-vpxa,etc against set of ESX(i) hosts either directly connected or via vCenter. You'll need to provide a list of hosts to perform a certain operation when connecting to vCenter or if you're connecting directly to an ESX(i) host, you will not need to provide an input file.

     

    Category

    • Miscellaneous

     

    Features

    • Supports vCenter and ESX and ESXi (licensed version only)

    • Supports running on both Windows and Linux

     

    Requirements

    • vCenter 2.5 or 4.0

    • ESX(i) 3.5 4.0

    • vSphere SDK for Perl/vCLI 4.0 Windows or Linux OR vMA 4.0

     

    Version Support

    • Supports ESX(i) hosts being managed by vCenter

    • Supports both ESX and ESXi (licensed version only)

     

    Sample Execution

     

    Operations:

    • Query

    • Start

    • Stop

    • Restart

     

    Here is sample hostfile input file:

    [vi-admin@scofield skunkworks]$ cat primp-hosts
    esxi4-1.primp-industries.com
    esxi4-2.primp-industries.com
    

     

    Sample Output

     

    Query availble services to operate on vCenter:

    [vi-admin@scofield skunkworks]$ ./hostServiceManagement.pl --server reflex.primp-industries.com --hostfile primp-hosts --operation query
    
    Host: esxi4-1.primp-industries.com ( VMware ESXi 4.0.0 build-171294 )
    ntpd    NOT RUNNING
    vmware-vpxa     RUNNING
    
    Host: esxi4-2.primp-industries.com ( VMware ESXi 4.0.0 build-171294 )
    ntpd    NOT RUNNING
    vmware-vpxa     RUNNING
    
    

     

    Query availble services to operate on individual ESX(i) host:

    [vi-admin@scofield skunkworks]$ ./hostServiceManagement.pl --server esx4-2.primp-industries.com --username root --operation query
    Enter password:
    
    Host: esx4-2.primp-industries.com ( VMware ESX 4.0.0 build-208167 )
    ntpd    NOT RUNNING
    sshd    RUNNING
    vmware-vpxa     NOT RUNNING
    vmware-webAccess        NOT RUNNING
    
    

     

    Start a service on individual ESX host:

     

    Stop a service on set of ESX(i) hosts on vCenter:

     

    Restart a service on on individual ESX host:

     

    Note: When stopping or restarting vmware-vpxa, you may want to connect directly to the host to perform the operation else you will lose the connection to the host you're restarting the vCenter agent which will cause the script to exit early, this is an expected outcome as the vCenter agent can not be contacted if it's been stopped or in process of restarting.