Nagios Core
How it works
When a problem meets a specified threshold in Nagios Core, it sends a JSON-formatted webhook to xMatters. A Nagios trigger in xMatters parses the webhook and initiates a flow. The webhook includes essential alert data you can use to enrich notifications to users or when building automated tasks.
Install the workflow
The following instructions describe how to install the workflow through the xMatters one-click installation process.
- Go to the Workflow Templates page and click the Nagios tile.
- On the Set up the Workflow tab, give the workflow a name that identifies its purpose (this must be unique in your instance), add an optional description, and set the default incident type (if applicable). Any built-in Initiate Incident steps in the workflow will automatically be set to the selected incident type.
- You can edit these later, if needed.
- Click Next to set up the connection.
- Choose the authentication method. A trigger URL is generated based on the selected authentication method.
- Copy the trigger URLs — you’ll use these to configure the webhook in Nagios.
- The trigger URLs include the recipients parameter, which specifies who should be notified. By default, this parameter is set to notify you (the logged in user), but you can set it to target any user or group you want.
- Send a test signal to the trigger URL to test the connection.
- Click Open Workflow to view and customize the workflow, or Close to return to the Workflows page.
Configure Nagios Core to send requests to the trigger URL
The following instructions describe how to configure Nagios Core to send signals to your triggers.
To have Nagios Core send host notifications to the flow trigger, you need to configure a webhook and set it to use the trigger URL.
- Go to the location of your Nagios Core configuration files. For example, /opt/nagios/etc.
- Create a new file in the configuration folder and name it xmatters.cfg.
- Open the new xmatters.cfg file and populate it with configuration information:
- To use URL Authentication, use the following configuration, replacing <URL_FROM_XMATTERS> with the URL you copied from the Nagios Host Notifications trigger.Copy
define contact {
contact_name xmatters
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
host_notification_commands notify_xmatters_host
}
define command {
command_name notify_xmatters_host
command_line curl -X POST -H "Content-Type: application/json" -d ' { "OBJECTTYPE": "HOST", "CONTACTGROUPNAME": "$HOSTDISPLAYNAME$", "HOSTDISPLAYNAME": "$HOSTDISPLAYNAME$", "HOSTNAME": "$HOSTNAME$", "HOSTOUTPUT": "$HOSTOUTPUT$", "HOSTSTATE": "$HOSTSTATE$", "LASTHOSTSTATECHANGE": "$LASTHOSTSTATECHANGE$", "NOTIFICATIONAUTHOR": "$NOTIFICATIONAUTHOR$", "NOTIFICATIONCOMMENT": "$NOTIFICATIONCOMMENT$", "NOTIFICATIONTYPE": "$NOTIFICATIONTYPE$", "SHORTDATETIME": "$SHORTDATETIME$" } ' "<URL_FROM_XMATTERS>"
} - To use Basic Authentication, use the following configuration. Replace <URL_FROM_XMATTERS> with the URL you copied from the trigger, and username:password with the username and password of the authenticating xMatters user.Copy
define contact {
contact_name xmatters
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
host_notification_commands notify_xmatters_host
}
define command {
command_name notify_xmatters_host
command_line curl -X POST -u username:password -H "Content-Type: application/json" -d ' { "OBJECTTYPE": "HOST", "CONTACTGROUPNAME": "$HOSTDISPLAYNAME$", "HOSTDISPLAYNAME": "$HOSTDISPLAYNAME$", "HOSTNAME": "$HOSTNAME$", "HOSTOUTPUT": "$HOSTOUTPUT$", "HOSTSTATE": "$HOSTSTATE$", "LASTHOSTSTATECHANGE": "$LASTHOSTSTATECHANGE$", "NOTIFICATIONAUTHOR": "$NOTIFICATIONAUTHOR$", "NOTIFICATIONCOMMENT": "$NOTIFICATIONCOMMENT$", "NOTIFICATIONTYPE": "$NOTIFICATIONTYPE$", "SHORTDATETIME": "$SHORTDATETIME$" } ' "<URL_FROM_XMATTERS>"
}
- To use URL Authentication, use the following configuration, replacing <URL_FROM_XMATTERS> with the URL you copied from the Nagios Host Notifications trigger.
- Add the target names of any recipients you want to notify when the alert fires to the end of the URL.
- For URL authentication, use an ampersand to attach recipients. For example, if you want to notify Emma Pearson and the on-call members in the group responsible for the Antares service, you'd add &recipients=epearson,antares to the URL.
- For other authentication types, use a question mark to attach recipients. For example, if you want to notify Barry Gull and the on-call members in the group responsible for the Cassiopeia service, you'd add ?recipients=bgull,cassiopeia to the URL.
- You must URL-encode any special characters or spaces in the target names.
- Save and close the xmatters.cfg file.
- Open the nagios.cfg file and go to the Object Configuration Files section.
- Add a new line to the section and type the absolute path to the xmatters.cfg file you just created. For example: cfg_file=/path/to/xmatters.cfg.
- Save and close the nagios.cfg file.
- Navigate to the options folder and open any host definitions that will send alerts to xMatters. Add contacts xmatters to the define host section.
- Restart Nagios Core to use the new configuration.
You're ready to use the webhook to trigger automated flows, including steps such as sending alerts and initiating incidents, though we always recommend testing before putting things into use. To test the webhook:
- Open Nagios Core and select a host configuration set up to contact xMatters.
- Select Forced and add a comment.
- Click Commit to send the notification.
- If you do not receive the notification in xMatters, check the Nagios log file. If the notification was sent, you'll see the following line: SERVICE NOTIFICATION: xmatters;localhost;PING;CUSTOM (OK);notify_xmatters_host
To have Nagios Core send service notifications to the flow trigger, you need to configure a webhook and set it to use the trigger URL.
- Go to the location of your Nagios Core configuration files. For example, /opt/nagios/etc.
- Create a new file in the configuration folder and name it xmatters.cfg.
- Open the new xmatters.cfg file and populate it with configuration information:
- To use URL Authentication, use the following configuration, replacing <URL_FROM_XMATTERS> with the URL you copied from the Nagios Service Notifications trigger.Copy
define contact {
contact_name xmatters
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify_xmatters_service
}
define command {
command_name notify_xmatters_service
command_line curl -X POST -H "Content-Type: application/json" -d ' { "OBJECTTYPE": "SERVICE", "HOSTNAME": "$HOSTNAME$", "CONTACTGROUPNAME": "$SERVICEDISPLAYNAME$", "LASTSERVICESTATECHANGE": "$LASTSERVICESTATECHANGE$", "NOTIFICATIONAUTHOR": "$NOTIFICATIONAUTHOR$", "NOTIFICATIONCOMMENT": "$NOTIFICATIONCOMMENT$", "NOTIFICATIONTYPE": "$NOTIFICATIONTYPE$", "SERVICEDESC": "$SERVICEDESC$", "SERVICEOUTPUT": "$SERVICEOUTPUT$", "SERVICESTATE": "$SERVICESTATE$", "SHORTDATETIME": "$SHORTDATETIME$" } ' "<URL_FROM_XMATTERS>"
} - To use Basic Authentication, use the following configuration. Replace <URL_FROM_XMATTERS> with the URL you copied from the trigger, and username:password with the username and password of the authenticating xMatters user.Copy
define contact {
contact_name xmatters
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify_xmatters_service
}
define command {
command_name notify_xmatters_service
command_line curl -X POST -u username:password -H "Content-Type: application/json" -d ' { "OBJECTTYPE": "SERVICE", "HOSTNAME": "$HOSTNAME$", "CONTACTGROUPNAME": "$SERVICEDISPLAYNAME$", "LASTSERVICESTATECHANGE": "$LASTSERVICESTATECHANGE$", "NOTIFICATIONAUTHOR": "$NOTIFICATIONAUTHOR$", "NOTIFICATIONCOMMENT": "$NOTIFICATIONCOMMENT$", "NOTIFICATIONTYPE": "$NOTIFICATIONTYPE$", "SERVICEDESC": "$SERVICEDESC$", "SERVICEOUTPUT": "$SERVICEOUTPUT$", "SERVICESTATE": "$SERVICESTATE$", "SHORTDATETIME": "$SHORTDATETIME$" } ' "<URL_FROM_XMATTERS>"
}
- To use URL Authentication, use the following configuration, replacing <URL_FROM_XMATTERS> with the URL you copied from the Nagios Service Notifications trigger.
- Add the target names of any recipients you want to notify when the alert fires to the end of the URL.
- For URL authentication, use an ampersand to attach recipients. For example, if you want to notify Emma Pearson and the on-call members in the group responsible for the Antares service, you'd add &recipients=epearson,antares to the URL.
- For other authentication types, use a question mark to attach recipients. For example, if you want to notify Barry Gull and the on-call members in the group responsible for the Cassiopeia service, you'd add ?recipients=bgull,cassiopeia to the URL.
- You must URL-encode any special characters or spaces in the target names.
- Save and close the xmatters.cfg file.
- Open the nagios.cfg file and go to the Object Configuration Files section.
- Add a new line to the section and type the absolute path to the xmatters.cfg file you just created. For example: cfg_file=/path/to/xmatters.cfg.
- Save and close the nagios.cfg file.
- Navigate to the options folder and open any service definitions that will send alerts to xMatters. Add contacts xmatters to the define service section.
- Restart Nagios Core to use the new configuration.
You're ready to use the webhook to trigger automated flows, including steps such as sending alerts and initiating incidents, though we always recommend testing before putting things into use. To test the webhook:
- Open Nagios Core and select a service configuration set up to contact xMatters.
- Add a comment, and then click Commit to send the notification.
- If you do not receive the notification in xMatters, check the Nagios log file for the following line: SERVICE NOTIFICATION: xmatters;localhost;PING;CUSTOM (OK);notify_xmatters_service
Set recipients in the trigger URL
The trigger expects the recipients in the trigger URL. When you copy the URL from xMatters, it includes the recipients parameter: recipients=<yourname>. Of course, you don’t want to receive all the alerts.
To change the recipients for alerts from this webhook, swap out your name for the people or groups you want to target. For example, to target the 'DatabaseTeam', 'Antares Service Team', and 'HR & Marketing' groups, add recipients=databaseteam,antares%20service%20team,HR%20%26%20Marketing to the trigger URL. Remember to URL-encode any special characters, including spaces, in your group names.
We recommend using groups so you can take advantage of the xMatters group features — rotations, escalations, and absences — to reach the right on-call people to jump on an issue.
How to use the workflow
When a condition you've set fires, it sends a signal to xMatters, which creates an alert and notifies the individual or the on-call members of the people or groups you set as recipients in the webhook URL. When the trigger receives a signal saying the issue is resolved, it automatically terminates related alerts in xMatters.
The person responding to the notification has the following response options:
- Acknowledge: Acknowledges the notifications and stops escalations.
- Escalate: Immediately escalates the alert to the next on-call resolver in a targeted group.
- Close: Ends the xMatters alert and stops notifying all targeted recipients.
- Initiate Incident: Initiates an incident in xMatters.
Next Steps
Now that you've installed the workflow, you can use it as-is, or customize it to suit your needs better. Here are some examples of things you can add to the workflow to customize it:
- Use Slack, Zoom, and Microsoft Teams steps to add collaboration channels to the flow.
- Update the message sent to resolvers to include the information most relevant to your team.
- Use the Nagios trigger to build your own custom flows.