npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ws-monitor

v0.2.0

Published

A runtime and server monitor for Node.js applications with WebSocket based reporting.

Readme

ws-monitor

A runtime and server monitor for Node.js applications with WebSocket based reporting.

This allows cross-application monitoring stats sharing through WebSockets, allowing you to create central monitoring applications and dashboards.

ws-monitor usage

Still in Beta with very limited functionality. More options and customizability coming soon.

Installation

npm install ws-monitor

Usage

Require the ws-monitor module and create a WSMonitor object,

var WSMonitor = require('ws-monitor');

var monitor = new WSMonitor();

This will start the ws-monitor with the default options: running on port 8080 with 5 second poll interval.

You will see the following message on the Node.js console.

Application monitor started on port 8080

You can then use any WebSocket client to connect with the monitor and start receiving the monitor data.

Multiple clients can be connected to the same monitor, and all messages will be broadcasted to all the clients alike.

Example - Monitoring from a Node.js application

You can connect to the WebSocket server of the monitor through the same Node.js application which you have it installed, or from a different application, allowing cross-application monitor data sharing.

In the Node.js application, use a WebSocket library, such as ws to create a client and connect to the monitor.

var WebSocket = require('ws');
var ws = new WebSocket('ws://localhost:8080');

ws.on('message', function(data, flags) {
  console.log(data);
});

You will get the following messages on the console,

1462167081:HOSTNAME:0.35:4310102016:8506159104:0:14865080:31246592

1462167086:HOSTNAME:5.357:4313698304:8506159104:0:15460720:32266496

1462167091:HOSTNAME:10.393:4313415680:8506159104:0:15600072:32266496

....

....

Example - Monitoring from a Javascript frontend

If you want to monitor from the frontend - such as when you want to build a dashboard to view your Node.js application performance - you can use the javascript built-n WebSocket capability to connect to the WebSocket server of the monitor,

    var exampleSocket = new WebSocket("ws://localhost:8080");

    exampleSocket.onmessage = function (event) {
        console.log(event.data);
    };

Options

The monitor object constructor accepts several parameters,

var monitor = new WSMonitor({
                            port : 10080,
                            pollInterval : 1000,
                            debug : true,
                            logger : yourLogger
                            });

| Property | Default | Description | |-----------|-----------|-------------| | port | 8080 | The port on which the WebSocket server of the monitor will be started | | pollInterval | 5000 | The interval in which the parameters are checked and reported, in milliseconds | | debug | false | Whether the debug messages should be printed out to console | | logger | undefined | If you want to log the monitor’s events to your application logs and has a standard logger instance (such as a Winston based logger), you can pass it along with the 'logger' parameter. The logger object should support 'info', 'debug', and 'error' functions |

Output Format

The output/report format received by the clients are as follows,

<timestamp>:<hostname>:<application uptime>:<free memory>:<total memory>:<1 minute CPU load average>:<heap used>:<heap total>

Example,

1462167101:HOSTNAME:20.443:4313341952:8506159104:0:15700144:32266496

Current version only supports this delimited output format. More formats support coming soon.

Resource Friendliness

The WS-Monitor will keep track of the clients connected to it. And, if it detects that no clients are connected, it will automatically shutdown the monitoring process, and will start it up again when a client connects again, preventing the use of server resources unnecessarily,

[INFO] client disconnected from app monitor : 1R1ZFWHG47QILIK9
[INFO] no clients connected to app monitor
[INFO] halting app monitor

Node.js version compatibility

Tested on Node.js v0.10.*, 0.12.*, v5.11.0, and v6.1.0.

On Node.js v6.*.*, you will get the following deprecated warning,

DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead.

, but will not affect functionality.

The warning is coming from the depending monitor module, and is tracked in the upstream issue #29

License

MIT

Contributors

Authored by Thimira Amaratunga