Hello there,
I'm monitoring 20 asterisk servers and I've developed a small php utility that displays me their errors when they happen.
Currently I'm using the something like this:
tail -5000 /var/log/asterisk/full | egrep -i "ERROR|WARNING" > errors.log
The problem with this is that some servers are getting more traffic then others resulting that on one box 5000 lines might last 5 hours and on another 5 minutes. And as such what I see on the screen might be outdated by a few hours or scrolls too fast for me to see.
I'd like to know what would be the most efficient command to extract only the last 60 minutes and perform my egrep on that. Cron is setup every minute.
Here's a sample of the log format:
Code:
[Apr 9 08:21:38] VERBOSE[13499] logger.c: Found request for channel [1239279644.1537]
[Apr 9 08:21:38] VERBOSE[13499] logger.c: CTI Asked for EXECAPP on channel [Zap/16-1], App [SBR_PLAY_ANNOUNCEMENT], Params [B310_CSMR_DAY_Fr_Dec08], confirmRequest [0]
[Apr 9 08:21:38] VERBOSE[13499] logger.c: Searching CallRoute with tracknum [1239279666.1543]
[Apr 9 08:21:38] VERBOSE[13499] logger.c: Found request for channel [1239279666.1543]
[Apr 9 08:21:39] VERBOSE[13499] logger.c: CTI Asked for EXECAPP on channel [Zap/16-1], App [MusicOnHold], Params [], confirmRequest [0]
[Apr 9 08:21:39] VERBOSE[13499] logger.c: Searching CallRoute with tracknum [1239279666.1543]
I've googled a bit but the things I found do not work.
For example:
grep -A 5 "Apr 9 08:21:38" full
Should return 5 lines after the match, but all it does it matches every "Apr 9 08:21:38" like a normal grep.
I wanted to do some kind of `date --date="1 hours ago"` and format that to feed the script so it selects everything below that var. And egrep the rest for errors.
Any input appreciated. Thank You
