We've been using nagios for some time and have recently decided to change how we receive alerts. To this end, we've installed twurl ( https://github.com/marcel/twurl ) and are using it to send alerts. Unfortunately this logs alerts as having been sent, but none get to the monitor's twitter account. twurl uses a pretty standard CLI which looks like this (nagios macros left in tact):
/usr/local/bin/twurl -d "status=d @$CONTACTEMAIL$ $NOTIFICATIONTYPE$: $TIME$ : $HOSTALIAS$ / $SERVICEDESC$ is $SERVICESTATE$ ($SERVICEOUTPUT$)" /1/statuses/update.xml
Here's the notification command:
define command {
command_name notify-service-by-twurl
command_line PATH="/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/nagios/bin"; HOME="/home/nagios"; /usr/local/bin/twurl -d "status=d @$CONTACTEMAIL$ $NOTIFICATIONTYPE$: $TIME$ : $HOSTALIAS$ / $SERVICEDESC$ is $SERVICESTATE$ ($SERVICEOUTPUT$)" /1/statuses/update.xml &>/tmp/lastcheck
# command_line /bin/echo '/usr/local/bin/twurl -d "status=d @$CONTACTEMAIL$ $NOTIFICATIONTYPE$: $TIME$ : $HOSTALIAS$ / $SERVICEDESC$ is $SERVICESTATE$ ($SERVICEOUTPUT$)" /1/statuses/update.xml' > /tmp/foo
}
Syntax works fine etc, no issues there. 1st line fires off the 2nd command_line line is to output the contents of the macros nagios uses, and returns what would be expected in all cases.
twurl pitfalls we've definitely avoided:
- we've authed to twitter for nagios's user (su'd in and checked, works fine when done manually).
- the credentials of the app are correct (again, works fine when using twurl manually)
- the settings of the twitter app ( on http://dev.twitter.com ) are correct (set to read/write direct messages etc)
I can provide any specific pieces of information anyone might need for extra context but for now that's about it. Edit: I'm starting to suspect this is due to a lack of a .profile when nagios itself calls twurl, but I'm not 100% sure and still can't make it "go".
Update: ascertained that the script is not using the .twurlrc from nagios's home directory when nagios executes it. This is a problem I still can't resolve, any other help would be much appreciated.