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:
Code:
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. Using the output from the commented 3rd line of the command definition I can see that twurl isn't authenticated, though it is authed with nagios's user. I believe this is because twurl uses a .twurlrc file with stored credentials, but I also suspect nagios does not use this when it runs.
If anyone knows of a way of making nagios use the .twurlrc / other files in the environment for a given command, this would, I suspect, solve the problem.
Any ideas?