Sample Web Hook

 

As part of our API alerts feature, your customers can add custom web hooks which will be called in the event of an alert or recovery. This allows your customers to setup a script on an alternate web server from the one they are checking that will parse a json post containing the details of the alert. A WebHook API alert will send a request to a URL on your server containing one post variable called webhook_data. The webhook_data field contains a json string with the following data:

results: will be true if this is a recovery alert and will be false if this is a down alert.
key: The key you enter below used to authenticate the hook request.
alert_date_time: The time the alert was sent.
downtime: The total downtime of this alert.
check_name: The name of the check.
hostname: The hostname/url of the check.
check_type: The type of check being performed.
check_notes: User entered check notes.
failure_message: User entered custom failure message, this is only sent on a failure.
recover_message: User entered custom recovery message, this is only sent on recovery.
first_down_time: When the first down alert was sent.
location: The location of the check failure, this is only sent on failure not on recovery. 
error_message: The error message from the check, this is only sent on failure. 
dns_hostname: The dns hostname being checked, only sent for the alert type of DNS.
dns_record_type: The record type of the DNS check, only sent for the alert type of DNS.
dns_server: The dns server being used to perform the check, only sent for the alert type of DNS.

 

The following is a simple web hook that checks the key that was passed and prints the downtime. This wouldn't actually do anything, this is just an example to get you started.

<?php

$results = json_decode($_POST['webhook_data']);

if ($results->key == "mysecretkey") {

echo $results->downtime;

}

?>

 

  • 95 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

Installation Guide

Requirements You will need at least one Cent OS 6 (64 bit recommended) VPS/Dedicated server with...

Adding ServerPing Package

  Login to your WHMCS Admin Area and go to Setup->Products/Services->Products/Services...

Adding a SMS Credits Package

Login to your WHMCS Admin Area and go to Setup->Products/Services->Products/Services...

Adding ServerPing to your Client Area template

You will need to provide a link to the SeverPing module from your client area. We recommend...

System Requirements

Requirements You will need at least one Cent OS 6 (64 bit recommended) VPS/Dedicated server with...