Tuesday, October 6, 2009

Nagios Twitter Plugin

Send your Nagios alarms to your twitter account

1-. Create a twitter bot user
2-. logon with your new twitter bot
3-. go to settings
4-. mark your updates as private
5-. logout
6-. logon with your regular twitter user
7-. follow your twitter bot
8-. logout
9-. logon again with your twitter bot
10-. accept the follow request
11-. logout
12-. logon again (Argh!) with your regular twitter user
13-. ssh/telnet to your nagios installation
14-. go to your nagios objects directory (/usr/local/nagios/etc/objects)
15-. paste this (change user and password) into commands.cfg

define command {
command_name alarma-twitter
command_line /usr/bin/curl --connect-timeout 30 --max-time 60 -u YOUR_TWITTER_BOT_USER:YOUR_TWITTER_BOT_PASSWORD -d status="$SERVICEDESC$@$HOSTNAME$ is $SERVICESTATE$ ** $SERVICEOUTPUT$ ** Date: $SHORTDATETIME$" http://twitter.com/statuses/update.xml
}

16-. paste this into templates.cfg

define contact {
name twitter_contact
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
service_notification_commands alarma-twitter
host_notification_commands alarma-twitter
register 0
}

17-. paste this into contacts.cfg

define contact{
contact_name twitter_jorge
use twitter_contact
alias Twitter Jorge
}

18-. edit some service you have defined and select “twitter_jorge” as contact

define service{
use passive_service
hostgroup_name servidores_solaris
contacts twitter_jorge
service_description Prueba NSCA
}

19-. submit a passive check for this service
20-. go to your twitter homepage,

No comments:

Post a Comment