Custom Commands Not Running

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
liquidcourage1
Posts: 2
Joined: Thu Aug 18, 2016 8:46 am

Custom Commands Not Running

Post by liquidcourage1 »

Background: trying to integrate Slack so that Nagios can trigger alerts to a channel. The alerts don't seem to be triggering, though. I'm also not sure where to check to see if Nagios is even trying.

We have a script that works when ran from the cli. Along with the script, we have configured user accounts and groups that will be notified. Those notifications should trigger a new, custom notification that we have defined in the commands.cfg file (imported through the web portal and verified to be there when configuration applied and core restarted).

Here are the commands:

Code: Select all

define command {
       command_name                  		notify-service-by-slack
       command_line                  		/usr/local/bin/slack_nagios.sh > /tmp/slack.log 2>&1
}
define command {
       command_name                  		notify-host-by-slack
       command_line                  		/usr/local/bin/slack_nagios.sh > /tmp/slack.log 2>&1
}
Here are the user accounts and the trigger defined in contacts.cfg and contractgroups.cfg:

Code: Select all

define contact {
       contact_name                     slack
       alias                            Slack
       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-slack
       host_notification_commands       notify-host-by-slack
       }
       
define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 root,slack
        }

define contactgroup{
        contactgroup_name       admins-page
        alias                   Nagios Administrators
        members                 root,slack
        }
Linux CentOS 6.7 64bit
VMware VM - built from OVA/OVF from Nagios
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: Custom Commands Not Running

Post by bwallace »

...I'm also not sure where to check to see if Nagios is even trying.
Here are some locations to get started:
Is your Nagios system configured to use sendmail or SMTP?
Admin > Manage Email Settings

If sendmail, you can check this log:

Code: Select all

/var/log/maillog
tail -100 /var/log/maillog 

--This file logs email sent through sendmail. Only applicable to core contact "notify-*-by-email" notification handlers and sendmail tests.

If you're using SMTP, check

Code: Select all

/usr/local/nagiosxi/tmp/phpmailer.log
tail -100 /usr/local/nagiosxi/tmp/phpmailer.log
First run a notification report -- In the UI go to Reports > Available Reports > Notifications (make sure the date range will contain alerts you were expecting to receive emails about). The output is actual notifications that XI sent out . If you see zero notifications for these checks, then we'll have to check your configuration. If you see outbound notifications listed there, then the issue is outside of Nagios - check your mail server, etc.

Lastly, you can refer to "nagios.log" - here you will see checks, notifications, external commands, and events:
/usr/local/nagios/var/nagios.log


Hope this helps, feel free to post any logs here if any questions.
Be sure to check out the Knowledgebase for helpful articles and solutions!
liquidcourage1
Posts: 2
Joined: Thu Aug 18, 2016 8:46 am

Re: Custom Commands Not Running

Post by liquidcourage1 »

As for mail, we're using sendmail, but the Slack integration doesn't use smtp or mail at all, actually. The command we're trying basically curls the Slack site and adds a comment to a specific channel based on the alert.

As for the Reports, I can't see any notifications. But there seems to be another, separate error. Not sure if it's related:

Code: Select all

SQL: SQL Error [ndoutils] : Incorrect file format 'nagios_notifications'
Is it possible this may be the root of the problem?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Custom Commands Not Running

Post by ssax »

Ticket received, locking and will continue through the ticket.

Thank you
Locked