Check out my nagios twitter updates

Hi all, I’ve been working on using curl to send twitter updates. Here’s the process:

  1. Create a twitter account you intend to use to send alerts.
  2. Make all the posts private (this will prevent what I call ‘overspill’ when a direct message exceeds the limit and leaks into a public tweet.
  3. Assuming all your admins have a twitter account allow each of them to have visability of the account you made in step 1. Also (this is where the beauty of twitter comes into play) subscribe to mobile phone alerts.
  4. Add the following checks to your commands.cfg file (note that this cannot be used on conjunction with paged alerts due to the way in which I’ve configged it).

[code]define command {
command_name notify-host-twitter
command_line curl -u twitter_acc_name:twitter_acc_passwd -d “text=$HOSTALIAS$ is $HOSTSTATE$&user=$CONTACTPAGER$” http://twitter.com/direct_messages/new.xml
}

define command {
command_name notify-service-twitter
command_line curl -u twitter_acc_name:twitter_acc_passwd -d “text=$HOSTALIAS$ $SERVICEDESC$ - $SERVICEOUTPUT$&user=$CONTACTPAGER$” http://twitter.com/direct_messages/new.xml
}[/code]
Obviously replace ‘twitter_acc_name:twitter_acc_passwd’ with your account name and password

  1. Change the contents of contacts.cfg so it looks something like the following:

define contact{ contact_name Example_User alias Example_user pager admins_twitter_acc service_notification_commands notify-service-twitter host_notification_commands notify-host-twitter service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r,f,s host_notification_options d,u,r,f,s register 1 }

Replace the pager with the admin accounts username, NOT the pager number (like I said you can’t have a pager and twitter running parallel due to the way in which I’ve configged this).
Obviously tweek everything else to your liking - this setup notifies me of almost every kind of alert.

  1. Sit back and wait - direct messages will come directly to your admins, these will be completely invisible to everyone else (including your friends on twitter).
  2. Thank me for this rather clever (relatively secure) little hack :).

Tim.