To send alert notifications to a REST API such as ServiceNow, create a notification group (Configure > Notification Groups) using a custom script:
- To use a custom script, go to the Delivery Address section and click Add.
- In the address editor, select the Script address type.
- In the Custom Script file field, enter the script followed by the required variables.
There are several custom scripts available for interacting with a REST API:
Script | Type | Example |
url_executor.cs | HTTP GET |
url_executor.cs "http://www.example.com/url_to_call" |
url_executor_pwd.cs | HTTP GET with basic authentication |
url_executor_pwd.cs "http://www.example.com/url_to_call" "Username" "Password" |
Url_PostExecutor.cs | HTTP POST with the content of a custom Alert Template |
Url_PostExecutor.cs "http://www.example.com/url_to_call" "123456" "Username" "Password" " \n Accept:application/json \n Content-Type:application/json" |
Available arguments for url_executor.cs:
- <URL> – address to call.
Available arguments for url_executor_pwd.cs:
- <URL> – address to call.
- <username><password>- authentication parameters.
For Url_PostExecutor.cs use the available arguments in the provided order:
- <URL> – address to call.
- <Template ID> – custom alert template ID. If the parameter is omitted the default alert template is used.
- <Username><Password>- authentication parameters.
- <CustomHeaders> – list of custom headers separated by /n (the script accepts a maximum number of 5 variables, so if you require multiple headers, you should include them in a list separated by \n as shown in the example above).
- <Method> – HTTP method for RESTful Services.
- <URLUptime> – address to send Uptime alerts.
- <TemplateIDUptime> – custom template ID for Uptime alerts. If the parameter is omitted the default alert template is used.
- <UsernameUptime><PasswordUptime>- authentication parameters.
- <CustomHeadersUptime> – list of custom headers separated by /n.
- <MethodUptime> – HTTP method for RESTful Services.
Find a Template ID in the URL bar of the related template edit page (Configure > Alert Templates).
Sending Uptime Alerts with Url_PostExecutor.cs
The Url_PostExecutor.cs script supports sending Uptime alerts to the specified URL address after the device has reported successful monitoring results. In the case when the <TemplateIDUptime> argument is specified the script will use the corresponding alert template to send Uptime alerts.
Herewith, if the <URLUptime> argument exists the network settings provided in <UsernameUptime>, <PasswordUptime>, <CustomHeadersUptime>, <MethodUptime> will be used to perform a call.
Posting Specific Variables with Url_PostExecutor.cs
When using the Url_PostExecutor.cs script to post variables to a site you will also need to create a custom template to include the necessary variables:
- Navigate to Configure > Alerts Templates, and select the option to create a new template.
- Then in the source fields, add the necessary variables.
Check the available variables below:
<%Contact_Full_Name%> <%Contact_Org_Name%> <%Contact_Title_Name%> <%Site_Name%> <%Monitor_Datetime%> <%Duration%> <%Location%> <%TaskInfo%> <%TaskType%> <%Task_Name%> <%Error_Code%> <%Error_Dscr%> <%Reason%>