Sunday, August 7, 2011

Using ESXTOP end to end

ESX using esxtop:

Esxtop is a powerfull CLI tool on ESX server to take a look at performance counters of an ESX system, including the resources that the Virtual Machines (VMs) take. In this short walkthrough I will explain in a general matter how to setup performance logging to a separate Windows share from an ESX server.


We can use esxtop to monitor CPU, memory, network, and disk I/O.

First of all I presume you are a little familiar with Windows, Linux, the ESX CLI and esxtop as a command. Do not worry, I will point out most of the command switches we are going to need, but at least you should know what esxtop is used for.

Create the Windows share

First we are going to create a share on a Windows workstation or server. This share will be used for storing the generated log files.
  • Connect to a Windows PC or server with sufficient free space (logging can easily take a few MegaBytes per minute / ESX server).
    • Create a new local user account

      • Provide a username, will we using “esxlog” in this example
      • Provide a password and make sure the user does not have to change the password at the next login.
    • Create a folder an share

      • Create a folder name “esxlog” on the host (example 2003 server)
      • Share the folder by right clicking it, pick “Properties” and the tab “Sharing”

        • Select “Share this folder” and share the folder as “esxlog’
        • Click “Permissions”
        • Remove “Everyone”
        • Add the newly created user “esxlog”, and give Full Control.
    • Close all dialogs

Mount the share on ESX

Secondly we will mount the share we just created on the ESX server, and make sure we can places a file on it.
  • Log into the Virtual Center Client and connect to the ESX host logging will be configured on.
    • Goto the tab “Configuration” and select “Security Profile”
    • Click “Properties” and tick the checkbox in front of “SMB Client”
      vc-firewall
    • Close alle dialogs
  • Log into the esx server using ssh as root (if there is no root account prefix all following commands with sudo).
  • Mounting and testing the share
    • Create a directory on the ESX server in the “mnt”directory
    • mkdir /mnt/esxlogfiles 
    • Mount the Windows share on the ESX host using:
    • mount -t smbfs -o username=esxlog ///esxlog /mnt/esxlogfiles 

    • Provide the password when prompted
    • Create a testfile on the share:
    • touch /mnt/esxlogfiles/test.log 
      Check the Windows host to see if the file is created there.

Configure esxtop

This is where you dertermine what you will be loggin. esxtop Provides various options for logging. You can use esxtop to log the following. The letter behind the item is used to see this data in esxtop. Start esxtop and press this letter to see the default data.
  • CPU data – c
  • Memory data – m
  • Network data – n
  • Disk – d
  • ESX disk devices – u
  • Virtual Machine disk devices – v

You can modify the columns shown in the various screens by pressing the letter f. A detailed explanation of all columns can be viewed in the esxtop helpfile.

Type the followingto show the help.

man esxtop

You can change the logfile interval by pressing the letter s. Enter a number of seconds to change. The minimum is 2.

After you are done press a capital W to save your settings. You can use the default proposed filename, or provide a custom one.

Starting esxtop in batch mode

Before we execute or schedule the command we test it. We start esxtop with some parameters. Use:
  • -b To start in batchmode (obligatory)
  • -d The number of seconds between the logging intervals
  • -n The number of iterations
  • > Pipe the output to a file (on the mounted Windows share)

Combining these options gives us the following esxtop batch mode example:

esxtop –b –d 3 –n 20 >/mnt/esxlogfiles/.csv

Running this should provide a logfile on the Windows share with 1 minute of logging data (20 iterations of 3 a second interval)

Check the logfile and verify it provides the data you want to collect! Esxtop always provides generic data like processor, memory and swapfile logdata.

Also make sure the time on the server is correctly. Preferably a NTP server.

Starting esxtop in the background

When you want to start esxtop in the background, including the option to completely quit your session, prefix the command with nohup and add the “&” to the end of the command line. This looks like:

nohup esxtop –b –d 3 –n 20 >/mnt/esxlogfiles/.csv &

Do not forget to change the number of interations!

Schedule esxtop to start logging

A third option to start the esxtop in batchmode is to use the crontab to schedule it.

Presumed you are still logged in to the CLI, do the following:

  • Open the default crontab for the current user (root!) by typing
  • crontab –e
  • Add a line to the crontab file. We use the esxtop line tested earlier and add the crontab data (time in this example)
  • 00 12 * * * esxtop –b –d 3 –n 20 >/mnt/esxlogfiles/.csv

This example schedules the command every day at 12:00 hours.

If you only want to run this command a limited number of times do not forget to remove the entry. Again substitute the number of iterations for the number you would like the logging to run.

Log file analysis

When logging has finished you can view the log file using Microsoft excel of Permon. You can import the CSV file into these applications.

Perfmon example
  • Start perfmon (start, run, perfmon)
  • Select “Performance Monitor”, en right click it.
  • Click “Properties”
  • Goto the tab “Source”
  • Click logfiles and choose “Add”
  • Select the created logfile and click “Open”
  • Close the dialog by clicking OK.
  • Goto the tab “Data” and click “Add”
  • Select the counter you would like to see, en add them to the view
    perfmon-addcounters

  • Enjoy too much data in a graph. ;-)
    perfmon-showgraph

Original Source: http://www.b3rg.nl/blog/blog-it/performance-logging-on-esx-using-esxtop.html

No comments:

Post a Comment