vCheck (Daily Report)
Alan Renouf is a community peer for VMware PowerCLI, Virtu-Al.Net. In 2009, he was named a vEXPERT by VMware. Alan's main focus is to teach and help other VMware admins automate their VMware infrastructures and make their lives easier through automation.
www.virtu-al.net.
Introduction
vCheck is a vCenter checking script, the script is designed to run as a scheduled task before you get into the office to present you with key information via an email directly to your inbox in a nice easily readable format.
This script picks on the key known issues and potential issues of the virtual infrastructure and reports it all in one place so all you do in the morning is check your email.
One of they key things about this report is if there is no issue in a particular place you will not receive that section in the email, for example if there are no datastores with less than 5% free space (configurable) then the disk space section will not show in the email, this ensures that you have only the information you need in front of you when you get into the office.
This script is not to be confused with an Audit script, I don't want to remind you that you have 5 hosts and what there names are and how many CPU’s they have each and every day as you don't want to read that kind of information unless you need it, this script will only tell you about problem areas with your infrastructure.
What is checked for ?
The following items are checked for by default but these can be disabled individually to make the script run faster and remove unwanted items from the report, see “Configuring the script” below for details.
- General Details
- Number of Hosts
- Number of VMs
- Number of Templates
- Number of Clusters
- Number of Datastores
- Number of Active VMs
- Number of Inactive VMs
- Number of DRS Migrations for the last days
- Snapshots over x Days old
- Datastores with less than x% free space
- VMs created over the last x days
- VMs removed over the last x days
- VMs with No Tools
- VMs with CD-Roms connected
- VMs with Floppy Drives Connected
- VMs with CPU ready over x%
- VMs with over x amount of vCPUs
- List of DRS Migrations
- Hosts in Maintenance Mode
- Hosts in disconnected state
- NTP Server check for a given NTP Name
- NTP Service check
- vmkernel warning messages ov the last x days
- VC Error Events over the last x days
- VC Windows Event Log Errors for the last x days with VMware in the details
- VC VMware Service details
- VMs stored on datastores attached to only one host
- VM active alerts
- Cluster Active Alerts
- If HA Cluster is set to use host datastore for swapfile, check the host has a swapfile location set
- Host active Alerts
- Dead SCSI Luns
- VMs with over x amount of vCPUs
- vSphere check: Slot Sizes
- vSphere check: Outdated VM Hardware (Less than V7)
- VMs in Inconsistent folders (the name of the folder is not the same as the name)
- VMs with high CPU usage
- Guest disk size check
- Host over committing memory check
- VM Swap and Ballooning
- ESXi hosts without Lockdown enabled
- ESXi hosts with unsupported mode enabled
- General Capacity information based on CPU/MEM usage of the VMs
- vSwitch free ports
- Disk over commit check
- Host configuration issues
- VCB Garbage (left snapshots)
- HA VM restarts and resets
- Inaccessible VMs
Prerequisites
The following will need to be installed for you to run this script:
- PowerShell V2
- PowerCLU 4.0 U1 or later version
- vCenter 2.5 or later version
Configuring the script
All configuration is stored at the top of the script, it is recommended you check the configuration and change the thresholds before running the script as this will help the script focus on your issues and best practices.
Changing the email information
Just after the comments you will find the following information:
1 # You can change the following defaults by altering the below settings: #
2 # Set the SMTP Server address $SMTPSRV = "mysmtpserver.mydomain.local"
3 # Set the Email address to recieve from
4 $EmailFrom = "me@mydomain.local"
5 # Set the Email address to send the email to
6 $EmailTo = "me@mydomain.local"
This information will need to be adjusted to your specific requirements in order for the email to work.
If you wish to add multiple recipients then change the $EmailTo to the following:
|
1
|
$EmailTo = “user@domain.com,user2@domain.com" |
Setting the thresholds
This will help the script focus on the specific areas you want to report on, it can be used to define your own best practices.
Just after the comments will be a “Detail Settings” part of the script, under here will be a variable for each setting, these are described by a comment before and will need to be changed to fit in with your own specific requirements.
An example is setting the ntp server, to do this change the current setting to match your configuration:
Before
|
1
2
|
#The NTP server to check$ntpserver = "pool.ntp.org" |
After
|
1
2
|
# The NTP server to check$ntpserver = "ntp.mycompany.mydomainname.internal" |
Running the script
The script is currently in “html view mode”, this means that after you have run the script it will display a HTML report with any errors which may be relevant, it is useful to run it in this mode until you are happy with the results, you can then change it to “Email mode”.
To do this, find the area just after you have set the email settings and change the following variables to the required output:
|
1
2
3
|
$DisplaytoScreen = $true$SendEmail = $false |
To run the script from the PowerCLI prompt simply cd into the folder where the script is located and type the script name followed by your vCenter name as below:
.\vCheck5.ps1 vCenter01
Example:
Customising the report colours
Near the top of the report, just after the version comments will be two areas where you can define custom colours, use these to set the colours of the headings as below:
Main Title bar
|
1
|
$Colour1 = "CC0000" |
Check bar
|
1
|
$Colour2 = "7BA7C7" |
Adjusting connection information
In some cases you will need to adjust the connection information used by the connect-viserver cmdlet to connect to your vCenter, this can be adjusted on line 701 as below:
Before
|
1
|
$VIServer = Connect-VIServer $VISRV |
After
|
1
|
$VIServer = Connect-VIServer $VISRV –user “AlternateUsername” –Pass “Alternatepassword” –Protocol Https |
Example report
An example report can be seen by clicking the below image or here, please note that not all checks are triggered here.
Download
- xtravirt's blog
- Login or register to post comments
Spotlight:
VMware Documentation Downloader v11.08.30
Updated for vSphere 5 - A free tool for those on the move who need information FAST
vSphere 5 License Entitlement Changes
See what has changed in the license entitlement in vSphere 5?
Thin Client vs Zero Client
The differences between Thin and Zero desktop clients for VDI


