I’m all alone in a group where I’m becoming a one man devops crew and working on the start of some logging/monitoring scripts that I need some feedback on, so I’ll get right to it.
I am doing log analysis and need to extract some information out of each log file. In this world there are 200 nodes. Each node has several subdirectories (Days), and each day has multiple log files depending on how many times they booted.
\Node001\day001\log001\Logfile.log
I’m starting with one log file and I will scale up from that. I have a start, that works but I’m pretty sure I’m going at this the wrong way.
I’m looking to the group to get some better suggestions on how to do this.
If you are looking on how to process these logs, you should look at Get-ChildItem and Get-Content to recurse the directory structure and open and parse the logs.
#Assuming C:\Nodes is the root of the logs
foreach ($file in (Get-ChildItem -Path C:\Nodes -Include *.log -File -Recurse)) {
"Processing log file {0}" -f $file
foreach ($line in Get-Content $file.FullName) {
#Do something in each log
}
}
First, I want to say thank you to Don for all of the powershell material you have put out. The videos and books have gotten me to this point and I really appreciate all of your time and effort. I’m sure that when I actually get time to actually read the entire lunches book, and the Dev ops manifesto
My apologies that my post was so vauge and missing the GIST that I thought I attached, however after reading all of this, I am working on a new version.