Created
April 30, 2010 16:43
-
-
Save phred/385455 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# super-simple request per minute statistics from an Apache log file | |
# watch it live, now with JSON output! | |
# while [ /bin/true ]; do sh logstats.sh ; sleep 60 ; done | |
# | |
LOGFILE=/var/log/apache2/access_log | |
HOUR=`date +%H` | |
MIN=`date +%M` | |
MIN=`expr $MIN - 1` | |
if [ $MIN -lt 0 ]; then | |
MIN=59 | |
HOUR=`expr $HOUR - 1` | |
if [ $HOUR -lt 0 ]; then | |
HOUR=23 | |
fi | |
fi | |
TIME=$HOUR:$MIN | |
echo '{'date: \"$TIME\", hits: `grep $TIME: $LOGFILE | wc -l`, load: "[`uptime | awk '{print $10, $11, $12}'`]"'}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment