I have log files of size of the order of several 100 MBs, containing lines like this, containing the date-time information in the beginning:
[Tue Oct 4 11:55:19 2016] [hphp] [25376:7f5d57bff700:279809:000001] [] \nFatal error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ')' in /var/cake_1.2.0.6311-beta/app/webroot/openx/www/delivery/postGetAd.php(12479)(62110d90541a84df30dd077ee953e47c) : eval()'d code on line 1
I have a plugin (nagios check_logwarn) to print out only those lines which contain some of the error strings. Following is the command to run it:
/usr/local/nagios/libexec/check_logwarn -d /tmp/logwarn -p /mnt/log/hiphop/error_20161003.log "^.*Fatal error*"
I want to filter out further, based on the date-time, i.e., all the lines which are after, say, 11:55:10.
I am not sure whether to use regex for this. Following is what I have so far:
/usr/local/nagios/libexec/check_logwarn -d /tmp/logwarn -p /mnt/log/hiphop/error_20161003.log "^.*Fatal error*" | grep "15\:19\:1*"
But this will only filter those logs whose time is in the 19th minute of the 15th hour.
Update
I am now able to compare the time part of the date-time.
/usr/local/nagios/libexec/check_logwarn -d /tmp/logwarn -p /mnt/log/hiphop/error_20161004.log "^.*Fatal error*" | awk '$4 > "14:22:11"'
How do I compare the day part?
Update 2 - opening bounty
I am having to open a bounty because I do not have much expertise with shell and I need a solution soon.
I am stuck at the part of comparing the dates. With The solution https://stackoverflow.com/a/39856560/351903, I am facing this problem. If that is fixed, I would be happy.
I am also open to some enhancement to this (I don't mind if the output has some jumbled up order of logs) -
/usr/local/nagios/libexec/check_logwarn -d /tmp/logwarn -p /mnt/log/hiphop/error_20161004.log "^.*Fatal error*" | awk '$4 > "14:22:11"'
I looked for some date-time to timestamp comparison, but couldn't find something working.
I am not able to proceed from what is given in this question. I cannot see the timestamp value using this -
echo date -d '06/12/2012 07:21:22' +"%s"
Not sure what am I missing.