Archive

Posts Tagged ‘twidge’

tweet nagios server status

August 28th, 2011 2 comments

On my Nagios Server I use twitter to send status alerts. It works nicely with Identica & Twitter.

The setup is easy. First install twidge with

root@host:~# apt-get install twidge

Then write a twidgerc file with the according twidge configuration

nagios@host:~# vi /etc/nagios3/twidgerc
[DEFAULT]
oauthaccesstoken: %(serverbase)s/oauth/access_token
oauthauthorize: %(serverbase)s/oauth/authorize
oauthdata: [("user_id","XXXXXX"),("screen_name","YOUR_SCREENNAME"),("oauth_verifier","XXXXXX"),("oauth_token","XXXXXX"),("oauth_token_secret","XXXXXX"),("oauth_callback_confirmed","true")]
oauthrequesttoken: %(serverbase)s/oauth/request_token
sendmail: /usr/sbin/sendmail
serverbase: https://api.twitter.com
shortenurls: yes
urlbase: %(serverbase)s/1

Make sure the file is readable by Nagios user. (!)

nagios@host:~# chown nagios /etc/nagios/twidgerc

Then add the following lines to /etc/nagios3/conf.d/contacts_nagios2.cfg (on GNU/Linux Debian).

define contact{
contact_name twitter
alias Twitter
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-twitter
host_notification_commands notify-host-by-twitter
email twitteraccount_to_contact
}

… and add “twitter” to the members in the contactgroup (in the same file).

members root,nagiosadmin,twitter

Then add these lines to etc/nagios3/commands.cfg:

define command {
command_name notify-service-by-twitter
command_line echo "#Nagios $NOTIFICATIONTYPE$ $HOSTNAME$($SERVICEDESC$) is $SERVICESTATE$" | twidge -c /etc/nagios3/twidgerc update
}
define command {
command_name notify-host-by-twitter
command_line echo "#Nagios $HOSTSTATE$ alert for $HOSTNAME$" | twidge -c /etc/nagios3/twidgerc dmsend $CONTACTEMAIL$
}

Nagios will tweet the service notifications and send a directmessage to the according user with the host notification.
Here’s an example:

=^.^= Lx