How to use the ping.promise function in ping

To help you get started, we’ve selected a few ping examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github suskind / network-list / src / index.js View on Github external
function getInfo(ip, callback) {
	const result = {
		ip,
		alive: false,
		hostname: null,
		mac: null,
		vendor: null,
        hostnameError: null,
        macError: null,
        vendorError: null,
	};
    // console.log(`Checking ${ip}...`);
    ping.promise.probe(ip, {
        timeout: options.timeout,
    }).then((res) => {
        if (res.alive) {
            result.alive = true;
            dns.reverse(ip, (err, host) => {
                if (err) {
                    result.hostnameError = 'Error on get hostname';
                } else {
                    result.hostname = (host && host.length) ? host[0] : null;
                }
                arp.getMAC(ip, (err2, mac) => {
                    if(err2 || !mac) {
                        result.macError = 'Error on get Mac address';
                    } else {
                        result.mac = mac.replace(/:([^:]{1}):/g, ':0$1:');
                    }
github AlexGustafsson / homebridge-wol / lib / pinger.js View on Github external
async ping() {
    this.debugLog('Attempting to ping "%s" (%s)', this.config.name, this.config.ip || 'unknown ip');

    // Timeout is given in seconds
    const response = await ping.promise.probe(this.config.ip, {timeout: this.config.pingTimeout / 1000});
    this.debugLog('Result of pinging "%s" (%s): %s', this.config.name, this.config.ip || 'unknown ip', response.alive ? 'online' : 'offline');
    return response.alive;
  }
github jesusprubio / bluebox-ng / lib / protocols / ping.js View on Github external
new Promise((resolve, reject) => {
    const result = { up: false };
    const timeout = opts.timeout || 5000;
    const cliOpts = {
      timeout: timeout / 1000,
      // TODO: Add as parameter
      extra: ['-i', '2'], // 2 attempt
    };

    dbg('Starting, opts', cliOpts);
    cli.promise.probe(rhost, cliOpts)
    .then((res) => {
      dbg('Response received', res);

      // We're only sending one so if no max -> host down.
      if (res.alive) {
        result.up = true;
        // We only made one, so avg is the same and the parsing is easier.
        result.data = res.output;
      }

      resolve(result);
    })
    .catch(err => reject(err));
  });
github jesusprubio / bluebox-ng / lib / index / ping.js View on Github external
(rhost) => {
      const attempts = opts.attempts || 3;
      const reqCfg = {
        // TODO: Not working for values over > 2000
        // timeout: opts.timeout || 5000,
        extra: [`-i ${attempts.toString()}`],
      };

      return ping.promise.probe(rhost, reqCfg);
    },
    // TODO: Review
github icymind / VRouter / src / renderer / lib / utils.js View on Github external
const p1 = new Promise((resolve, reject) => {
      ping.promise.probe(ip, {
        timeout: 1,
        min_reply: 1
      })
        .then(res => {
          resolve(res.alive)
        })
    })
github rosmod / webgme-rosmod / src / common / remote_utils.js View on Github external
testPing: function(ip) {
	    var self = this;
	    var ping = require('ping');
	    return ping.promise.probe(ip)
		.then(function (res) {
		    if (!res.alive)
			throw new String(ip + ' is not reachable.');
		    return true;
		});
	},
	testSSH: function(ip, user) {
github WFCD / genesis / src / commands / Core / Ping.js View on Github external
'use strict';

const ping = require('ping').promise;
const Command = require('../../models/Command.js');
const { timeDeltaToString, games } = require('../../CommonFunctions.js');

const d2Hosts = [
  'bungie.net',
  'api.steampowered.com',
  'xbl.io',
  'vlkyrie-superi.us',
  'status.vlkyrie-superi.us',
];

const wfHosts = [
  'warframe.com',
  'api.warframestat.us',
  'hub.warframestat.us',
  'drops.warframestat.us',
github readium / readium-desktop / src / main / redux / sagas / net.ts View on Github external
function pingHost() {
    return ping.promise.probe(PINGABLE_HOST, PING_CONFIG);
}
github ottomatica / Baker / lib / modules / utils / utils.js View on Github external
static async hostIsAccessible(host) {
        return (await ping.promise.probe(host, {extra: ['-i 2']})).alive;
    }
github miladbonakdar / ICMP-server / server / cron / pingHost.js View on Github external
module.exports = async hostName => {
    try {
        let pingResponse = await ping.promise.probe(hostName);
        return pingResponse.alive;
    } catch (exception) {
        return false;
    }
};

ping

a simple wrapper for ping

MIT
Latest version published 1 year ago

Package Health Score

66 / 100
Full package analysis