Blog Post

Raising the bar with BitBar (Mac)

We now offer a new alert integration for Mac users. Get the script to learn how to implement this integration right away.

Mat Ryer (@matryer) has developed a neat tool for Mac OS X that allows you to put the output from any script or program right into your menu bar. Your script can be written using BASH, Ruby, Python, PHP etc.

After stumbling across this tool, it soon became apparent this would be an excellent next victim candidate to integrate with the Catchpoint Pull API. Below is a screenshot of the tool in action.

Mac OS X integration screenshot 2

To begin, you need to visit and download and install BitBar (it is completely free, but donations are appreciated).

Once you have copied to your Applications folder and created your plugins folder, we can start on the integration. For this, I will mainly be using PHP.

Create your plugin filename by following the convention of {name}.{refresh}.{ext} e.g. catchpoint.5m.php. This will have the plugin run your script every five minutes in BitBar.

Below is an example script that fetches your alerts and formats them nicely for you.



/* Display Catchpoint logo on menu bar */












echo “—\n”;

/* Configure Catchpoint API Key/Secret */

$key   = ‘<Your_Catchpoint_API_Key’;

$secret = ‘<Your_Catchpoint_API_Secret>’;

/* Get Auth Token */

$data = array(‘grant_type’ => ‘client_credentials’, ‘client_id’ => $key, ‘client_secret’ => $secret);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, ‘’);

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);


$result = json_decode($result);

/* Base64 encode the token */

$_SESSION[‘token’] = base64_encode($result->access_token);

$ch = curl_init();

/* Fetch last 5 alerts */

curl_setopt($ch, CURLOPT_URL, ‘’);

curl_setopt($ch, CURLOPT_HTTPHEADER,

array(‘Authorization: Bearer ‘ . $_SESSION[‘token’]));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$data = curl_exec($ch);


$alerts = json_decode($data);

/* Apply styling to each alert */

foreach ($alerts->alerts as $a) {

switch ($a->level->id) {

case 0:

$color = ‘#ff8000’;

$state = ‘Warning’;

$emoji = ‘:neutral_face:’;


case 1:

$color = ‘#ff0000’;

$state = ‘Critical’;

$emoji = ‘:worried:’;


case 3:

$color = ‘#80ff00’;

$state = ‘OK’;

$emoji = ‘:smile:’;



echo “:clock1030: ” . $a->report_time . ” | size=10 color=” . $color. “\n”;

echo $emoji . ” Test: ” . $a->test->name . ” – ” . $state . “| size= 10 color=” . $color . ” href=” . $a->test->id . “&z=&chartView=1\n”;

echo “Reason: ” . $a->alert_type->name . ” | size=10 color=#000000\n”;

echo “—\n”;


Save this and make sure it is executable (chmod +x catchpoint.5m.php); you will then get your alerts (if you have any) listed in the new plugin e.g.

For additional integration you can add an extra line that will display the last alert received in your Notifications. Add the following line to the bottom of the above script:

echo exec(“osascript -e ‘display notification \”” . $a->report_time . ” – ” . $a->alert_type->name . “\” with title \”” . $a->test->name . ” – ” . $state . “\”‘”);

There you have it … Catchpoint alerts integrated right into your Mac OS X desktop! Enjoy!

API Monitoring

You might also like

Blog post

Unraveling AWS Lambda: Exploring Scalability and Applicability

Blog post

Applying JSON Patch Operations with ASP.NET Core Web API

Blog post

How can companies improve Network and API performance?