Wednesday 3 August 2011

Quick and Dirty Log Viewing

I've been running some reallocates on some NetApp volumes, however you need to keep checking the syslogs. We send these to our syslog server which archives them daily so we can go back days, weeks and years should we need old logs, I needed a quick way of going through the logs and looking for what I wanted which was any messages related to this task, easy! - Yeah that easy I'll forget, hence this post.

Anyway simple 15 year old MS-DOS will do the first bit... list all the files in the current folder...

for /r in %i in (*) do @echo %i

There, simples a list of the logs.. now to find what I want..

well yeah you can use find but I prefer to use grep and have the gnu tools installed on my windows box here

so the following should do the trick..

for /r %i in (*) do type %i|grep wafl.reallocate

well it would but it was a bit lacking, quick check of the logs suggests I want wafl.scan too.. Quick google for doing OR with grep (Dont suggest RegEx!) suggest that you use egrep wafl.scan|wafl.reallocate..

hmm check the help... ahh
`egrep' means `grep -E'.

for /r %i in (*) do type %i|grep -E "wafl.scan|wafl.reallocate"

Done - I think!

No comments:

Post a Comment