Ping request to check status of elasticsearch host
176407
def ping(self, callback=None, **kwargs):
        
        self.client.fetch(
            self.mk_req('', method='HEAD', **kwargs),
            callback = callback
        )
1045872
def index_exists(index, hosts=None, profile=None):
    '''
    
    '''
    es = _get_instance(hosts, profile)

    try:
        return es.indices.exists(index=index)
    except elasticsearch.exceptions.NotFoundError:
        return False
    except elasticsearch.TransportError as e:
        raise CommandExecutionError("Cannot retrieve index {0}, server returned code {1} with message {2}".format(index, e.status_code, e.error))
1259923
def status(self, host=None):
        
        if host is None:
            host_cores = self.host_cores
        else:
            host_cores = [hc for hc in self.host_cores if hc[0] == host]
        lst = []
        for host, _ in host_cores:
            ready = general.socket_ready((host, self.ctrl_port))
            lst.append((host, 'running' if ready else 'not-running'))
        return lst
675551
def ping(cls, host=None, count=1):
        
        option = '-n' if platform.system().lower() == 'windows' else '-c'
        return cls.execute('ping',
                           "{option} {count} {host}".format(option=option,
                                                            count=count,
                                                            host=host))
154645
def ping(self):
        
        response = self.request(
            url="ping",
            method='GET',
            expected_response_code=204
        )

        return response.headers['X-Influxdb-Version']
479397
public void updateStatus() {

    String hostaddr = null;
    try {
      hostaddr = InetAddress.getByName(ip).getHostAddress();
    } catch (UnknownHostException e) {
      online = false;
      latency = Long.MAX_VALUE;
      return;
    }

    int total = 0;
    long totalPing = 0;

    // test ping 4 times
    int times = 4;

    while (total < times) {
      total++;
      long start = System.currentTimeMillis();

      SocketAddress sockaddr = new InetSocketAddress(hostaddr, port);
      try (Socket socket = new Socket()) {
        socket.connect(sockaddr, 1000);
      } catch (Exception e) {
        online = false;
        return;
      }

      totalPing += (System.currentTimeMillis() - start);
    }

    online = true;
    latency = totalPing / total;
  }
567552
def ping():
    '''
    
    '''
    if DETAILS.get('esxi_host'):
        return True
    else:
        # TODO Check connection if mechanism is SSPI
        if DETAILS['mechanism'] == 'userpass':
            find_credentials(DETAILS['host'])
            try:
                __salt__['vsphere.system_info'](host=DETAILS['host'],
                                                username=DETAILS['username'],
                                                password=DETAILS['password'])
            except SaltSystemExit as err:
                log.warning(err)
                return False
    return True
1090371
function _fetchHostMeta(host, callback) {
	var url = "http://" + host + "/.well-known/host-meta";
	console.log("Requesting host meta at " + url);
   	Http.get(url, function(err, response, content) {
		if (err) return callback(err);
		if (response.statusCode == 200) {
			try {
			    callback(null, _parseHostMeta(content));
			} catch (e) {
			    callback(e);
			}
   		} else {
   			callback(new Error("Fetching host meta returned HTTP Status " + response.statusCode));
   		}
    });
}
369735
def get_guest_connection_status(self, userid):
        ''''''
        rd = ' '.join(('getvm', userid, 'isreachable'))
        results = self._request(rd)
        if results['rs'] == 1:
            return True
        else:
            return False
16607
def ping(proxy=None, hostport=None):
    
    schema = {
        'type': 'object',
        'properties': {
            'status': {
                'type': 'string'
            },
        },
        'required': [
            'status'
        ]
    }

    assert proxy or hostport, 'Need either proxy handle or hostport string'
    if proxy is None:
        proxy = connect_hostport(hostport)

    resp = {}

    try:
        resp = proxy.ping()
        resp = json_validate( schema, resp )
        if json_is_error(resp):
            return resp

        assert resp['status'] == 'alive'

    except ValidationError as e:
        if BLOCKSTACK_DEBUG:
            log.exception(e)

        resp = {'error': 'Server response did not match expected schema.  You are likely communicating with an out-of-date Blockstack node.', 'http_status': 502}
        return resp

    except socket.timeout:
        log.error("Connection timed out")
        resp = {'error': 'Connection to remote host timed out.', 'http_status': 503}
        return resp

    except socket.error as se:
        log.error("Connection error {}".format(se.errno))
        resp = {'error': 'Connection to remote host failed.', 'http_status': 502}
        return resp

    except Exception as ee:
        if BLOCKSTACK_DEBUG:
            log.exception(ee)

        log.error("Caught exception while connecting to Blockstack node: {}".format(ee))
        resp = {'error': 'Failed to contact Blockstack node.  Try again with `--debug`.', 'http_status': 500}
        return resp

    return resp
275356
private void checkForIndexTemplate() {
        try {
            HttpURLConnection connection = openConnection( "/_template/metrics_template", "HEAD");
            if (connection == null) {
                LOGGER.error("Could not connect to any configured elasticsearch instances: {}", Arrays.asList(hosts));
                return;
            }
            connection.disconnect();

            boolean isTemplateMissing = connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND;

            // nothing there, lets create it
            if (isTemplateMissing) {
                LOGGER.debug("No metrics template found in elasticsearch. Adding...");
                HttpURLConnection putTemplateConnection = openConnection( "/_template/metrics_template", "PUT");
                if(putTemplateConnection == null) {
                    LOGGER.error("Error adding metrics template to elasticsearch");
                    return;
                }

                JsonGenerator json = new JsonFactory().createGenerator(putTemplateConnection.getOutputStream());
                json.writeStartObject();
                json.writeStringField("template", index + "*");
                json.writeObjectFieldStart("mappings");

                json.writeObjectFieldStart("_default_");
                json.writeObjectFieldStart("_all");
                json.writeBooleanField("enabled", false);
                json.writeEndObject();
                json.writeObjectFieldStart("properties");
                json.writeObjectFieldStart("name");
                json.writeObjectField("type", "string");
                json.writeObjectField("index", "not_analyzed");
                json.writeEndObject();
                json.writeEndObject();
                json.writeEndObject();

                json.writeEndObject();
                json.writeEndObject();
                json.flush();

                putTemplateConnection.disconnect();
                if (putTemplateConnection.getResponseCode() != 200) {
                    LOGGER.error("Error adding metrics template to elasticsearch: {}/{}" + putTemplateConnection.getResponseCode(), putTemplateConnection.getResponseMessage());
                }
            }
            checkedForIndexTemplate = true;
        } catch (IOException e) {
            LOGGER.error("Error when checking/adding metrics template to elasticsearch", e);
        }
    }
1043712
def ping(self):
        
        start = time.time()
        self._conn.ping()
        return (time.time() - start)
1241190
def ping():
    '''
    
    '''
    try:
        session, cookies, csrf_token = logon()
        logout(session, cookies, csrf_token)
    except salt.exceptions.CommandExecutionError:
        return False
    except Exception as err:
        log.debug(err)
        return False
    return True
125361
def ping(self, params=None):
        
        try:
            return self.transport.perform_request("HEAD", "/", params=params)
        except TransportError:
            return False
1241253
def _handle_ping(client, topic, dct):
        """"""
        if dct['type'] == 'request':
            resp = {
                'type': 'answer',
                'name': client.name,
                'source': dct
            }

            client.publish('ping', resp)
150221
def ping(self, timestamp=None):
        
        cmd = 'ping'
        if timestamp: cmd += ' %s' % timestamp
        return tuple(map(float, self.fetch(cmd)[1].split()[1:]))
876377
def get_status(self):
        """"""
        req_url = ENDPOINTS["getStatus"].format(self.ip_address, self.zone_id)
        return request(req_url)