Introduction
Puppeteer is an open-source Node.js library developed and maintained by Google. This library provides a high-level control over Chrome or Chromium, using DevTools Protocol. Puppeteer runs a headless browser by default, however, it can also use a full, non-headless browser.
Chromium is also an open-source web browser by Google. It provides easy integration with third-party tools.
Prerequisites
- Node.js installed
Installation & Configuration
Log in to your Linux node and navigate to the directory below.
/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox
Install Puppeteer and Chromium
The command below will install Puppeteer with the latest version of Chromium.
$ npm i puppeteer
Implementation
Write the Custom Script
-
Navigate to /opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox to create a shell script.
$ vi index.js -
Paste the code below and save it.
#!/usr/bin/env node
const puppeteer = require('puppeteer');
async function run() {
const browser = await puppeteer.launch({args: ['--no-sandbox']});
const page = await browser.newPage();
await page.goto('https://www.catchpoint.com/');
await page.screenshot({path: 'Step1.png'});
if (await page.$('.green-button') !== null){
console.log('Availability:1');
}
else {
console.log('Availability:0');
}
await browser.close();
}
run()
Note: You can modify the above code as per your requirement.
- Run these commands to change the permission and owner of the shell script.
$ chmod 500 index.js
$ chown serveruser index.js
Create the Custom Test
Create a Custom Test within the Portal with the JSON template below. Make sure that you replace the necessary values.
{
"shell_command_file_name":"index.js"
}
Results
Based on the output that prints on the console, you can create Tracepoints and Indicators to capture the metrics and analyze it in the Portal.
This is an example used for monitoring availability of a website. Based on the script run, it will return either “1,” when script passes or “0,” when the script fails.

Here are the results of the test:
Now we can set up Insight to capture and analyze the results.
