blurredvision
Lifer
I'm in need of a good script to parse event logs for warnings and errors, and found that Microsoft's Log Parser does the trick quite nicely. However, I'm running into an issue. As a system administrator, I parse the logs of many, many servers once per month. I've got the following script written to parse the system logs:
This brings back a datagrid with just warnings and errors, groups duplicates and gives me a count of how many there are of each. This is exactly what I'm looking for, however I still need to be able to specify to bring back only the records that are within the past 30 days since I do this monthly. I don't want everything that's on the system every time I run it. I know that I can pull the TimeGenerated field and use that to specify to report back a certain period, but if I pull that field, then it breaks my DISTINCT command, which is basically the crowning jewel of what I'm ultimately trying to do here (sorting through dozens/hundreds of repeated entries).
Any thoughts?
Code:
logparser "SELECT DISTINCT EventTypeName, EventID, SourceName, Message, Count(*) AS Entries FROM System WHERE EventTypeName = 'Warning event' OR EventTypeName = 'Error event' OR EventTypeName = 'Critical event' GROUP BY EventID, Message, SourceName, EventTypeName ORDER BY EventTypeName,Entries DESC" -i:EVT -o:DATAGRID -rtp:-1
This brings back a datagrid with just warnings and errors, groups duplicates and gives me a count of how many there are of each. This is exactly what I'm looking for, however I still need to be able to specify to bring back only the records that are within the past 30 days since I do this monthly. I don't want everything that's on the system every time I run it. I know that I can pull the TimeGenerated field and use that to specify to report back a certain period, but if I pull that field, then it breaks my DISTINCT command, which is basically the crowning jewel of what I'm ultimately trying to do here (sorting through dozens/hundreds of repeated entries).
Any thoughts?