---
title: "Custom Monitor Monitoring with Puppeteer and Chromium"
slug: "custom-monitor-monitoring-with-puppeteer-and-chromium"
updated: 2023-01-06T15:49:51Z
published: 2023-01-06T15:49:51Z
canonical: "docs.catchpoint.com/custom-monitor-monitoring-with-puppeteer-and-chromium"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.catchpoint.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Monitor Monitoring with Puppeteer and Chromium

## 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

1. Navigate to **/opt/3genlabs/hawk/syntheticnode/service/shellmonitor/sandbox** to create a shell script.
`$ vi index.js`

2. 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.*

3. 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.
![](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/360020126792-mceclip0.png)

Here are the results of the test:

Now we can set up Insight to capture and analyze the results.
![](https://cdn.document360.io/cb4af8f9-6751-4fd2-b39c-07aae832badb/Images/Documentation/360020126812-mceclip1.png)
