0

I have spent the day setting up custom twitter notification on nagios. Everything seems to be in place and the notifications seems to be triggered but the script is not called.

my contacts configuration looks like this:

define contactgroup{
        contactgroup_name       twittergroup
        alias                   twittergroup
        members                 user1
        }


define contact {
      contact_name                             user1
      alias                                    user1
      service_notification_period              24x7
      host_notification_period                 24x7
      service_notification_options             c,r
      host_notification_options                d,r
      service_notification_commands            streamnotify-service-twitter-dm
      host_notification_commands               streamnotify-host-twitter-dm
}

a typical service looks like this:

define service{
    use                             generic-service
    host_name                       ra-stream-monitoring-host
    servicegroups                   streaming_services
    service_description             Stream / starrfm-redfm ingest stream
    check_command                   check_http_status!"http://somestream"
    contact_groups                  admins,twittergroup
  }

my commands.cfg has these entries:

define command { 
        command_name   streamnotify-host-twitter-dm
        command_line   echo "todo notify host by twitter"
}

define command { 
        command_name    streamnotify-service-twitter-dm
        command_line   /etc/nagios3/streamnotify_twitter.sh 
}

the script in /etc/nagios3/streamnotify_twitter.sh looks like this

!/bin/bash
touch /etc/nagios3/CALLED

the file CALLED is never created although the notifications panel of nagios reports that user1 has been notified

We also have custom slack notifications in place in the admin group and these work fine if I manually trigger a notification, but not the new twitter notifications.

How do I go about debugging this? I have looked into the nagios debug logs and the command seems to be executed. But as far as I can tell something is going wrong since the file is never created. This has been cue for many rage filled rants about nagios this evening but that has not solved the problem either (and it is probably my fault anyway).

Thanks in advance.

1 Answer 1

1

Your script is missing a proper shebang at the beginning of the first line. It should be #!/bin/bash.

Additionally, it's almost a certainly that the nagios user doesn't have write permission in /etc/nagios3 (I'm guessing Ubuntu package?). Scripts really don't belong there either, but that's beside the point.

Change your test file path to something in /tmp if you want to test this way.

2
  • I doubt this is the problem. My script to send slack notifications is in /etc/nagios3 and that works fine.
    – Russell
    Jul 31, 2015 at 0:13
  • A thousand apologies Keith, the reason the file was not being created was indeed due to lack of write permissions. From logging out the actual twitter script to /tmp I found out that the underlying problem was due to permissions on the oauth key that the twitter client used. Many thanks.
    – Russell
    Jul 31, 2015 at 1:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .