[vhffs-dev] [406] Add a little tool I wrote to handle stats with multiple web servers, very ugly but it works fine :p

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 406
Author:   gradator
Date:     2007-01-19 00:24:24 +0000 (Fri, 19 Jan 2007)

Log Message:
-----------
Add a little tool I wrote to handle stats with multiple web servers, very ugly but it works fine :p

Modified Paths:
--------------
    branches/vhffs_4.1/Makefile
    trunk/Makefile

Added Paths:
-----------
    branches/vhffs_4.1/vhffs-robots/src/generate_webstats.sh
    trunk/vhffs-robots/src/generate_webstats.sh


Modified: branches/vhffs_4.1/Makefile
===================================================================
--- branches/vhffs_4.1/Makefile	2007-01-19 00:13:37 UTC (rev 405)
+++ branches/vhffs_4.1/Makefile	2007-01-19 00:24:24 UTC (rev 406)
@@ -74,6 +74,7 @@
 	install -d -m 755 $(BOTSDIR)	
 	install -d -m 755 $(BOTSDIR)/misc/
 	install -m 755 vhffs-robots/src/*.pl            $(BOTSDIR)/
+	install -m 755 vhffs-robots/src/*.sh            $(BOTSDIR)/
 	install -m 644 vhffs-robots/misc/*   $(BOTSDIR)/misc/
 
 install-doc:

Added: branches/vhffs_4.1/vhffs-robots/src/generate_webstats.sh
===================================================================
--- branches/vhffs_4.1/vhffs-robots/src/generate_webstats.sh	2007-01-19 00:13:37 UTC (rev 405)
+++ branches/vhffs_4.1/vhffs-robots/src/generate_webstats.sh	2007-01-19 00:24:24 UTC (rev 406)
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+INCOMINGDIR="/data/logs/web/incoming"
+
+
+
+for dirserv in $INCOMINGDIR/* ; do
+	if [ -d $dirserv ]; then
+		echo "Rotate log files for $dirserv"
+		for logfile in $dirserv/*.log; do
+			echo "Found $logfile"
+			# -- this is gruiikkkkk but it works ;)
+			if [ -f $logfile.7.gz ]; then rm $logfile.7.gz; fi
+			if [ -f $logfile.6.gz ]; then mv $logfile.6.gz $logfile.7.gz; fi
+			if [ -f $logfile.5.gz ]; then mv $logfile.5.gz $logfile.6.gz; fi
+			if [ -f $logfile.4.gz ]; then mv $logfile.4.gz $logfile.5.gz; fi
+			if [ -f $logfile.3.gz ]; then mv $logfile.3.gz $logfile.4.gz; fi
+			if [ -f $logfile.2.gz ]; then mv $logfile.2.gz $logfile.3.gz; fi
+			if [ -f $logfile.1.gz ]; then mv $logfile.1.gz $logfile.2.gz; fi
+			if [ -f $logfile.0 ]; then gzip $logfile.0; mv $logfile.0.gz $logfile.1.gz; fi
+			if [ -f $logfile ]; then mv $logfile $logfile.0; fi
+			> $logfile
+
+			# -- ask apache to restart
+			> $dirserv/cycleok
+		done
+	fi
+done
+
+echo "Wait 180 seconds to be sure all apache are restarted"
+sleep 180
+
+echo "Removing previous log"
+rm $INCOMINGDIR/logfile
+
+#for dirserv in $INCOMINGDIR/* ; do
+#	if [ -d $dirserv ]; then
+#		echo "Merge log from $dirserv/vhffs.log.0 to $INCOMINGDIR/logfile"
+#		cat $dirserv/vhffs.log.0 >> $INCOMINGDIR/logfile
+#	fi
+#done
+echo "Merge all logs"
+mergelog $INCOMINGDIR/*/vhffs.log.0 > $INCOMINGDIR/logfile
+
+echo "Parse http logs"
+/usr/lib/vhffs/bots/parse_httplog.pl
+
+echo "Create awstats config files for each website"
+/usr/lib/vhffs/bots/create_statsconf.pl
+
+echo "Run awstats for each website"
+/usr/lib/vhffs/bots/create_stats.pl
+
+for site in /data/logs/web/sites/* ; do
+	if [ -d $site ]; then
+		logfile="$site/logfile"
+		echo "Rotate $site"
+		# -- this is gruiikkkkk but it works ;)
+		if [ -f $logfile.7.gz ]; then rm $logfile.7.gz; fi
+		if [ -f $logfile.6.gz ]; then mv $logfile.6.gz $logfile.7.gz; fi
+		if [ -f $logfile.5.gz ]; then mv $logfile.5.gz $logfile.6.gz; fi
+		if [ -f $logfile.4.gz ]; then mv $logfile.4.gz $logfile.5.gz; fi
+		if [ -f $logfile.3.gz ]; then mv $logfile.3.gz $logfile.4.gz; fi
+		if [ -f $logfile.2.gz ]; then mv $logfile.2.gz $logfile.3.gz; fi
+		if [ -f $logfile.1.gz ]; then mv $logfile.1.gz $logfile.2.gz; fi
+		if [ -f $logfile.0 ]; then gzip $logfile.0; mv $logfile.0.gz $logfile.1.gz; fi
+		if [ -f $logfile ]; then mv $logfile $logfile.0; fi
+		> $logfile
+	fi
+done


Property changes on: branches/vhffs_4.1/vhffs-robots/src/generate_webstats.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2007-01-19 00:13:37 UTC (rev 405)
+++ trunk/Makefile	2007-01-19 00:24:24 UTC (rev 406)
@@ -74,6 +74,7 @@
 	install -d -m 755 $(BOTSDIR)	
 	install -d -m 755 $(BOTSDIR)/misc/
 	install -m 755 vhffs-robots/src/*.pl            $(BOTSDIR)/
+	install -m 755 vhffs-robots/src/*.sh            $(BOTSDIR)/
 	install -m 644 vhffs-robots/misc/*   $(BOTSDIR)/misc/
 
 install-doc:

Added: trunk/vhffs-robots/src/generate_webstats.sh
===================================================================
--- trunk/vhffs-robots/src/generate_webstats.sh	2007-01-19 00:13:37 UTC (rev 405)
+++ trunk/vhffs-robots/src/generate_webstats.sh	2007-01-19 00:24:24 UTC (rev 406)
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+INCOMINGDIR="/data/logs/web/incoming"
+
+
+
+for dirserv in $INCOMINGDIR/* ; do
+	if [ -d $dirserv ]; then
+		echo "Rotate log files for $dirserv"
+		for logfile in $dirserv/*.log; do
+			echo "Found $logfile"
+			# -- this is gruiikkkkk but it works ;)
+			if [ -f $logfile.7.gz ]; then rm $logfile.7.gz; fi
+			if [ -f $logfile.6.gz ]; then mv $logfile.6.gz $logfile.7.gz; fi
+			if [ -f $logfile.5.gz ]; then mv $logfile.5.gz $logfile.6.gz; fi
+			if [ -f $logfile.4.gz ]; then mv $logfile.4.gz $logfile.5.gz; fi
+			if [ -f $logfile.3.gz ]; then mv $logfile.3.gz $logfile.4.gz; fi
+			if [ -f $logfile.2.gz ]; then mv $logfile.2.gz $logfile.3.gz; fi
+			if [ -f $logfile.1.gz ]; then mv $logfile.1.gz $logfile.2.gz; fi
+			if [ -f $logfile.0 ]; then gzip $logfile.0; mv $logfile.0.gz $logfile.1.gz; fi
+			if [ -f $logfile ]; then mv $logfile $logfile.0; fi
+			> $logfile
+
+			# -- ask apache to restart
+			> $dirserv/cycleok
+		done
+	fi
+done
+
+echo "Wait 180 seconds to be sure all apache are restarted"
+sleep 180
+
+echo "Removing previous log"
+rm $INCOMINGDIR/logfile
+
+#for dirserv in $INCOMINGDIR/* ; do
+#	if [ -d $dirserv ]; then
+#		echo "Merge log from $dirserv/vhffs.log.0 to $INCOMINGDIR/logfile"
+#		cat $dirserv/vhffs.log.0 >> $INCOMINGDIR/logfile
+#	fi
+#done
+echo "Merge all logs"
+mergelog $INCOMINGDIR/*/vhffs.log.0 > $INCOMINGDIR/logfile
+
+echo "Parse http logs"
+/usr/lib/vhffs/bots/parse_httplog.pl
+
+echo "Create awstats config files for each website"
+/usr/lib/vhffs/bots/create_statsconf.pl
+
+echo "Run awstats for each website"
+/usr/lib/vhffs/bots/create_stats.pl
+
+for site in /data/logs/web/sites/* ; do
+	if [ -d $site ]; then
+		logfile="$site/logfile"
+		echo "Rotate $site"
+		# -- this is gruiikkkkk but it works ;)
+		if [ -f $logfile.7.gz ]; then rm $logfile.7.gz; fi
+		if [ -f $logfile.6.gz ]; then mv $logfile.6.gz $logfile.7.gz; fi
+		if [ -f $logfile.5.gz ]; then mv $logfile.5.gz $logfile.6.gz; fi
+		if [ -f $logfile.4.gz ]; then mv $logfile.4.gz $logfile.5.gz; fi
+		if [ -f $logfile.3.gz ]; then mv $logfile.3.gz $logfile.4.gz; fi
+		if [ -f $logfile.2.gz ]; then mv $logfile.2.gz $logfile.3.gz; fi
+		if [ -f $logfile.1.gz ]; then mv $logfile.1.gz $logfile.2.gz; fi
+		if [ -f $logfile.0 ]; then gzip $logfile.0; mv $logfile.0.gz $logfile.1.gz; fi
+		if [ -f $logfile ]; then mv $logfile $logfile.0; fi
+		> $logfile
+	fi
+done


Property changes on: trunk/vhffs-robots/src/generate_webstats.sh
___________________________________________________________________
Name: svn:executable
   + *


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/