Using Twitter as notifications transport for Nagios or Icinga alerts

Are you wondering how many alternative ways to get notifications from your nagios/icinga exists, other than plain email messages? And what if you actually are monitoring your email or DNS infrastructure and you don’t want to use a third-party email account dedicated to our precious notices?

An alternative and effective method to deliver the short status notification is via Twitter messages, using a protected account (for privacy).

Register a new standard Twitter account and make sure to enable in the settings.

We need to install on the monitoring server a command-line Twitter client, such as Twidge:

sudo apt-get install twidge

Do the one-time configuration procedure with the user you prefer:

twidge setup

Move the generated configuration file from your home folder somewhere into the nagios/icinga configuration folder:

sudo mv ~/.twidgerc /etc/icinga/twidgerc

Now add two new custom commands in the nagios/icinga configuration:

/etc/icinga/commands.cfg:

define command {
        command_name	notify-host-by-twitter
        command_line	/bin/echo "HOST $HOSTALIAS$ is $HOSTSTATE$" | twidge -c /etc/icinga/twidgerc update
}
define command {
	command_name	notify-service-by-twitter
	command_line	/bin/echo "SERVICE $SERVICEDESC$ on $HOSTALIAS$ is $SERVICESTATE$" | twidge -c /etc/icinga/twidgerc update
}

Now you need to use such commands as host and service notifications, like here:

define contact {
        contact_name                    root
        alias                           Root
        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
}

Reload and enjoy!

sudo /etc/init.d/icinga reload

space new robot

🇬🇧 🇺🇸 If you found value in my content, consider supporting me by treating me to a coffee, beer, or pizza. Your contributions help fuel more quality content creation.

🇮🇹 Se hai trovato valore nei miei contenuti, considera di supportarmi offrendomi un caffè, una birra o una pizza. I tuoi contributi aiutano a creare contenuti di qualità.

🇬🇧 🇺🇸 If you have found inaccuracies or wish to improve this article, please use the comments section below (after clicking on Load Comments).

🇮🇹 Se hai trovato imprecisioni o vuoi migliorare questo articolo, utilizza la sezione commenti qui sotto (dopo aver cliccato Load Comments)

Comments