Aim
To understand the function and use of action templates.
Action templates
Definition
An action template is a predefined command that can be used when configuring a host, a service or a user service.
The command will only be executed when there is a confirmed OK to CRITICAL change of status.
They are useful in automatically resolving issues such as restarting a service (Windows or Linux) or executing a linux command.
The available templates can be modified according to customer needs.
Predefined action commands
Action templates support the following commands:
Applies to | Description | Action command |
User Service | Writing a variable in the external application PCvue | write_arcinfo_pcvue_variable |
Hosts | Write to the syslog file of the Linux device associated with the action. | write_syslog_host |
Execution of a DOS or Powershell command on any Windows device via winexe or winrm. | launch_command_windows_host | |
Calling a URL using GET or POST, passing variables in the URL or as expected content. | call_url_host | |
Service | Execute a command via SSH on any port, on the host associated with the service | launch_command_linux_debian |
Execution of a DOS or Powershell command on any Windows device via winexe or winrm. | launch_command_windows_service | |
Restart a service on Debian Linux OS, via SSH, on the host associated with the service. | restart_service_linux_debian | |
Restart a service on Windows OS, via SSH, on the host associated with the service. | restart_service_windows | |
Write to the syslog file of the Linux device associated with the action. Possibility of not executing this action if the device is in CRITICAL or UNKNOWN state. Possibility of not executing this action if the host or service is in maintenance mode. | write_syslog_service | |
Calling a URL using GET or POST, passing variables in the URL or as expected content. | call_url_service |
Product Variables
The product variables (Nagios macro) that can be used in the action template settings are as follows:
For Hosts:
- $_HOSTCOMPANYNAME$
- $_HOSTDOCUMENTATION$
- $_HOSTHOST_CATEGORY_NAME$
- $_HOSTIDHOST$
- $_HOSTINSTRUCTIONS$
- $HOSTADDRESS$
- $HOSTALIAS$
- $HOSTDOWNTIME$
- $HOSTOUTPUT$
- $HOSTSTATE$
- $HOSTSTATETYPE$
- $_HOSTCRITICALITY$
For Services:
- $_HOSTCOMPANYNAME$
- $_HOSTHOST_CATEGORY_NAME$
- $_SERVICEDISPLAYNAME$
- $_SERVICEDOCUMENTATION$
- $_SERVICEHOSTALIAS$
- $_SERVICEIDSERVICE$
- $_SERVICEINSTRUCTIONS$
- $HOSTADDRESS$
- $HOSTDOWNTIME$
- $HOSTSTATE$
- $SOWNTIME SERVICE $
- $SERVICEOUTPUT$
- $SERVICESTATE$
- $SERVICESTATETYPE$
- $_HOSTCRITICALITY$
- $_SERVICECRITICALITY$
Configuration
Creation of an action template
To add an action template, go to the section Configuration and then to the menu General > Action template.
Click on "Add": a configuration window opens.
Fill in the general information then click on " Apply ".
You can add action templates for a host, a service or a user service.
Modifying an action template
You can modify an action template. To do so, click on the name of the template to be modified.
Deleting an action template
Select the action template to be deleted and then click on the "Delete" button.
Confirm the deletion of the action template.
Using action templates
Assigning the template to a host, service or user service
To assign an action template to a service, go to Monitoring and then to the menu Monitoring.
Example : I want to automatically restart the Windows Update service if it stops on my server COPCGRE61.
Select the service to modify. The configuration window opens. Go to Action and choose the template.
Enter the service to be restarted and click on Apply.
Note Configuration is the same for a host or user service
Changing the action template
To change an action template, proceed as for adding. Select the command to be used from the list of action templates.
Deleting an action model
To delete an action model from a service, go to the section Monitoring and then to the menu Monitoring.
Select the service you want to change. The configuration window opens. Go to Action then select the empty field from the list Template.
Then click on Apply.