Webhook / HTTP Alert Channel
The Webhook / HTTP channel makes an HTTP POST request to the specified URL, encapsulating the alert data in an XML string, JSON object, or Serialized-PHP array.
This enables you to invoke a Remote Procedure Call (RPC) within your system, allowing applications to automatically take action when Wormly alerts are triggered.
Bear in mind that your URL should point to a different webserver than the one being monitored, since sending HTTP alerts to a crashed server will obviously fail. The HTTP timeout for sending alerts is 5 seconds
What's in the HTTP request?
Wormly will make a single HTTP POST request to the specified URL, containing one POST variable: wormlyalert.
Depending on the data format you have specified, this variable will contain either an XML string, a JSON object, or a serialized PHP array.
What information is provided with the alert?
All three data formats include the following components:
A unique ID identifying the Wormly host from which the alert has been triggered.
The customer-specified name of the Wormly host.
0 if this alert indicates a failure, 1 if the alert indicates that the host has recovered from a prior failure.
The amount of time (in seconds) for which the host has been down.
A unique ID identifying the current alert escalation level.
The textual name describing the current alert escalation level.
An array of the hosts' sensors which have failed their tests.
Contents of "failedsensors" array elements
The sensor type, e.g. HTTP, POP3, etc.
A globally unique ID identifying this sensor.
The error message indicating why this sensor failed the test.
XML Data Format
An example of this data in XML format is shown below:
<?xml version="1.0" encoding="UTF-8"?> <wormlyalert> <hostid>5112</hostid> <name>WWW Server-7</name> <isrecovery>0</isrecovery> <downtime>300</downtime> <alertlevel>2</alertlevel> <alertlevel_name>Continued Error</alertlevel_name> <failedsensors> <sensor> <type>HTTP</type> <sensorid>501</sensorid> <message>Failed to connect to TCP port 80.</message> </sensor> </failedsensors> </wormlyalert>
Serialized PHP Array Format
To receive alerts with a PHP script, you simply need to unserialize the alert data as follows:
<?php $alertdata = unserialize($_POST["wormlyalert"]); ?>
JSON Object Format
There are libraries available for most platforms to parse JSON objects into native data structures. See JSON.org for more details.
Within PHP (versions 5.2 and later), the task is trivial:
<?php $alertdata = json_decode($_POST["wormlyalert"]); ?>