Unleashing the Power of Nagios — Utilizing the Actions Component

The “Action URL” component has been quietly deprecated in favor of the newer “Actions” component. The “Actions” component has been released for some time now and has been rolled up into the base install of XI. Although it is most commonly used to add URLs to specific Nagios objects on the details pages in XI, it is by far more advanced than its predecessor “Action URL”. The “Actions” component is truly one of the more powerful components available for Nagios XI, on par with event handlers in extensibility and complexity.

The use cases for the Actions component are near endless. A simple example would consist of the streamlining of repeated tasks, like the adding of common comments to particular hosts. This can be accomplished using the Actions component and the command pipe. For the following example, we will assume that the comment to be added to a host relates to the completion of a successful security audit by the user “auditor”. This action will include the passing of the %host% macro to a script that will write to the Nagios command pipe.

First create a script named “security_audit_completed.sh” in /usr/local/nagios/libexec. The script follows:

More information about the Nagios command pipe can be found at:
http://nagios.sourceforge.net/docs/3_0/extcommands.html

Make the script executable:

The script above is passed one macro, the hostname (%host%). If you have worked with Nagios macros in the past, you will notice the format is different. A full list of the available macros in the Actions component format can be found in the documentation at the bottom of this post. Configure the action through the Actions component interface accessible on the “Manage Components” admin page in XI. We want this action to apply to every host, so we will use the regex: /.*/

We now need to configure the action:

Leave the other “Match Criteria” fields in the component blank for this example. Configure the “Action Type” and “Command Action” as follows:

Apply the settings and browse to any of your host’s details pages. Click the “Security Audit Successful” link and voila!, you should see a new comment after a moment or two declaring that the security audit was indeed successful.

All the portions of the component are explained in detail in the documentation. This example, among a few others can be found therein as well.

The one issue with this component was the lack of documentation, and with all of the potential uses and options, a small tutorial was necessary. The following document below walks though the basic options, explains the complex ones, and offers up a few use cases including adding comments from the link, writing to the command pipe and even emailing a ticketing system – all from hyperlinks on the details page of any Nagios object!

Actions Component Documentation

0 Responses to “Unleashing the Power of Nagios — Utilizing the Actions Component”


Comments are currently closed.