Loading

×Sorry to interrupt
CSS Error

Refresh

Cookie Preference Center

General Information on cookies

When you visit our website, we use cookies to ensure that we give you the best experience. This information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience on the site and the services we are able to offer. Further information can be found in our

Cookie Policy.

Strictly Necessary

Strictly Necessary

Always Active

Strictly Necessary

Strictly necessary cookies are always enabled since they are essential for our website to function. They enable core functionality such as security, network management, and website accessibility. You can set your browser to block or alert you about these cookies, but this may affect how the website functions. For more information please visit www.aboutcookies.org or www.allaboutcookies.org.

Cookie Details‎

Performance

Performance

Performance

Performance cookies are used to analyze the user experience to improve our website by collecting and reporting information on how you use it. They allow us to know which pages are the most and least popular, see how visitors move around the site, optimize our website and make it easier to navigate.

Cookie Details‎

Please confirm your settings by refreshing the page.

Functional

Functional

Functional

Functional cookies help us keep track of your past browsing choices so we can improve usability and customize your experience. These cookies enable the website to remember your preferred settings, language preferences, location and other customizable elements such as font or text size. If you do not allow these cookies, then some or all of these services may not function properly.

Cookie Details‎

Advertising

Advertising

Advertising

Advertising cookies are used to send you relevant advertising and promotional information. They may be set through our site by third parties to build a profile of your interests and show you relevant advertisements on other sites. These cookies do not directly store personal information, but their function is based on uniquely identifying your browser and internet device.

Cookie Details‎

Advertising Cookies

Consent Leg.Interest

Select All Vendors

Select All Vendors

Select All Hosts

Select All

Clear Filters

Information storage and access

Apply

Confirm My Choices Reject All Allow All

My Subscriptions

Loading

Knowledge Base

Gathering esxtop performance data using cronjobs (1033346)

Last Updated: 9/18/2023Categories: TroubleshootingTotal Views: 10568Language:
Chinese (Simplified)JapaneseEnglish

4 like this article

Subscribe to get an email
newsletter with new updates

4 people found this helpful Please provide article feedback:

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 need to 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 the task in ESXi using cron

Open a console to the ESXi host using the ESXi Shell formally (TSM/Tech Support Mode) or open an SSH connection to your ESXi and login as the root user. For more information, see Using ESXi Shell in ESXi 6.x, 7.x and 8.x (2004746)

First take a backup of the crontabs file to another location before editing.

cat /var/spool/cron/crontabs/root > /vmfs/volumes/<Datastore>/<folder>/crontab-$(hostname).txt

 Open the root crontab file located in /var/spool/cron/crontabs using the vi editor:

# vi /var/spool/cron/crontabs/root

Open To enter insert mode in vi and make changes to the file press "i"

To start esxtop at the desired time, append the crontab file with the esxtop command using the syntax explained below:

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.

For example, 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 180 samples, while saving the collected data as "batch.csv" on your VMFS datastore "datastore1", the entry in crontabs/root will have to look like this:

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

The above command generates 15 minutes (5 x 180 seconds) worth of data for analysis.

Scheduling a rolling ESXtop using cron.

In the event of a collecting performance data where it is difficult to collect or predict when an issue may occur you may be able to set a rolling collection of performance data.

The cron job command in the code block below will place a place a mark the logs at the start of the performance data collection. Below is an example of what you may see in the vmkernel:
xxx-xx-xxTxx:xx:xxZ esxcfg-syslog[2233321]: mark: ESXTOP-CRONJOB-xxxx-xx-xxTxx:xx.csv

While collecting a rolling 15 minutes of performance data into individual files on the specified datastore.
You may notice that the files are marked by the time when we start the collection and cover the proceeding 15 minutes.

NOTE: This operation will create many files and will continue to consume space if not continuously monitored please remove the old file that do not cover the time in question and select the files with the appropriate date and time that could cover the time of interest:

*/16 * * * * localcli system syslog mark --message=ESXTOP-CRONJOB-$(date +"%FT%H:%M").csv;esxtop -ba -d 5 -n 180 >/vmfs/volumes/datastore1/folder/esxtop-$(hostname)-$(date +"%FT%H:%M").csv

Saving the file crontab file once changes have been made:

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

To apply the new cron schedule, you will have to restart crond. 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.

Run this command to stop and restart the crond process:

# kill -HUP 1234

In order to restart the crond process use this command:

# /usr/lib/vmware/busybox/bin/busybox crond

As soon as these changes have been made, esxtop will start 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 and restart the crond process again.

Related Information

Verifying time synchronization across an ESX/ESXi host environment
Using syslog log markers from the ESXi command line (2146535)
Exporting esxtop performance data as a CSV file and manipulating it from the command-line
Editing configuration files in VMware ESXi and ESX
Using Tech Support Mode in ESXi 4.1, ESXi 5.x, and ESXi 6.x
crontab を使用して指定した時刻に esxtop パフォーマンス データを収集する
使用 crontab 在特定时间收集 esxtop 性能数据

Detectable by VMware SkylineTM

Actions

Copy

link to clipboard
copied!

Print

Language:
Chinese (Simplified)JapaneseEnglish

Attachments

Additional Resources

KB
•
End Of General Availability of the Free vSphere Hypervisor (ESXi 7.x and 8.x) (2107518)

KB
•
Download and Install VMware Fusion (2014097)

Results 1-2 of 2

Ask The Community

Get answers quickly from VMware experts in the community

Post Subject

CONTINUE IN COMMUNITIES

Related Products:

VMware vSphere ESXi

VMware vSphere ESXi

Related Versions:

VMware vSphere ESXi 8.0

VMware vSphere ESXi 7.0.0

VMware vSphere ESXi 7.0.0

VMware vSphere ESXi 6.7

Take Our Survey

Support Assistant