Just a brief note: I’ve just updated my script for graphing referrals from Google, Bing and Yahoo!. I intended it to reset each first day of a month, so one can see whether each month is “better” than the one before… however, it didn’t handle stats without any referrals at all from those search engines, which is likely to happen every time the current month changes. It’s fixed now.
Tag: MRTG
Graphing search engine referrals with AWStats and MRTG
From my previous post, AWStats tip: creating static pages (and why itβs a good idea):
for instance, Iβm currently using MRTG to plot a graph of Google and Bing referrals, using the AWstats-generated static pages as input
So… anyone curious? π
Note: again, beware of word wrapping below. I’ve added an empty line between any “true” line of text; if you see two or more lines together, it’s supposed to be just one.
cat /root/bin/winterdrake-se.sh
#!/usr/local/bin/bash
GOOGLE=`grep \>Google\</a\>\</td\>\<td\>
/var/www/htdocs/AWstats/awstats.winterdrake.com.html | awk -F"<td>" '{print $2}' | cut -d "<" -f 1`
if [ -z $GOOGLE ]; then
GOOGLE=0
fi
echo $GOOGLE
BING=`grep \>Microsoft\ Bing\</a\>\</td\>\<td\>
/var/www/htdocs/AWstats/awstats.winterdrake.com.html | awk -F"<td>" '{print $2}' | cut -d "<" -f 1`
if [ -z $BING ]; then
BING=0
fi
YAHOO=`grep \>Yahoo\!\</a\>\</td\>\<td\>
/var/www/htdocs/AWstats/awstats.winterdrake.com.html | awk -F"<td>" '{print $2}' | cut -d "<" -f 1`
if [ -z $YAHOO ]; then
YAHOO=0
fi
echo $(($BING + $YAHOO))
uptime | awk -F"up " '{print $2}'
uname -n
EDIT in April 1, 2011: fixed the script so that it deals with non-existing entries (typically on the first day of the month).
By the way, this is a FreeBSD box; that’s the reason why bash is in /usr/local/bin
. In Linux, it’s probably in /bin
.
The mrtg.cfg file is mostly standard: it invokes the script shown above, and labels “I” as hits from Google, and “O” as hits from Bing and Yahoo! put together.
If you want to see what the result looks like, look here.
If you’ve been paying attention, yes, both values will reset to zero the first day of every month. That’s exactly how I want it: I want to see if every month it “rises” faster than the month before, or slower, or whatever. π