Munin Popularity Plugins

October 29, 2009

google-index

After writing about Munin last week and mentioning some of its uses outside of system performance tracking I decided to write a collection of plugins for tracking website popularity. The full code is available on GitHub.

The plugins include:

  • Alexa traffic rank
  • Number of pages in the Google index
  • Technorati authority
  • Feedburner RSS subscribers
  • Twitter followers

Munin will automatically handle the generation of daily, weekly, monthly and yearly graphs. All of the plugins support graphing of multiple sites/accounts, so you can show several sites on the same graph, as is the case with the Google index graph above, or you can decide to show a single site/account per graph. Some example graphs are shown below:

twitter

technorati

feedburner

alexa

Server Monitoring with Munin

October 21, 2009

Munin is an excellent open source tool for monitoring and graphing server performance metrics. It can be configured to send out alert emails when something goes wrong with your server, and the graphs make it easy to view trends over time: You could see that your site gets much less traffic on a Sunday, for example, or that the number of database queries performed per day has doubled in the last 2 months.

On a Debian-based system installing Munin is as simple as running the following command, and then going to http://your-server/munin/ in your browser:

sudo aptitude install munin

Munin comes with lots of monitoring plugins by default, including those for MySQL, PostgresSQL, Apache, Tomcat, Squid, and for things such a CPU and memory usage, load average, network traffic, and many more. You can also find lots of user submitted plugins on sites like Munin Exchange.

Munin doesn’t have to be used solely for monitoring server performance though. Being so easy to extend Munin is also a great tool for tracking non-server performance related trends over time. In just a few lines of code you could write plugins to track the following stats about your website:

  • Number of User signups
  • Google PageRank
  • Pages in Google’s index
  • Number of backlinks
  • Number of twitter mentions
  • Alexa traffic rank

The number of pages in Google’s index is actually a plugin I’ve written. Simple put the following code in your /etc/munin/plugins directory to see it in action:

#!/bin/sh
# Munin Plugin to display the number of pages in the
# google index for all of the given websites
# Ben Dowling - www.coderholic.com

# Change this to whatever sites you're interested in
websites="www.yahoo.com www.google.com www.twitter.com"

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then

        echo 'graph_title Number of Pages in Google Index'
        echo 'graph_args --base 1000 -l 0 '
        echo 'graph_vlabel number of pages'
        echo 'graph_category google'
        echo 'graph_info This graph shows the number of pages in the Google index for a given website.'

        i=0
        for site in $websites
        do
                name="site_${i}"
                echo "${name}.label ${site}"
                echo "${name}.draw LINE2"
                echo "${name}.info The number of pages in the google index."
                i=$((i+1))
        done
        exit 0
fi

i=0
for site in $websites
do
        name="site_${i}"
		value=$(wget -q --user-agent=Firefox -O - "http://www.google.com/search?q=site:${site}" | grep -E "of about [0-9,]+" -o | grep -E "[0-9,]+" -o | sed "s/,//g")
        echo "${name}.value ${value}"

        i=$((i+1))
done

For more details about Munin see their homepage, which also includes detailed documentation on writing your own plugins.

Let me know if you can think of any more Munin plugins that could be interesting, or if you’ve used any yourself!

10 More Puzzle Websites to Sharpen Your Programming Skills

October 18, 2009

My recently published Six Revision guest post, 10 Puzzle Websites to Sharpen Your Programming Skills, got a great response, hitting the front page of Hacker News, Reddit, and doing fairly well on Digg too.

Lots of comments were left pointing out some sites which weren’t included in my list, so I’m following up here with a list of 10 more top programming puzzle websites:

1. Code Chef

Code Chef has lots of practice puzzles, and monthly competitions with cash prizes. The site officially supports over 35 programming languages!

2. SPOJ

The Sphere Online Judge contains 1871 different programming problems. More points are awarded for better performing solutions, which can be submitted in a range of languages.

3. Code Golf

The aim with code golf is to submit a solution using the fewest characters possible.Solutions can be submitted in Perl, Python PHP or Ruby.

4. Uva Online Judge

Over 2600 great programming puzzles, and also regular contests. Submissions in C, C++, Java or Pascal are automatically checked for you.

5. Timus Online Judge

An online competition site that automatically checks your submissions. Supports Java, C#, Pascal, C and C++.

6. Google Code Jam

The code jam is a programming contest from Google. The top 25 contestants get to travel to Google’s HQ in California. Entries are accepting in any programming language.

7. USA Computing Olympiad

Programming puzzles designed to provide “pre-college students with opportunities to sharpen their computer programming skills”. The puzzles are still interesting and fun even if you’ve got a CS degree!

8. Informatics Olympiad

A British version of the computing olympiad. Again aimed at school and college students, but fun and interesting for everyone.

9. Programming Challenges in C, C++ and C#

About.com’s C/C++/C# section regularly posts interesting programming puzzles. Successful solutions get acknowledged on the site once the deadline has passed.

10. Java Bat

A site dedicated to practical Java programming problems. You can type your code directly into the website, and it’ll tell you if you’ve solve the problem correctly or not.