0.0.8 • Published 11 months ago

js-monitor-server v0.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

JS Resources Monitor

A real-time monitoring tool for JavaScript applications that tracks CPU usage and memory consumption.

JS Monitor Server

Table of Contents

Features

  • Real-time monitoring of CPU usage and memory consumption
  • Web-based UI for easy visualization
  • Customizable monitoring interval
  • WebSocket communication for live updates

Prerequisites

  • Node.js (version 12 or higher recommended)
  • npm (Node Package Manager)

Installation

  1. Install the js-monitor-server as dependency of your application:

    npm install js-monitor-server@latest

Usage

  1. Import the library as dependency of your ESM nodejs app.

    import 'js-monitor-server';

    For common js modules, use dynamic import:

    import('js-monitor-server');
  2. The default web server port is 9966. You can change it by changing the MONITOR_PORT environment variable in the .env file.

  3. Open a web browser and navigate to http://localhost:9966 (or the port specified in your environment variables).

  4. The UI will display real-time CPU and memory usage of the monitored process.

File Structure

  • index.js: Entry point of the application
  • server.js: Sets up the Express server and Socket.io
  • monitor.js: Contains the Monitor class for tracking system resources
  • public/index.html: The frontend UI for displaying monitoring data

How It Works

  1. The Monitor class in monitor.js uses Node.js's process.cpuUsage() and process.memoryUsage() to collect system resource data.
  2. The Express server in server.js serves the frontend and sets up WebSocket communication using Socket.io.
  3. The frontend (index.html) receives real-time updates via WebSocket and displays the data using charts (implementation not shown in the provided code).

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago