Perform health check on node
161045
function healthcheck(node) {
    var ended = false;
    var node_id = node.host + ':' + node.port;
    var client = net.connect(
      {port: node.adminport, host: node.host},
      function onConnect() {
        if (!ended) {
          client.write('health\r\n');
        }
      }
    );

    client.setTimeout(healthCheckInterval, function() {
      client.end();
      markNodeAsUnhealthy(node_id);
      client.removeAllListeners('data');
      ended = true;
    });

    client.on('data', function(data) {
      if (ended) {
        return;
      }

      var health_status = data.toString();
      client.end();
      ended = true;

      if (health_status.indexOf('up') < 0) {
        markNodeAsUnhealthy(node_id);
      } else {
        markNodeAsHealthy(node_id);
      }
    });

    client.on('error', function(e) {
      if (ended) {
        return;
      }

      if (e.code !== 'ECONNREFUSED' && e.code !== 'EHOSTUNREACH' && e.code !== 'ECONNRESET') {
        log('Error during healthcheck on node ' + node_id + ' with ' + e.code, 'ERROR');
      }

      markNodeAsUnhealthy(node_id);
    });
  }
70776
function updateCheck() {
    // CASE: The check will not happen if your NODE_ENV is not in the allowed defined environments.
    if (_.indexOf(allowedCheckEnvironments, process.env.NODE_ENV) === -1) {
        return Promise.resolve();
    }

    return api.settings.read(_.extend({key: 'next_update_check'}, internal))
        .then(function then(result) {
            const nextUpdateCheck = result.settings[0];

            // CASE: Next update check should happen now?
            // @NOTE: You can skip this check by adding a config value. This is helpful for developing.
            if (!config.get('updateCheck:forceUpdate') && nextUpdateCheck && nextUpdateCheck.value && nextUpdateCheck.value > moment().unix()) {
                return Promise.resolve();
            }

            return updateCheckRequest()
                .then(updateCheckResponse)
                .catch(updateCheckError);
        })
        .catch(updateCheckError);
}
797579
def checks(s, options = {})
      custom_params = []
      custom_params << use_named_parameter('dc', options[:dc]) if options[:dc]

      ret = send_get_request(@conn, ["/v1/health/checks/#{s}"], options, custom_params)
      JSON.parse(ret.body).map { |check| OpenStruct.new check }
    end
79554
def kube_node_status_network_unavailable(self, metric, scraper_config):
        
        service_check_name = scraper_config['namespace'] + '.node.network_unavailable'
        for sample in metric.samples:
            node_tag = self._label_to_tag("node", sample[self.SAMPLE_LABELS], scraper_config)
            self._condition_to_service_check(
                sample,
                service_check_name,
                self.condition_to_status_negative,
                tags=[node_tag] + scraper_config['custom_tags'],
            )
623832
async def run_checks(self):
        

        async for check in self.fsm.health_check():
            yield check

        async for check in self.self_check():
            yield check

        for check in MiddlewareManager.health_check():
            yield check
76621
def start_health_check(self, recipient):
        
        if recipient not in self.addresses_events:
            self.whitelist(recipient)  # noop for now, for compatibility
            ping_nonce = self.nodeaddresses_to_nonces.setdefault(
                recipient,
                {'nonce': 0},  # HACK: Allows the task to mutate the object
            )

            events = healthcheck.HealthEvents(
                event_healthy=Event(),
                event_unhealthy=Event(),
            )

            self.addresses_events[recipient] = events

            greenlet_healthcheck = gevent.spawn(
                healthcheck.healthcheck,
                self,
                recipient,
                self.event_stop,
                events.event_healthy,
                events.event_unhealthy,
                self.nat_keepalive_retries,
                self.nat_keepalive_timeout,
                self.nat_invitation_timeout,
                ping_nonce,
            )
            greenlet_healthcheck.name = f'Healthcheck for {pex(recipient)}'
            greenlet_healthcheck.link_exception(self.on_error)
            self.greenlets.append(greenlet_healthcheck)
1308663
def health_check(cls):
        

        try:
            assert isinstance(settings.MIDDLEWARES, list)
        except AssertionError:
            yield HealthCheckFail(
                '00005',
                'The "MIDDLEWARES" configuration key should be assigned '
                'to a list',
            )
            return

        for m in settings.MIDDLEWARES:
            try:
                c = import_class(m)
            except (TypeError, ValueError, AttributeError, ImportError):
                yield HealthCheckFail(
                    '00005',
                    f'Cannot import middleware "{m}"',
                )
            else:
                if not issubclass(c, BaseMiddleware):
                    yield HealthCheckFail(
                        '00005',
                        f'Middleware "{m}" does not implement '
                        f'"BaseMiddleware"',
                    )
59670
function HealthCheck($cli=false)
	{
		$saveE = $this->conn->fnExecute;
		$this->conn->fnExecute = false;
		if ($cli) $html = '';
		else $html = $this->table.'<tr><td colspan=3><h3>'.$this->conn->databaseType.'</h3></td></tr>'.$this->titles;

		$oldc = false;
		$bgc = '';
		foreach($this->settings as $name => $arr) {
			if ($arr === false) break;

			if (!is_string($name)) {
				if ($cli) $html .= " -- $arr -- \n";
				else $html .= "<tr bgcolor=$this->color><td colspan=3><i>$arr</i> &nbsp;</td></tr>";
				continue;
			}

			if (!is_array($arr)) break;
			$category = $arr[0];
			$how = $arr[1];
			if (sizeof($arr)>2) $desc = $arr[2];
			else $desc = ' &nbsp; ';


			if ($category == 'HIDE') continue;

			$val = $this->_DBParameter($how);

			if ($desc && strncmp($desc,"=",1) === 0) {
				$fn = substr($desc,1);
				$desc = $this->$fn($val);
			}

			if ($val === false) {
				$m = $this->conn->ErrorMsg();
				$val = "Error: $m";
			} else {
				if (is_numeric($val) && $val >= 256*1024) {
					if ($val % (1024*1024) == 0) {
						$val /= (1024*1024);
						$val .= 'M';
					} else if ($val % 1024 == 0) {
						$val /= 1024;
						$val .= 'K';
					}
					//$val = htmlspecialchars($val);
				}
			}
			if ($category != $oldc) {
				$oldc = $category;
				//$bgc = ($bgc == ' bgcolor='.$this->color) ? ' bgcolor=white' : ' bgcolor='.$this->color;
			}
			if (strlen($desc)==0) $desc = '&nbsp;';
			if (strlen($val)==0) $val = '&nbsp;';
			if ($cli) {
				$html  .= str_replace('&nbsp;','',sprintf($this->cliFormat,strip_tags($name),strip_tags($val),strip_tags($desc)));

			}else {
				$html .= "<tr$bgc><td>".$name.'</td><td>'.$val.'</td><td>'.$desc."</td></tr>\n";
			}
		}

		if (!$cli) $html .= "</table>\n";
		$this->conn->fnExecute = $saveE;

		return $html;
	}
128497
private function checkStatus()
    {
        if (!$this->running) {
            return;
        }

        if ($this->running) {
            foreach (proc_get_status($this->resource) as $key => $value) {
                if ($key == 'command') {
                    continue;
                }

                $this->$key = $value;
            }
        }

        if (!$this->running) {
            $this->cleanup();
        }
    }
790115
def timed_connectivity_check(self, event):
        """"""
        self.status = self._can_connect()
        self.log('Timed connectivity check:', self.status, lvl=verbose)

        if self.status:
            if not self.old_status:
                self.log('Connectivity gained')
                self.fireEvent(backend_nodestate_toggle(STATE_UUID_CONNECTIVITY, on=True, force=True))
        else:
            if self.old_status:
                self.log('Connectivity lost', lvl=warn)
                self.old_status = False
                self.fireEvent(backend_nodestate_toggle(STATE_UUID_CONNECTIVITY, off=True, force=True))

        self.old_status = self.status
399706
def check
      refresh
      primary_status = self.primary_status
      secondary_status = self.secondary_status
      mark_message "Connected to #{session.cluster.nodes.count} nodes in mongodb replica set '#{primary_status['set']}'"
    rescue ConnectionFailed => e
      mark_failure
      mark_message "Error: '#{e}'"
    end
916700
def monitor_node
      failures = 0

      loop do
        begin
          break if @done
          sleep(WATCHER_SLEEP_TIME)
          latency = Benchmark.realtime { @node.ping }
          failures = 0
          notify(:available, latency)
          @node.wait
        rescue NodeUnavailableError => ex
          logger.debug("Failed to communicate with node #{@node}: #{ex.inspect}")
          failures += 1
          if failures >= @max_failures
            notify(:unavailable)
            failures = 0
          end
        rescue Exception => ex
          logger.error("Unexpected error while monitoring node #{@node}: #{ex.inspect}")
          logger.error(ex.backtrace.join("\n"))
        end
      end
    end
1197430
def _health_check_thread(self):
        
        while self._run_health_checker:
            response = self._health_check(Health_pb2.HealthCheckRequest(service='predix-event-hub.grpc.health'))
            logging.debug('received health check: ' + str(response))
            time.sleep(30)
        return
1221712
def health_check(self):
        """"""
        logger.debug('Health Check on Table: {namespace}'.format(
            namespace=self.namespace
        ))

        try:
            self.get_all()
            return True

        except ClientError as e:
            logger.exception(e)
            logger.error('Error encountered with Database. Assume unhealthy')
            return False
696071
def check_health(settings_cls) -> int:
    
    cls_kwargs = get_kwargs(settings_cls)
    loop = asyncio.get_event_loop()
    return loop.run_until_complete(async_check_health(cls_kwargs.get('redis_settings')))
135668
def associate_health_monitor(self, pool, body):
        """"""
        return self.post(self.associate_pool_health_monitors_path % (pool),
                         body=body)
150415
def check(cls, data):
        
        conn = Qubole.agent()
        return conn.post(cls.rest_entity_path, data=data)['status']