npm.io
1.2.0 • Published 5 years ago

simple-ws-monitor

Licence
MIT
Version
1.2.0
Deps
2
Size
11 kB
Vulns
0
Weekly
0
Stars
2

simple-ws-monitor

Description

simple-ws-monitor is a monitoring app runs on Node.

It is aimed to periodically send various information about the system to the users such as CPU and RAM usage.

Examples

Server:
const Monitor = require("simple-ws-monitor");

const PORT = 8000;

const monitoringService = new Monitor({
    port: 8000,
    cpu: true,
    ram: true,
});
Client:
const PORT = 8000;
const monitoringService = new WebSocket(`ws://localhost:${PORT}`);

monitoringService.onerror = (e) => console.log(e);
monitoringService.onmessage = (msg) => console.log(JSON.parse(msg));
Result (in client console):
{
    Header: "Monitoring",
    Payload: {
        cpu: {
            count: "4",
            usage: "1.25",
        },
        ram: {
            total: "16.4",
            usage: "41.30",
        }
    }
}

Installation

npm i simple-ws-monitor

Usage

Import package on server side
const Monitor = require("simple-ws-monitor");
Start service
const monitoringService = new Monitor({
    port: 8000,
    cpu: true,
    ram: true,
});

simple-monitor is now ready and waiting for connections.

Development

Clone repository:
git clone https://github.com/yasinosman/simple-ws-monitor
cd simple-ws-monitor
Install packages:
npm install
Start development server
npm run dev

Contributing

Feel free to create issues or create pull requests.

Keywords