This is very simple promise-based module to make system-level ping requests. Works in Windows / Linux / Mac.
Node 8+
npm install system-ping
const ping = require( 'system-ping' );
ping( '127.0.0.1' ).then( ({ total, received }) => {
console.log( `Sent ${total} packets, received ${received} packets` );
if( total === received ){
console.log( 'Ping was successful' );
}
else{
console.warn( 'Some problems with host 127.0.0.1' );
}
});
ping( '127.0.0.1', { 'packetsCount': 8 } ) // How much packets to send for this ping