ping-stats
v1.0.3
Published
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 the actual results of the ping command as well as if the ping was successful. Operating Systems Supported: OS X
Downloads
3
Readme
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
}
};