Initial commit
This commit is contained in:
30
node_modules/ping/examples/example.js
generated
vendored
Normal file
30
node_modules/ping/examples/example.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// -------- example -----------------------
|
||||
|
||||
'use strict';
|
||||
|
||||
var ping = require('../index');
|
||||
|
||||
var hosts = ['192.168.1.1', 'google.com', 'yahoo.com'];
|
||||
hosts.forEach(function (host) {
|
||||
// Running with default config
|
||||
ping.sys.probe(host, function (isAlive) {
|
||||
var msg = isAlive ?
|
||||
'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log(msg);
|
||||
});
|
||||
|
||||
// Running with custom config
|
||||
ping.sys.probe(host, function (isAlive) {
|
||||
var msg = isAlive ?
|
||||
'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log(msg);
|
||||
}, {extra: ['-i', '2']});
|
||||
|
||||
// Running ping with some default argument gone
|
||||
ping.sys.probe(host, function (isAlive) {
|
||||
var msg = isAlive ?
|
||||
'host ' + host + ' is alive' : 'host ' + host + ' is dead';
|
||||
console.log(msg);
|
||||
}, {extra: ['-i', '2'], timeout: false});
|
||||
});
|
||||
|
Reference in New Issue
Block a user