Nothing beats a full stats package, but with a little grepping and a logfile and we can figure out some quick statistics.
Get only hits coming from Google.com/search:
grep 'google.com/search' access_log | head -1
Extract only the referrer field:
grep 'google.com/search' access_log | head -1 | awk '{print $11}'
Get the search terms only:
grep 'google.com/search' access_log | \
head -1 | \
awk '{print $11}' | \
cut -d\? -f2 | cut -d\& -f1 | \
sed 's/+/ /g;s/%22/"/g;s/q=//'
Here’s a little script that puts it all together. It finds the unique search terms, cleans out the trash, sorts them and list the top twenty five in order of descending hit count.
#!/bin/sh
LOG="/var/logs/httpd/access_log"
grep 'google.com/search' $LOG | \
awk '{print $11}' | \
cut -d\? -f2 | cut -d\& -f1 | \
sed 's/+/ /g;s/%22/"/g;s/q=//' | \
sed 's/%[0-9a-fA-F][0-9a-fA-F]/ /g;s/"//g' | \
grep -v '=' | sort | uniq -c | sort -rn | head -25
To see them all remove the | head -25 statement at the end of the command.
Thanks to an article at Linux Journal for the examples.
Popularity: 1% [?]
Posted in Snippets.
By damonp
– 9/14/2009
Find all setuid / setgid files owned by root:
find / -user root -type f \( -perm -4000 -o -perm -2000 \) -exec ls -ld '{}' \;
Find all setuid / setgid files owned by any user:
find / -type f \( -perm -4000 -o -perm -2000 \) -exec ls -ld '{}' \;
Popularity: 1% [?]
Posted in Snippets.
Tagged with Linux, Security.
By damonp
– 9/10/2009
After nearly two years with not much to say, I decided to pick up the blog again. It was a long and winding journey, this time in between. Maybe more on that later.
I should be updating the pages of the blog with current info about myself and my projects over the next few weeks.
As always, the shop is open for any sysadmin or development projects.
Popularity: 1% [?]
Posted in General.
By damonp
– 8/29/2009
Pre-Leopard the command to force OS X to flush and reload it’s DNS cache was:
In Leopard, lookupd no longer exists. Instead force a DNS cache refresh with:
sudo dscacheutil -flushcache
Popularity: 92% [?]
Posted in Apple / Mac.
By damonp
– 11/15/2007
Recent Comments