#!/bin/sh
# ------------------------
# access log
# ------------------------
# Version : 1.2
# update  : 2003.5.24

export LANG=C
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH


# Set Default Parameter

DATE=`date`					#
DATE2=`date +%Y%m`				# today filename
DATE3=`date +%Y%m --date '1 month ago'`		# lastmth fiename
SOURCEPATH="/home/httpd/logs"			# sorce file path
SOURCEFILE="access_log"				# sorce file name
TMPPATH="/export/httpd/admin/logs/hydra"	# temp file path
TMPFILE="today_access.tmp"			# temp file name
OUTPATH="/export/httpd/admin/logs/hydra"	# log output path
OUTFILE="today_access.html"			# output log file name
TMPFILE="access_tmp.html"			# work file
INCLUDE="./include"				# include lib path


# remove chatracter pattern

RM1="192.168.1"
RM2=".png"
RM3=".jpg"
RM4=".gif"
RM5="219.123."
RM6="/hbm/menu/"

# Output TempFile

grep -v $RM1 $SOURCEPATH/$SOURCEFILE | grep -v $RM2 | grep -v $RM3 | grep -v $RM4 | grep -v $RM5 | grep -v $RM6 > $TMPPATH/$TMPFILE


# Output HTML

echo > $OUTPATH/$OUTFILE
cat $INCLUDE/html-head.txt >> $OUTPATH/$OUTFILE 
echo "<HR align=center width=90% noshade>" >> $OUTPATH/$OUTFILE
echo "<CENTER>HTTP Access Log ---" $DATE "</CENTER>" >> $OUTPATH/$OUTFILE
echo "<HR align=center width=90% noshade>" >> $OUTPATH/$OUTFILE
echo "<BR>" >> $OUTPATH/$OUTFILE
echo "<CENTER>" >> $OUTPATH/$OUTFILE
echo "<TABLE>" >> $OUTPATH/$OUTFILE

echo "<TR><TD width=140>Date</TD><TD width=100>IP</TD><TD></TD><TD>User</TD><TD width=40>Code</TD><TD>file</TD></TR>" >> $OUTPATH/$OUTFILE

cat $TMPPATH/$TMPFILE | awk '{printf "%s %s %s %s %s %s %s %s %s\n",$4,$1,$2,$3,$6,$7,$8,$9,$10}' | awk 'BEGIN{FS="["}{printf "%s %s\n",$1,$2}' | awk '{printf "<TR><TD width=65 nowrap>%s</TD><TD width=65 nowrap>%s</TD><TD align=center width=40 nowrap>%s</TD><TD nowrap>%s</TD><TD align=center nowrap>%s</TD><TD nowrap>%s %s %s</TD></TR>\n",$1,$2,$3,$4,$8,$5,$6,$7}' | sort -r >> $OUTPATH/$OUTFILE

echo "</TABLE>" >> $OUTPATH/$OUTFILE
echo "</CENTER>" >> $OUTPATH/$OUTFILE
cat $INCLUDE/html-tail.txt >> $OUTPATH/$OUTFILE

# color chenge

# HTTP - 404 Not Found
mv $OUTPATH/$OUTFILE $OUTPATH/$TMPFILE
sed 's/>404/><FONT color=ff0000>404<\/FONT>/g' $OUTPATH/$TMPFILE > $OUTPATH/$OUTFILE
rm $OUTPATH/$TMPFILE

# HTTP - 403 Forbidden
mv $OUTPATH/$OUTFILE $OUTPATH/$TMPFILE
sed 's/>403/><FONT color=ffa100>403<\/FONT>/g' $OUTPATH/$TMPFILE > $OUTPATH/$OUTFILE
rm $OUTPATH/$TMPFILE

# HTTP - 401 Unauthorized
mv $OUTPATH/$OUTFILE $OUTPATH/$TMPFILE
sed 's/>401/><FONT color=0000ff>401<\/FONT>/g' $OUTPATH/$TMPFILE > $OUTPATH/$OUTFILE
rm $OUTPATH/$TMPFILE


# EOF

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2007-12-26 (水) 02:22:56 (3622d)