#!/bin/sh # # server-status へアクセスし、アクセス数を得る # apacheが作成した error.logと gazou.logの行数を計測する datetimej=`/bin/date +%Y%m%d%H%M%S` echo "datetimej="$datetimej # ---------- server-statusの access数 ----------- access=`/usr/local/bin/lynx -dump localhost/server-status | \ grep "Total accesses" | awk '{print $3}'` echo "access="$access accessN1=`/usr/bin/mysql vine62 -u root -N -e \ "select value from N1 where name='access'"` echo "accessN1="$accessN1 let accessNow=$access-$accessN1 if [ $accessNow -lt 0 ]; then accessNow=0 fi echo "accessNow="$accessNow /usr/bin/mysql vine62 -u root -e \ "update N1 set \ datetime=$datetimej, \ value=$access \ where name='access';" # ---------- error.log ----------- error=`wc -l /var/log/httpd/error.log | awk '{print $1}'` echo "error="$error errorN1=`/usr/bin/mysql vine62 -u root -N -e \ "select value from N1 where name='error';"` echo "errorN1="$errorN1 let errorNow=$error-$errorN1 if [ $errorNow -lt 0 ]; then errorNow=0 fi echo "errorNow="$errorNow /usr/bin/mysql vine62 -u root -e \ "update N1 set \ datetime=$datetimej, \ value=$error \ where name='error';" # ---------- gazou.log ----------- gazou=`wc -l /var/log/httpd/gazou.log | awk '{print $1}'` echo "gazou="$gazou gazouN1=`/usr/bin/mysql vine62 -u root -N -e \ "select value from N1 where name='gazou';"` echo "gazouN1="$gazouN1 let gazouNow=$gazou-$gazouN1 if [ $gazouNow -lt 0 ]; then gazouNow=0 fi echo "gazouNow="$gazouNow /usr/bin/mysql vine62 -u root -e \ "update N1 set \ datetime=$datetimej, \ value=$gazou \ where name='gazou';" # ---------- mysqlへ書き込み ----------- /usr/bin/mysql vine62 -u root -e \ "insert into access \ (datetime,access,error,gazou) values \ ($datetimej,$accessNow,$errorNow,$gazouNow)"