ping-stats

1.0.3 • Public • Published

Ping-Stats

A Node.js library wrapper around the ping command for use within Node.js. Unlike the majority of the ping libraries out there, this one returns not only if the ping was considered successful and the host is "alive", it also returns a JSON object containing the actual results of the ping including the actual textual result of the ping command as well as the parsed values for the minimum, average, maximum, and standard deviation for the ping response times.

Operating Systems Supported: OS X, CentOS, Ubuntu (Windows with some more work).

This is an extension of the node-ping library created by Daniel Zelisko (http://github.com/danielzzz/node-ping) credit is due to him for the majority of the code base. If you need a Node.js library that simply returns a boolean value indicating if the host responded to the ping command be sure to check out his library.

Installation

npm install ping-stats --save

Use

ping.sys.probe(data.clientIp, function(results, err){
    if(err){
        logger.error(err, null);
    } else {
        // TODO: process results object
    }
});

Results

var result = {
    host: addr,         // the host address for the system that was pinged
    code: code,         // the ping command result code
    isAlive: false,     // whether or not the host responded and the ping was considered successful
    output: outstring,  // the actual text that was output by the ping command
    stats: {
        min = 0;        // the minimum ping response time 
        avg = 0;        // the average ping response time
        max = 0;        // the max ping response time
        stddev = 0;     // the standard deviation for the ping response time
    }
};

Readme

Keywords

none

Package Sidebar

Install

npm i ping-stats

Weekly Downloads

4

Version

1.0.3

License

none

Last publish

Collaborators

  • schleichermann