Tuesday, August 2, 2011

Monitoring Standalone ESX\ESXi Server hardware with the VMA


Monitoring Standalone ESX\ESXi Server hardware with the VMA



The below article explains how to setup a perl script to generate a daily email showing the hardware status of your VMware ESX/ESXi servers. In the below example we are using a VMA to run the perl scripts but you could also do this as a scheduled task on a windows host (with the vmware vsphere client installed)

If you haven’t setup the vMA please see my article on this setup-the-vsphere-management-assistant

Step 1 – Upload the Esx-health.pl script to your VMA server

I currently use the excellent esx-health.pl script originally developed by William Lam with additional modifications from James Pearce.
Cut and paste the code from http://blog.peacon.co.uk/wiki/Esx-health.pl_code into a notepad document and save as Esx-health.pl (Be sure you read and agree to the terms of use.)
Then copy this perl script to your VMA. I use Veeam Backup & FastSCP for this.

Step 2 – Execute code

Connect to the VMA and change to the directory where you copied the Esx-health.pl script
Navigate to the directory where you have copied the perl script and make sure you have execure permissions by entering:
chmod +x Esx-health.pl

Execute the below command:
./Esx-health.pl –server –username root –mailhost –maildomain –mailfrom ESXMonitor@ –mailto
Note – I find issues when pasting hypens (i.e. “-”) if you get an error running this command try deleting and retyping the hypen. Weird but seems to work.
Note that the command is case sensitive
You will be prompted for the password for the ESX server.
You should shortly receive the health check email
If you don’t receive this email then it may be due to the SMTP server not being setup to allow relays from the VMA’s IP

Step 3 – Schedule the script to run

In the below example I am scheduling the perl script to run everyday.
  • Logon to the VMA and enter the command crontab – e
  • Enter the command to run the perl script. The below command will run daily at 08:01
  • 01 08 * * * ./Esx-health.pl –server –username root –password –mailhost –maildomain –mailfrom ESXMonitor@ –mailto
  • Once you have entered this press CTRL + C to exit
  • Then type :wq to save and quit
Note – I haven’t found a way to send to more than 1 email receipient. If you want to send to multiple recipients then I recommend setting up a separate cron job for each
  • You can verify your entry is listed by running crontab –l
Note – To avoid passing the root password in plaintext you can use vifastpass
Please Click any of the following link

Share this

0 Comment to "Monitoring Standalone ESX\ESXi Server hardware with the VMA"

Post a Comment