Virtu-Al.Net

Virtually everything is poshable

PowerCLI: Reading host log files

Recently I needed to check the vmkernel log file on a host for any errors relating to a disk issue I was having, I did this in the normal way of using putty to get to my server and then a cat /var/log/vmkernel.  That is one way of doing it but did you know you could also do this through PowerCLI and add some automation into it ?  Well you can….

There is a cmdlet called Get-Logtype, if we connect to a VirtualCenter and then run this you will see the following:

Get-LogType

image

so these are the VirtualCenter log files, but what if we want to get a hosts log files, lets try this:

Get-VMHost Testesx01* |Get-LogType

image

That’s better now we can see the log files we are interested in, now we need to read the log file for the server, this can be done using the Get-Log cmdlet as so:

(Get-Log -VMHost (Get-VMHost testesx01*) vmkernel).Entries

image

That’s great but as we all know we don’t really want to get all the information from the vmkernel log file as most of it is irrelevant, what we really need are any warning messages.

This is easily achievable with the power of PowerCLI and PowerShell:

(Get-Log -VMHost (Get-VMHost testesx01*) vmkernel).Entries | Where {$_ -like *WARNING*}

image

Just one more thing that will be added as part of the next version of the Daily Report which will be posted this week.

, ,

13 Responses to “PowerCLI: Reading host log files”

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>