A simple, backend-only Node.js package to monitor a specific website for downtime. If the site becomes unreachable, it sends a notification using the Pushbullet service.
-
Continuous Monitoring: Periodically checks a target URL to ensure it's online.
-
Stateful Notifications: Sends a notification only when the site's status changes (i.e., when it first goes down and when it first comes back up) to avoid spam.
-
Pushbullet Integration: Leverages Pushbullet for reliable push notifications to your devices.
-
Flexible Configuration: Configure via command-line arguments or environment variables.
-
Lightweight: No front-end, designed to run as a background service.
-
Node.js (v14 or later)
-
A Pushbullet account
Clone or download the package files, then navigate into the directory and install the dependencies:
npm install
-
Go to your Pushbullet Account Settings page: https://www.pushbullet.com/#settings/account
-
Scroll down to "Access Tokens" and click "Create Access Token".
-
Copy this token. This is your API key.
You can configure the notifier in two ways. Command-line arguments will always override environment variables.
You can pass configuration directly when you run the script.
--url: The website to watch.
--apiKey: Your Pushbullet API key.
--interval: (Optional) The check interval in milliseconds.
node index.js --url="https://example.com" --apiKey="o.YOUR_API_KEY_HERE" --interval=60000
Create a file named .env in the root of the project directory.
Now, open the .env file and fill in the required values. These will be used if no corresponding command-line arguments are provided.
# Your Pushbullet API key from your account settings
PUSHBULLET_API_KEY="YOUR_API_KEY_HERE"
# The full URL of the website you want to monitor
URL_TO_WATCH="https://example.com"
# (Optional) The time between checks in milliseconds. Defaults to 5 minutes (300000).
CHECK_INTERVAL_MS="300000"
Once configured, you can start the monitoring script directly from your terminal.
npm start
node index.js --url="https://example.com" --apiKey="o.YOUR_KEY"
For long-term use, you should run this script with a process manager like pm2 to ensure it runs continuously in the background.
# Install pm2 globally
npm install pm2 -g
# Start the notifier with pm2, passing arguments
pm2 start index.js --name "website-monitor" --url="https://example.com" --apiKey="o.YOUR_KEY"
You can also integrate the monitoring logic into your own Node.js application.
const { startMonitoring } = require('./index');
// Note: The Pushbullet API key must be set as an environment variable
// or passed directly to the startMonitoring function if you modify it.
startMonitoring('https://example.com', 60000);