I have a requirement to write a script to get the number of errors generated during a time period. How can I achieve this.
To be exact, I need to get the number of 404 or 500 errors generated during a time period from 01 to 02 hrs from a webserver access log.
Any help will be appreciated.
Thanks
Sriram
What have you tried so far ?
Can you please post sample input and the expected output that would be a lot easier to proceed ?
marconi
3
Hey,
I had posted a similar kind of my Query in a thread, 'Korne Shell Problem'. But there has been no response.
This site seems to have a policy of frowning on people who post 'homework'. So, don't expect much help from anyone.
Thanks,
Marconi.
whats is this ? 


Please read the rules of the forum ! 
I need to get the no. of http 404 errors occured during a time period from 1 PM to 2 PM from the access.log file.
#!/bin/sh
echo "Enter the log file directory:"
read logdir
echo "Enter the log file name:"
read logfile
echo "Enter the Error Code:"
read error
echo "Enter the time in (24 hours) which you want to see the number of:"
read time
echo "---------------------------------------------"
echo "No. of $error errors occured during $time to `expr $time + 1` hours is:"
cat $logdir/$logfile | awk '{print $9}' | grep -i $error | wc -l
cat $logdir/$logfile | awk '{print $4}' | cut -d ":" -f2 | grep -i $time
How can I grep the time range from the access log. The access log has the below format
9.126.7.15 - - [27/Nov/2007:14:20:30 +051800] "GET /images/notes.gif HTTP/1.1" 200 170