Search the VMware Knowledge Base (KB)
View by Article ID

Gathering esxtop performance data at specific times using crontab (1033346)

  • 14 Ratings

Purpose

This article provides steps for setting up a scheduled cron job to run esxtop in batch mode. The esxtop utility redirects the output to a .csv file.

Resolution

You must edit the crontab configuration file to create scheduled tasks on ESXi/ESX. For more information, see Editing configuration files in VMware ESXi and ESX (1017022) .

Before creating a scheduled task, ensure that the ESXi/ESX host's date and time are correct. For more information, see Verifying time synchronization across an ESXi/ESX host environment (1003736) .

Scheduling tasks in ESX using cron

  1. Log in as root to the ESX host console directly or using SSH. For more information, see Connecting to an ESX host using a SSH client (1019852).
  2. Run this command to open the crontab configuration file in the vi text editor:

    crontab -e

    Note: To use a different editor, modify the EDITOR environment variable.

    For example, to use nano:

    EDITOR=nano crontab -e

  3. To start esxtop at the desired time, append the crontab file and run the esxtop command using the syntax:

    Minutes Hour(24 hour format) Date Month_Day_of_Week  /usr/bin/esxtop -b -d ## -n #### > path/name-of-the-file.csv

    -b : Signifies batch mode

    -d : Sampling Frequency in seconds

    -n : Total number of samples.

    To collect the ESXTOP data in batch mode every night regardless of date, month or day of week at 2:20 am with frequency of sampling set to 5 seconds for 1440 samples, run this command:

    20 2 * * * /usr/bin/esxtop -b -d 5 -n 1440 > /vmfs/volumes/DatastoreName/esxtop-batch.csv

    This command generates 120 minutes worth of data for analysis.

  4. Save the file. The changes take effect immediately and esxtop starts at the next scheduled time.
Note : The configuration changes on ESX persist across reboots. To revert the change, remove the esxtop  line from the crontab configuration file.

Scheduling tasks in ESXi using cron

Note: Nano is not available in ESXi and, therefore, you must use the vi editor.

  1. Open a console to the ESXi host using the Tech Support Mode. For more information, see Using Tech Support Mode in ESXi 4.1 and ESXi 5.x (1017910).
  2. Open the root crontab file located in /var/spool/cron/crontabs as the root user using the vi editor.
  3. To start esxtop at the desired time, append the crontab file with the esxtop command using the syntax explained below:

    Syntax: 

    Minutes Hour(24 hour format) Date Month_Day_of_Week  /usr/sbin/esxtop -b -d ## -n #### > path/name-of-the-file.csv

    -b : Signifies batch mode

    -d : Sampling Frequency in seconds

    -n : Total number of samples.

    To collect the ESXTOP data in batch mode every night regardless of date, month or day of week
    at 2:20 am with frequency of sampling set to 5 seconds for 1440 samples, run this command:

    20 2 * * * /usr/sbin/esxtop -b -d 5 -n 1440 > /vmfs/volumes/DatastoreNametmp/esxtop-batch.csv

    The above command generates 120 minutes worth of data for analysis.

  4. Save the file. 

    Note: By default, this file is read-only. However, you can write changes to the file using the wq! key combination in the vi editor.

  5. Run this command to determine the process ID of the crond process:

    cat /var/run/crond.pid

    You see output similar to:

    1234

    Where 1234 is the Process ID of the crond process.

  6. Run this command to restart the crond process:

    kill -HUP 1234

    Note: On some ESXi versions, a manual restart is required. Run the appropriate command:

    In ESXi 4.x and ESXi 5.0:

    kill 1234
    /bin/busybox crond 

    In ESXi 5.1 and ESXi 5.5:

    kill 1234
    /usr/lib/vmware/busybox/bin/busybox crond

    The changes take effect immediately and esxtop starts at the next scheduled time.

Note: The configuration changes on ESXi do not persist across reboots. To revert the change without rebooting, remove the esxtop line from the crontab file and kill the crond process.

See Also

Update History

01/31/2012 - Added location of crontab for ESXi 01/30/2013 - Added ESXi 5.0 crond restart command 04/11/2013 - Added note the Step 4 4/15/2013 - Added command to restart crond in ESXi 5.1 11/27/2013 - Added command for 4.1 and 5.5 and added ESXi 5.5 to Product Versions.

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback

  • 14 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.

What can we do to improve this information? (4000 or fewer characters)




Please enter the Captcha code before clicking Submit.
  • 14 Ratings
Actions
KB: