How to: Setup ESXi alerting monitor with email notification

Many times I wanted to see if I could send a notification by mail about the status of my ESXi machines. There seems to be a solution by using PERL and VMWare VSphere CLI. Firstly you will need to download and install the PERL and VMWare VSphere CLI and here are the links to download them.

Note: This is for the free ESXi version

PERL
http://strawberryperl.com/

VMWare VSphere CLI
https://my.vmware.com/group/vmware/details?downloadGroup=VSP510-VCLI-510&productId=285

After you download the above, install them. It’s simple as it’s just Next, Next, Next.

Now to create the batch file script. Use the following to send an email of the ESXi server with all the information including alerts.

"C:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" script.pl --server [serverip] --username [username] --password [password] --mailhost [smtpserver] --maildomain [domain name] --mailfrom noreply@myserver.com --mailto reports@mydomain.com;otheruser@mydomain.com

If you want to send only an email with alerts (if there are) use the following batch file script

"C:\Program Files\VMware\VMware vSphere CLI\Perl\bin\perl.exe" script.pl --server [serverip] --username [username] --password [password] --mailhost [smtpserver] --maildomain [domain name] --mailfrom noreply@myserver.com --mailto reports@mydomain.com;otheruser@mydomain.com --cpuwarnpc 85 --memwarnpc 85 --dswarnpc 25 --dscriticalpc 10 --warnofsnapshots --warnonchange --warnonalerts --concise --logfile esx-health.log --statusfile esx-health-status.txt

Note: The script is looking for the perl.exe under the VMWare CLI. If you change the location of the CLI installation, change the first part of the script.

Script download: http://noelpulis.com/files/esxi_monitor_script.zip
Source: http://blog.peacon.co.uk/hardware-health-alerting-with-esxi/

(15733)

Leave a Reply

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