1.0.1 • Published 12 months ago

server-health-checker v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
12 months ago

Server Health Checker

This project monitors server health by checking CPU usage, memory usage, and disk space. It displays the health check results in the console and sends an alert using the souq-error-handler package if any of the health checks enter the red zone.

Usage

To use the Server Health Checker in your project, first install it as a dependency:

npm install --save server-health-checker

Then, import and use the Server Health Checker in your project:

const ServerHealthChecker = require("server-health-checker");

// Initialize ServerHealthChecker instance
const checker = new ServerHealthChecker(intervalInSeconds, logToConsole /*true or false*/);

// Start monitoring server health
checker.startMonitoring();

Parameters

intervalInSeconds (number): The interval in seconds between server health checks.

logToConsole (boolean, optional, default: true): Whether to display server health check results in the console. Pass false to disable console logs.

Example Usage

  1. Using Server Health Checker with console logs enabled (default behavior):
const ServerHealthChecker = require("server-health-checker");

const checker = new ServerHealthChecker(60); // Check server health every 60 seconds
checker.startMonitoring();
  1. Using Server Health Checker with console logs disabled:
const ServerHealthChecker = require("server-health-checker");

const checker = new ServerHealthChecker(60, false); // Check server health every 60 seconds without console logs
checker.startMonitoring();