#! /bin/csh -f # Gets dates of all requests in the files # "http.error.*" and "http.log.*" in the current directory. # Writes a shell script "httpd.greps" that will merge and split # those logs into per-day logs. set TMP = "/tmp/$$-http" set DEF = "httpd-greps" ls http.error.[A-Z][a-z][a-z][0-9][0-9][0-9][0-9] > ${TMP}-err.dir ls http.log.[A-Z][a-z][a-z][0-9][0-9][0-9][0-9] > ${TMP}-log.dir foreach t ( err log ) /bin/rm -f ${TMP}-$t.dates foreach f ( `cat ${TMP}-$t.dir` ) echo '=== '$f' ===' nice sed \ -e '1,$s/^[^[]*\[\([^:]*\):.*$/nice grep \1 '"$f"' >> http-'"$t"'-\1/' \ $f \ | nice sort -u \ | nice sed \ -e 's@-\([0-9][0-9]\)/\([A-Z][a-z][a-z]\)/19\([0-9][0-9]\)@-\3-\2-\1@g' \ -e 's@-Jan-@-01-@g' \ -e 's@-Feb-@-02-@g' \ -e 's@-Mar-@-03-@g' \ -e 's@-Apr-@-04-@g' \ -e 's@-May-@-05-@g' \ -e 's@-Jun-@-06-@g' \ -e 's@-Jul-@-07-@g' \ -e 's@-Aug-@-08-@g' \ -e 's@-Sep-@-09-@g' \ -e 's@-Oct-@-10-@g' \ -e 's@-Nov-@-11-@g' \ -e 's@-Dec-@-12-@g' \ | sort \ >> ${DEF}-$t.csh end end /bin/rm -f ${TMP}-*