Monitor Installation

Monitoring involves three steps where you need to send http requests to different ping urls at the start and end of your script.

We outlined the detailed installation instructions for each programming language you use.

# Crontab

Make sure you replace YOUR-MONITOR-UUID with your monitor uuid and any other placeholders in the example code before using them.

Update your crontab entry to match the following format.

* * * * * START=$(curl https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start);   YOUR-COMMAND-OR-SCRIPT-HERE   &&   curl https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id=${START}

# PHP

If your application is using composer, Please see our official php client

Make sure you replace YOUR-MONITOR-UUID with your monitor id and any other placeholders in the example code before using them.

Add the following code at the beginning of your script.

$start=file_get_contents("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start");

Add the following code at the end of your script.

file_get_contents("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id=$start");

Complete code

$start=file_get_contents("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start");

try{

// your code here

file_get_contents("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id=$start");
}catch(\Exception $e){
file_get_contents("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/fail?".http_build_query(['ping_id' => $start, 'log' => $e->getMessage() ]));
}

# PHP Using Composer

Make sure you replace YOUR-MONITOR-UUID with your monitor id and any other placeholders in the example code before using them.

First, Install the php client by running

composer require binarybuilds/cronbuzz-php

Use the following code to send pings automatically.

\BinaryBuilds\CronBuzzPHP\CronBuzzTask::run('your-monitor-uuid', function (){

    // Add your code here
});

For more usage details, Please check our github repo

# NodeJs

Make sure you replace YOUR-MONITOR-UUID with your monitor id and any other placeholders in the example code before using them.

Add the following code at the beginning of your script.

const https = require('https');
let startId = await new Promise((resolve, reject) => {
    https.get('https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start', (response) => {
        let data = '';
        response.on('data', (chunk) => {
            data += chunk;
        });
        response.on('end', () => {
            resolve(data);
        });
        response.on('error', (error) => {
            reject(data);
        });
    });
});

Add the following code at the end of your script.

https.get("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id="+startId);

Complete code

const https = require('https');
let startId = await new Promise((resolve, reject) => {
    https.get('https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start', (response) => {
        let data = '';
        response.on('data', (chunk) => {
            data += chunk;
        });
        response.on('end', () => {
            resolve(data);
        });
        response.on('error', (error) => {
            reject(data);
        });
    });
});

try {

    // your code here

    https.get("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id="+startId);
}
catch (err) {
    https.get("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/fail?ping_id="+startId+"&log="+err.message);
}

# Python

Make sure you replace YOUR-MONITOR-UUID with your monitor id and any other placeholders in the example code before using them.

Add the following code at the beginning of your script.

import urllib.request
with urllib.request.urlopen('https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start') as response:
   startId = response.read()

Add the following code at the end of your script.

urllib.request.urlopen("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id="+startId)

Complete code

import urllib.request
with urllib.request.urlopen('https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start') as response:
    startId = response.read()


try:
    // Your code here

    urllib.request.urlopen("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id="+startId)

except:
    urllib.request.urlopen("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/fail?ping_id="+startId)

# Bash/Shell Script

Make sure you replace YOUR-MONITOR-UUID with your monitor id and any other placeholders in the example code before using them.

Add the following code at the beginning of your script.

START=$(curl https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start);

Add the following code at the end of your script.

curl https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id=${START}

Complete code

START=$(curl https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start);


// Your code here

curl https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id=${START}

# Java

Make sure you replace YOUR-MONITOR-UUID with your monitor id and any other placeholders in the example code before using them.

Add the following code at the beginning of your script.

URL url = new URL("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
string startId = con.getResponseMessage();

Add the following code at the end of your script.

URL finalUrl = new URL("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id="+startId);
HttpURLConnection finalCon = (HttpURLConnection) finalUrl.openConnection();
finalCon.setRequestMethod("GET");
finalCon.getResponseMessage();

Complete code


URL url = new URL("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); string startId = con.getResponseMessage(); try{ // Your code here URL finalUrl = new URL("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id="+startId); HttpURLConnection finalCon = (HttpURLConnection) finalUrl.openConnection(); finalCon.setRequestMethod("GET"); finalCon.getResponseMessage(); }catch(Exception $e){ URL expUrl = new URL("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/fail?ping_id="+startId+"&log="+e); HttpURLConnection expUrl = (HttpURLConnection) finalUrl.openConnection(); expUrl.setRequestMethod("GET"); expUrl.getResponseMessage(); }

# GoLang

Make sure you replace YOUR-MONITOR-UUID with your monitor id and any other placeholders in the example code before using them.

Add the following code at the beginning of your script.

resp, err := http.Get("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start")
defer resp.Body.Close()
startId, err := ioutil.ReadAll(resp.Body)

Add the following code at the end of your script.

resp, err := http.Get("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id="+startId)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)

Complete code

resp, err := http.Get("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start")
defer resp.Body.Close()
startId, err := ioutil.ReadAll(resp.Body)


// Your code here


resp, err := http.Get("https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id="+startId)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)

# Other

Make sure you replace YOUR-MONITOR-UUID with your monitor id and any other placeholders in the example code before using them.

For any other language not mentioned above, Please follow the below steps.

  • Ping this url(https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/start) at the beginning of your script.
  • Store the response returned by the ping url in a variable( ex: startId)
  • Ping this url(https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/complete?ping_id=startId) at the end of your script by appending the previous variable to the url as shown.
  • If any error occurred, Ping this url(https://ping.cronbuzz.com/ping/YOUR-MONITOR-UUID/fail?ping_id=startId&log=your-error-message) at the end of your script by appending the previous variable to the url as shown.