alanrenouf / vCheck-vSphere

vCheck Daily Report for vSphere
MIT License
735 stars 325 forks source link

44 VMKernel Warnings - want to filter some messages out #191

Closed randy16randy closed 10 years ago

randy16randy commented 10 years ago

Hopefully this is also the place to post questions...

In plugin 44 for VMKernal Warnings, I want to be able to filter out certain messages from the vCheck report. Its OK that they stay in vCenter so I have the full history there so i want to do it within the plugin script but do not know how.

I assume it is this line (9) that would be modified: $Warnings = (Get-Log -vmhost ($VMHost.name) -Key messages -ErrorAction SilentlyContinue).entries |where {$ -match "warning" -and $ -match "vmkernel"}

if I add another AND to the end so that it does NOT report messages where the message text includes "unsupported ioctl 58" I can't seem to get the syntax correct. I know SQL scripting but couldn't find any similar examples to help me with this.

Thanks!

The full script I am using for that plugin is:

Start of Settings

# End of Settings 
$VMKernelWarnings = @()
foreach ($VMHost in ($HostsViews)){

    $product = $VMHost.config.product.ProductLineId
    if ($product -eq "embeddedEsx" -and $VIVersion -lt 5){
        $Warnings = (Get-Log -vmhost ($VMHost.name) -Key messages -ErrorAction SilentlyContinue).entries |where {$_ -match "warning" -and $_ -match "vmkernel"}
        if ($Warnings -ne $null) {
            $VMKernelWarning = @()
            $Warnings | % {
                $Details = "" | Select-Object VMHost, Message, Length, KBSearch, Google
                $Details.VMHost = $VMHost.Name
                $Details.Message = $_
                $Details.Length = ($Details.Message).Length
                $Details.KBSearch = "<a href='http://kb.vmware.com/selfservice/microsites/search.do?searchString=$Message&sortByOverride=PUBLISHEDDATE&sortOrder=-1' target='_blank'>Click Here</a>"
                $Details.Google = "<a href='http://www.google.co.uk/search?q=$Message' target='_blank'>Click Here</a>"
                $VMKernelWarning += $Details
            }
            $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique |select VMHost, Message, KBSearch, Google
        }    
    }
    else
    {
        $Warnings = (Get-Log –VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | where {$_ -match "warning"}
        if ($Warnings -ne $null) {
            $VMKernelWarning = @()
            $Warnings | % {
                $Details = "" | Select-Object VMHost, Message, Length, KBSearch, Google
                $Details.VMHost = $VMHost.Name
                $Details.Message = $_
                $Details.Length = ($Details.Message).Length
                $Details.KBSearch = "<a href='http://kb.vmware.com/selfservice/microsites/search.do?searchString=$($Details.Message)&sortByOverride=PUBLISHEDDATE&sortOrder=-1' target='_blank'>Click Here</a>"
                $Details.Google = "<a href='http://www.google.co.uk/search?q=$($Details.Message)' target='_blank'>Click Here</a>"
                $VMKernelWarning += $Details
                }
            $VMKernelWarnings += $VMKernelWarning | Sort-Object -Property Length -Unique |select VMHost, Message, KBSearch, Google            
        }
    }
}    

$VMKernelWarnings | sort Message -Descending

$Title = "VMKernel Warnings"
$Header =  "ESX/ESXi VMKernel Warnings: $(@($VMKernelWarnings).Count)"
$Comments = "The following VMKernel issues were found, it is suggested all unknown issues are explored on the VMware Knowledge Base. Use the below links to automatically search for the string"
$Display = "Table"
$Author = "Alan Renouf"
$PluginVersion = 1.1
$PluginCategory = "vSphere"
Sneddo commented 10 years ago

Hi Randy,

try this: $Warnings = (Get-Log –VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | where {$_ -match "warning" -and $_ -notmatch "unsupported ioctl 58"}

Probably worth looking at providing a way to filter kernel warnings for stuff like this...

let me know how you go

randy16randy commented 10 years ago

Perfect! Thanks.

-Randy-

From: Sneddo [mailto:notifications@github.com] Sent: Sun, April 27, 2014 10:00 PM To: alanrenouf/vCheck-vSphere Cc: Randy Redekopp Subject: Re: [vCheck-vSphere] 44 VMKernel Warnings - want to filter some messages out (#191)

Hi Randy,

try this: $Warnings = (Get-Log –VMHost ($VMHost.Name) -Key vmkernel -ErrorAction SilentlyContinue).Entries | where {$ -match "warning" -and $ -notmatch "unsupported ioctl 58"}

Probably worth looking at providing a way to filter kernel warnings for stuff like this...

let me know how you go

— Reply to this email directly or view it on GitHubhttps://github.com/alanrenouf/vCheck-vSphere/issues/191#issuecomment-41521293.