I'm trying to pull some information out of a log file, looking back over a specific period of time (e.g. the past hour). I've found the following awk construct that works, capturing the data as a variable:
myvar="$(awk '$0>=from&&$0<=to' from="$(date +%b" "%d" "%H:%M:%S -d -10minute)" to="$(date +%b" "%d" "%H:%M:%S)" /var/log/messages)"
I'd like to be able to get certain information from that variable, and use it to create an alarm, but I'm not sure how to do it, is it by using Grep or something else?
If anyone knows the solution, and can show me how, I'd very much appreciate it.
Here's some more detail: this is only an example. Say I look back over syslog for the past hour, saving all output as a variable with the awk construct above. Now, I want to parse out some data as the basis for sending an alerting email e.g. the keyword (or key phrase) "kdump" from "Apr 16 12:32:26 satest01 kdump: kexec: loaded kdump kernel". How would I extract that information from my variable?