Additional checks for vCheck Daily Report

I have been using the vCheck v5 for several months and have nothing but good things to say about it. The script has helped me find and resolve several issues in the environments I maintain. There are a few additional checks that I have come up with myself, but I usually run those manually once a month or so and then view the output from a command prompt. I have spent a couple of hours recently retro-fitting the scripts I use into vCheck format and then adding them to the existing script. If you would like to use these checks, please get the full script from here (after leaving a quick thank-you for Al). Here are my additions:

[cc lang=”powershell” width=”550″ height=”700″]
#Stuff added by bwuch:
$ShowThickDisk = $true
$ShowMisnamedVM = $true
$ShowWrongOS = $true
$ShowWrongSyslog = $true
$syslogserver = “Your_syslog_server:514”
$ShowRemoteTSM = $true

if ($ShowThickDisk) {
Write-CustomOut “..Checking for thick provisioned virtual disk files”
$thickdisks = @()
foreach ($vmguest in ($VM | get-view))
{
$name = $vmguest.name
$vmguest.Config.Hardware.Device | where {$_.GetType().Name -eq “VirtualDisk”} | %{
if(!$_.Backing.ThinProvisioned){
$myObj = “” |
select Name,Label,File,CapacityGB
$myObj.Name = $name
$myObj.Label = $_.DeviceInfo.Label
$myObj.File = $_.Backing.FileName
$myObj.CapacityGB = [math]::round(($_.CapacityInKB / 1024 / 1024),2)
$thickdisks += $myObj
}
}
}
If (($thickdisks | Measure-Object).count -gt 0) {
$myReport += Get-CustomHeader “Thick provisioned virtual disks : $($thickdisks.count)” “Standard virtual disks in this environment are thin provisioned. Thick provisioned disks represent a possible waste of storage space and should only be used when disk I/O performance is a top concern.”
$myReport += Get-HTMLTable $thickdisks
$MyReport += Get-CustomHeaderClose
}
}

#——————–
if ($ShowMisnamedVM) {
Write-CustomOut “..Finding mis-named VMs”
$misnamed = @()
foreach ($vmguest in ($VM | where { $_.Guest.HostName -ne $NULL -AND $_.Guest.HostName -notmatch $_.Name }))
{
$myObj = “” | select VMName,GuestName
$myObj.VMName = $vmguest.name
$myObj.GuestName = $vmguest.Guest.HostName
$misnamed += $myObj
}
If (($misnamed | Measure-Object).count -gt 0) {
$myReport += Get-CustomHeader “Mis-named virtual machines : $($misnamed.count)” “The following guest names do not match the name inside of the guest.”
$myReport += Get-HTMLTable $misnamed
$MyReport += Get-CustomHeaderClose
}
}

#——————–
if ($ShowWrongOS) {
Write-CustomOut “..Finding guests with wrong OS selected.”
$wrongOS = @()
foreach ($vmguest in ($VM | get-view |
where ({ $_.Guest.GuestFullname -ne $NULL -AND $_.Guest.GuestFullname -ne $_.Summary.Config.GuestFullName})))
{
$myObj = “” | select Name,InstalledOS,SelectedOS
$myObj.Name = $vmguest.name
$myObj.InstalledOS = $vmguest.Guest.GuestFullName
$myObj.SelectedOS = $vmguest.Summary.Config.GuestFullName
$wrongOS += $myObj
}
If (($wrongOS | Measure-Object).count -gt 0) {
$myReport += Get-CustomHeader “Guests with wrong OS $($wrongOS.count)” “The following virtual machines contain operating systems other than the ones selected in the VM configuration.”
$myReport += Get-HTMLTable $wrongOS
$MyReport += Get-CustomHeaderClose
}
}

#——————–
if ($ShowWrongSyslog) {
Write-CustomOut “..Checking VM Host syslog server”
$wrongSyslog = @()
foreach ($vmhost in ($VMH |
Where {$_.state -ne “Disconnected”} | Select Name, @{N=”SLServer”;E={$_ | Get-VMHostSyslogServer}} |
Where {$_.SLServer -notmatch $syslogserver}))
{
$myObj = “” | select Name,SyslogServer
$myObj.name = $vmhost.name
$myObj.SyslogServer = $vmhost.SLServer
$wrongSyslog += $myObj
}
If (($wrongSyslog | Measure-Object).count -gt 0) {
$myReport += Get-CustomHeader “Hosts with the wrong syslog specified $($wrongSyslog.count)” “The following hosts do not have a proper syslog specified.”
$myReport += Get-HTMLTable $wrongSyslog
$MyReport += Get-CustomHeaderClose
}
}

#——————–
if ($ShowRemoteTSM) {
Write-CustomOut “..Checking VM Host for remote TSM enabled”
$startingEAP = $ErrorActionPreference
$ErrorActionPreference=”SilentlyContinue”
$remoteTSM = @()
foreach ($vmhost in ($VMH))
{
$socket = new-object Net.Sockets.TcpClient
$socket.connect($vmhost,22)
if ($socket.Connected) {
$myObj = “” | select Name,Connected
$myObj.Name = $vmhost.name
$myObj.Connected = “TRUE”
$remoteTSM += $myObj
$socket.close()
}
}
$ErrorActionPreference = $startingEAP
If (($remoteTSM | Measure-Object).count -gt 0) {
$myReport += Get-CustomHeader “Hosts with remote tech support enabled $($remoteTSM.count)” “The following hosts have SSH/remote tech support mode enabled.”
$myReport += Get-HTMLTable $remoteTSM
$MyReport += Get-CustomHeaderClose
}
}

[/cc]

This entry was posted in Virtualization. Bookmark the permalink.

Leave a Reply

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

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.