Nonsense Placement Mandatory


    0.2.0 • Public • Published


    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.


    npm install ws-monitor


    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) {

    You will get the following messages on the console,


    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) {


    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>



    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




    Authored by Thimira Amaratunga


    npm i ws-monitor

    DownloadsWeekly Downloads






    Last publish


    • thimira