Ping the device on the other end of the connection

    .. code-block: bash

        salt '*' onyx.cmd ping
514251
def ping():
    '''
    
    '''
    if _worker_name() not in DETAILS:
        init()
    try:
        return DETAILS[_worker_name()].conn.isalive()
    except TerminalException as e:
        log.error(e)
        return False
197196
def _send_command(self, command, raw_text=False):
        
        return self.device.show(command, raw_text=raw_text)
818257
def ping(self, destination, length=20):
        
        print '%s call ping' % self.port
        print 'destination: %s' %destination
        try:
            cmd = 'ping %s %s' % (destination, str(length))
            print cmd
            self._sendline(cmd)
            self._expect(cmd)
            # wait echo reply
            time.sleep(1)
        except Exception, e:
            ModuleHelper.WriteIntoDebugLogger("ping() Error: " + str(e))
692903
def _cmd(self, endpoint, cmd):
        
        cmdbuf = "%s\n" % (cmd)
        # some cmds have large outputs and ZK closes the connection as soon as it
        # finishes writing. so read in huge chunks.
        recvsize = 1 << 20
        replies = []
        host, port = endpoint

        ips = get_ips(host, port)

        if len(ips) == 0:
            raise self.CmdFailed("Failed to resolve: %s" % (host))

        for ip in ips:
            try:
                with connected_socket((ip, port)) as sock:
                    sock.send(cmdbuf.encode())
                    while True:
                        buf = sock.recv(recvsize).decode("utf-8")
                        if buf == "":
                            break
                        replies.append(buf)
            except socket.error as ex:
                # if there's only 1 record, give up.
                # if there's more, keep trying.
                if len(ips) == 1:
                    raise self.CmdFailed("Error(%s): %s" % (ip, ex))

        return "".join(replies)
221771
def verbose_ping(hostname, timeout=WAIT_TIMEOUT, count=NUM_PACKETS,
                 packet_size=PACKET_SIZE, path_finder=False):
    
    signal.signal(signal.SIGINT, signal_handler)   # Handle Ctrl-C
    if hasattr(signal, "SIGBREAK"):
        # Handle Ctrl-Break e.g. under Windows
        signal.signal(signal.SIGBREAK, signal_handler)

    myStats = MyStats()  # Reset the stats

    mySeqNumber = 0  # Starting value

    try:
        destIP = socket.gethostbyname(hostname)
        print("\nPYTHON PING %s (%s): %d data bytes" %
              (hostname, destIP, packet_size))
    except socket.gaierror as e:
        print("\nPYTHON PING: Unknown host: %s (%s)" %
              (hostname, e.args[1]))
        print()
        return

    myStats.thisIP = destIP

    for i in range(count):
        delay = do_one(myStats,
                       destIP,
                       hostname,
                       timeout,
                       mySeqNumber,
                       packet_size)

        if not delay:
            delay = 0

        mySeqNumber += 1

        # Pause for the remainder of the MAX_SLEEP period (if applicable)
        if (MAX_SLEEP > delay):
            time.sleep((MAX_SLEEP - delay) / 1000)

    dump_stats(myStats)
264125
def _send_cmd(self, cmd: str):
        """"""
        self._sock.sendall(cmd.encode(encoding='latin-1', errors='strict'))
243956
def ping(self, message=None):
        '''
        '''
        return self.write(self.parser.ping(message), encode=False)
525874
def ping(self):
        """"""

        ret, data = self.sendmess(MSG_NOP, bytes())
        if data or ret > 0:
            raise ProtocolError('invalid reply to ping message')
        if ret < 0:
            raise OwnetError(-ret, self.errmess[-ret])
208178
def send_one_ping(self, current_socket):
        
        # Header is type (8), code (8), checksum (16), id (16), sequence (16)
        checksum = 0

        # Make a dummy header with a 0 checksum.
        header = struct.pack(
            "!BBHHH", ICMP_ECHO, 0, checksum, self.own_id, self.seq_number
        )

        padBytes = []
        startVal = 0x42
        for i in range(startVal, startVal + (self.packet_size)):
            padBytes += [(i & 0xff)]  # Keep chars in the 0-255 range
        data = bytes(padBytes)

        # Calculate the checksum on the data and the dummy header.
        checksum = calculate_checksum(header + data) # Checksum is in network order

        # Now that we have the right checksum, we put that in. It's just easier
        # to make up a new header than to stuff it into the dummy.
        header = struct.pack(
            "!BBHHH", ICMP_ECHO, 0, checksum, self.own_id, self.seq_number
        )

        packet = header + data

        send_time = default_timer()

        try:
            current_socket.sendto(packet, (self.destination, 1)) # Port number is irrelevant for ICMP
        except socket.error as e:
            print("General failure (%s)" % (e.args[1]))
            current_socket.close()
            return

        return send_time
619069
def send_command(command)
      SerialPort.open(self.device_path, 9600, 8, 1) do |port|
        # flush anything existing on the port
        port.flush
        flush_read_buffer(port)

        byte_string = command.to_bytes.pack('C*')

        begin
          while byte_string && byte_string.length != 0
            count = port.write_nonblock(byte_string)
            byte_string = byte_string[count,-1]

            port.flush
          end
        rescue IO::WaitWritable
          if IO.select([], [port], [], 5)
            retry
          else
            raise IOError, "Timeout writing command to #{self.device_path}"
          end
        end

        # wait for expected confirmation signals
        got_eot = false
        got_soh = false
        loop do
          begin
            c = port.read_nonblock(1)

            case c
              when "\x04"
                if ! got_eot
                  got_eot = true
                else
                  raise IOError, "Got EOT reply twice from #{self.device_path}"
                end
              when "\x01"
                if got_eot
                  if ! got_soh
                    got_soh = true

                    break
                  else
                    raise IOError, "Got SOH twice from #{self.device_path}"
                  end
                else
                  raise IOError, "Got SOH before EOT from #{self.device_path}"
                end
            end
          rescue IO::WaitReadable
            if IO.select([port], [], [], 3)
              retry
            else
              raise IOError, "Timeout waiting for command reply from #{self.device_path}.  EOT:#{got_eot} SOH:#{got_soh}"
            end
          end
        end
      end

      self
    end
200270
def ping(hostname: str, timeout_s: int = 5) -> bool:
    
    if sys.platform == "win32":
        timeout_ms = timeout_s * 1000
        args = [
            "ping",
            hostname,
            "-n", "1",  # ping count
            "-w", str(timeout_ms),  # timeout
        ]
    elif sys.platform.startswith('linux'):
        args = [
            "ping",
            hostname,
            "-c", "1",  # ping count
            "-w", str(timeout_s),  # timeout
        ]
    else:
        raise AssertionError("Don't know how to ping on this operating system")
    proc = subprocess.Popen(args,
                            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    proc.communicate()
    retcode = proc.returncode
    return retcode == 0
423789
def connect(self):
        
        self.end_live_capture = False
        if not self.ommit_ping and not self.helper.test_ping():
            raise ZKNetworkError("can't reach device (ping %s)" % self.__address[0])
        if not self.force_udp and self.helper.test_tcp() == 0:
            self.user_packet_size = 72 # default zk8
        self.__create_socket()
        self.__session_id = 0
        self.__reply_id = const.USHRT_MAX - 1
        cmd_response = self.__send_command(const.CMD_CONNECT)
        self.__session_id = self.__header[2]
        if cmd_response.get('code') == const.CMD_ACK_UNAUTH:
            if self.verbose: print ("try auth")
            command_string = make_commkey(self.__password, self.__session_id)
            cmd_response = self.__send_command(const.CMD_AUTH, command_string)
        if cmd_response.get('status'):
            self.is_connect = True
            return self
        else:
            if cmd_response["code"] == const.CMD_ACK_UNAUTH:
                raise ZKErrorResponse("Unauthenticated")
            if self.verbose: print ("connect err response {} ".format(cmd_response["code"]))
            raise ZKErrorResponse("Invalid response: Can't connect")
830768
def _ping(self) -> bool:
        """"""
        assert self.socket is not None
        resp = None
        try:
            self.socket.sendall(b"PINGPING")
            resp = self.socket.recv(8)
        except Exception:
            pass
        return resp == b"PONGPONG"
313510
function ping (host, callback) {
  var isWin = process.platform.indexOf('win') === 0; // win32 or win64
  var arg = isWin ? '-n' : '-c';
  var pong = spawn('ping', [arg, '3', host]); // only ping 3 times

  pong.on('error', function onerror (error) {
    callback(error, false);
    pong.kill();
  });

  pong.stdout.on('data', function stdoutdata (data) {
    callback(false, data.toString().split('\n')[0].substr(14));
    pong.kill();
  });

  pong.stderr.on('data', function stderrdata (data) {
    callback(new Error(data.toString().split('\n')[0].substr(14)), false);
    pong.kill();
  });
}
1339753
def start_pinging(self) -> None:
        """"""
        assert self.ping_interval is not None
        if self.ping_interval > 0:
            self.last_ping = self.last_pong = IOLoop.current().time()
            self.ping_callback = PeriodicCallback(
                self.periodic_ping, self.ping_interval * 1000
            )
            self.ping_callback.start()
506363
def send(self, s, end=os.linesep, signal=False):
        """"""

        if self.blocking:
            raise RuntimeError('send can only be used on non-blocking commands.')

        if not signal:
            if self._uses_subprocess:
                return self.subprocess.communicate(s + end)
            else:
                return self.subprocess.send(s + end)
        else:
            self.subprocess.send_signal(s)
150669
def ping():
    '''
    
    '''
    try:
        client = _get_client()
        client.info()
    except SaltSystemExit as err:
        log.warning(err)
        return False

    return True