#! /bin/csh -f set usage = "$0 [ -external | -unicamp | -local ] YAR MON TAG" # Reads per-day access and error logs for month MON, assumed to be in files # http-log-${YAR}-${MON}-${DAY}" and "http-err-${YAR}-${MON}-${DAY}", # writes a file called # http-day-stats-${YAR}-${MON}-${TAG}.plot # The lines of this file will have the format # # DAY NOTHER NGET TOTBYTES NERRORS # # where # DAY is the day number, # NGET is the number of regular "GET file" accesses # TOTBYTES is the total bytes in those accesses # NOTHER is the number of other entries in the access log # NERRORS is the number of entries in the error log set ORGS = ( ); unset FILTER while ( ( $#argv > 1 ) && ( "x$1" =~ x-* ) ) if ( "x$1" == "x-external" || "x$1" == "x-unicamp" || "x$1" == "x-local" ) then set FILTER; set ORGS = ( ${ORGS} $1 ) shift else echo "error: $0 $*" echo "${usage}" exit 1 endif end if ( $#argv != 3) then echo "error: $0 $*" echo "usage: $usage" exit 1 endif set YAR = "$1" set MON = "$2" set TAG = "$3" set LIB = "${STOLFIHOME}/programs/csh/http-log-tools" set TMP = "/tmp/log.$$" set PLT = "http-day-stats-${YAR}-${MON}-${TAG}.plot" /bin/rm -f ${TMP} ${PLT} if ( $?EXT ) then echo '# external accesses only ' >> ${PLT} endif echo '# day nget totbytes nother nerrors' >> ${PLT} foreach DAY ( \ 01 02 03 04 05 06 07 08 09 10 \ 11 12 13 14 15 16 17 18 19 20 \ 21 22 23 24 25 26 27 28 29 30 \ 31 \ ) /usr/ucb/echo -n " ${DAY}" >> ${PLT} set f = "http-log-${YAR}-${MON}-${DAY}" if ( -r $f ) then echo '=== '$f' ===' if ( $?FILTER ) then ${LIB}/select-log-entries-by-origin ${ORGS} < $f > ${TMP} else cat $f > ${TMP} endif if ( ! (-z ${TMP} ) ) then sed ${TMP} \ -e '/ [0-9][0-9]*$/\!s/^.*$/ 0 0 1/' \ -e '/ [0-9][0-9]*$/s/^.* \([0-9][0-9]*\)$/ 1 \1 0/' \ | nawk -f ${LIB}/add-numbers.nawk \ | tr '\012' ' ' \ >> ${PLT} else /usr/ucb/echo -n " 0 0 0 " >> ${PLT} endif else /usr/ucb/echo -n " 0 0 0 " >> ${PLT} endif set g = "http-err-${YAR}-${MON}-${DAY}" if ( -r $g ) then echo '=== '$g' ===' if ( $?FILTER ) then ${LIB}/select-log-entries-by-origin ${ORGS} < $g > ${TMP} else cat $g > ${TMP} endif cat ${TMP} | wc -l >> ${PLT} else echo ' 0' >> ${PLT} endif end /bin/rm -f ${TMP}