Use nagios to track and graph your twitter followers

Submit to reddit

I’ve been using Nagios to monitor servers and devices for years now. Lately as an exercise to learn more about nagios I installed a private instance that I use to monitor everything I can think of – from my personal servers to the number of hours we watch TV.

A nice use I found is to monitor the number of followers my twitter bots and personal account have. For that I wrote a custom plugin, available in my small repository of plugins at: https://github.com/silviuvulcan/nagios-plugins

The plugin pulls the number from the public site – no API access required. Since the data is not changing frequently you could use a custom setting to check less often. My entry looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
define host{
use                     linux-server
host_name               twitter
alias                   twitter
address                 twitter.com
}

define service{
use                             local-service,graphed-service         ; Name of service template to use
host_name                       twitter
service_description             Twitter followers: @rtjolla
normal_check_interval           60                    ; check hourly
check_command                   check_twitterfollowers!rtjolla
}

This creates a host named twitter, and graphs (provided you have nagiosgrapher up and running) the number of followers. Of course you have to install the plugin and create a custom command for it. Mine looks like this:

1
2
3
4
define command{
command_name check_twitterfollowers
command_line $USER1$/check_twitterfollowers.sh -u $ARG1$
}

Below is the code of the plugin if you are not interested in cloning the repo:

Twitter followers graphed by nagios sample

Twitter followers graphed by nagios sample