vHerseyVMware

Morning vHealth Email From vSphere Health Check Report Script

The VMware vSphere Health Check Report is a free script written by @lamw (Check out his site virtuallyGhetto for some other handy scripts) that generates an HTML report on the health of a vSphere 4.x or 5.x environment. The report script is well documented, easily installed and configured, and can be downloaded from here: http://communities.vmware.com/docs/DOC-9842

I run the VMware vSphere Health Check Report script from my vSphere Management Assistant 5.0 (vMA). Each day at 6:00 AM the script is run to generate a nice HTML report of my vSphere environment and then email it to me.

Installation of the script is pretty straight forward. Just download the zipped tar file, unzip and untar (I did this in the /home/vi-admin/bin directory on the vMA), and the script is basically ready to go. For the script to send email a few options need to be set in the healthCheck.conf file. EMAIL_HOST, EMAIL_DOMAIN, EMAIL_TO, and EMAIL_FROM need to be configured, pretty self explanatory.

Create a shell script, /home/vi-admin/bin/AMcheck.sh, that calls the Health Check Report script with all the command line options and set the script to be executable by the vi-admin user (chmod +x). Note that if your password contains certain special characters (! or – that I know of) you will need to use single quotes (‘) around it.

You could just add the vmwarevSphereHealthCheck.pl and its options to crontab but I find it easier to manage and edit if I do this in a separate shell script. This is just my personal preference.

#!/bin/bash
#Run vmwarevSphereHealthCheck with options

/home/vi-admin/bin/vmwarevSphereHealthCheck/vmwarevSphereHealthCheck.pl --server vCenterServer --username vReportUser --password 'vReportUserPassword' --type vcenter --conf /home/vi-admin/bin/vmwarevSphereHealthCheck/healthCheck.conf --email yes

Test the AMhealth.sh script by running it, just type /home/vi-admin/bin/AMhealth.sh.

Generating VMware vSphere Health Report v5.0.2 "vmware_health_report.html" ...

This can take a few minutes depending on the size of your environment.
Get a cup of coffee/tea/beer and check out http://www.virtuallyghetto.com

Start Time: 12-29-2011 15:06:15
End   Time: 12-29-2011 15:07:01
Duration  : 46 Seconds

If you have the email options configured correctly you should receive the report in your email when the script completes.

Now add the AMcheck.sh script to vi-admin’s crontab. While logged in as vi-admin edit crontab using crontab -e and add the following line:

0 11 * * * /home/vi-admin/bin/AMcheck.sh > /dev/null 2>&1

The timezone on my vMA is set to UTC. 11:00 UTC = 6:00 AM EST. I redirect all the output and errors to /dev/null. To redirect to a file just change the path. If you need information on crontab entries check here or use the man page (man crontab).

List out vi-admin’s crontab to make sure the changes are there using crontab -l.

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXTAVicE installed on Thu Dec 29 15:01:53 2011)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
0 11 * * * /home/vi-admin/bin/AMcheck.sh > /dev/null 2>&1

Now I get an email every morning at around 6:00 AM with the HTML report attached. Even looks great when viewed on an iPad.

2 thoughts on “Morning vHealth Email From vSphere Health Check Report Script

  • Andrew Golubenkoff

    Hi, how can i run this script in vMA 5.5? i Start scrip & get error:

    Error: This script only supports vSphere “4.0.0 4.1.0 5.0.0 5.1.0” or greater!

    Reply
    • Michael

      I got the same error. 🙁

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

seventeen − eleven =