If custom health check is enabled, this sends a heartbeat to it.
In most cases aws monitoring works off polling an application's endpoint
@param instance The instance of the service
@param status   The {@link HealthStatus}
508152
@Override
    protected void pulsate(ServiceInstance instance, HealthStatus status) {
        // this only work if you create a health status check when you register it
        // we can't really pulsate anywhere because amazon health checks work inverse from this UNLESS you have a custom health check
        Optional<String> opt = instance.getInstanceId();
        if (!opt.isPresent()) {
            // try the metadata
            if (instance.getMetadata().contains("instanceId")) {
                opt = Optional.of(instance.getMetadata().asMap().get("instanceId"));
            } else {
                if (LOG.isErrorEnabled()) {
                    LOG.error("Cannot determine the instance ID. Are you sure you are running on AWS EC2?");
                }
            }
        }

        opt.ifPresent(instanceId -> {
            if (discoveryService != null && discoveryService.getHealthCheckCustomConfig() != null) {
                CustomHealthStatus customHealthStatus = CustomHealthStatus.UNHEALTHY;

                if (status.getOperational().isPresent()) {
                    customHealthStatus = CustomHealthStatus.HEALTHY;
                }

                UpdateInstanceCustomHealthStatusRequest updateInstanceCustomHealthStatusRequest = new UpdateInstanceCustomHealthStatusRequest()
                                                                                                            .withInstanceId(instanceId)
                                                                                                            .withServiceId(route53AutoRegistrationConfiguration.getAwsServiceId())
                                                                                                            .withStatus(customHealthStatus);
                getDiscoveryClient().updateInstanceCustomHealthStatus(
                        updateInstanceCustomHealthStatusRequest);
            }

            if (status.getOperational().isPresent() && !status.getOperational().get()) {
                getDiscoveryClient().deregisterInstance(new DeregisterInstanceRequest().withInstanceId(instanceId).withServiceId(route53AutoRegistrationConfiguration.getAwsServiceId()));
                LOG.info("Health status is non operational, instance id " + instanceId + " was de-registered from the discovery service.");
            }

        });

    }
1113789
public void acknowledgeHeartBeat( Instance scopedInstance ) {

		String count = scopedInstance.data.get( MISSED_HEARTBEATS );
		if( count != null
				&& Integer.parseInt( count ) > THRESHOLD )
			this.logger.info( "Agent " + InstanceHelpers.computeInstancePath( scopedInstance ) + " is alive and reachable again." );

		// Store the moment the first ACK (without interruption) was received.
		// If we were deploying, store it.
		// If we were in problem, store it.
		// If we were already deployed and started, do NOT override it.
		if( scopedInstance.getStatus() != InstanceStatus.DEPLOYED_STARTED
				|| ! scopedInstance.data.containsKey( Instance.RUNNING_FROM ))
			scopedInstance.data.put( Instance.RUNNING_FROM, String.valueOf( new Date().getTime()));

		scopedInstance.setStatus( InstanceStatus.DEPLOYED_STARTED );
		scopedInstance.data.remove( MISSED_HEARTBEATS );
	}
552419
@EventListener(HeartbeatEvent.class)
    public void heartbeat(final HeartbeatEvent event) {
        if (this.monitor.update(event.getValue())) {
            for (final DiscoveryClientNameResolver discoveryClientNameResolver : this.discoveryClientNameResolvers) {
                discoveryClientNameResolver.refresh();
            }
        }
    }
26519
@Then("^service '(.+?)' status in cluster '(.+?)' is '(suspended|running|deploying)'( in less than '(\\d+?)' seconds checking every '(\\d+?)' seconds)?")
    public void serviceStatusCheck(String service, String cluster, String status, String foo, Integer totalWait, Integer interval) throws Exception {
        String response;
        Integer i = 0;
        boolean matched;

        response = commonspec.retrieveServiceStatus(service, cluster);

        if (foo != null) {
            matched = status.matches(response);
            while (!matched && i < totalWait) {
                this.commonspec.getLogger().info("Service status not found yet after " + i + " seconds");
                i = i + interval;
                response = commonspec.retrieveServiceStatus(service, cluster);
                matched = status.matches(response);
            }
        }

        assertThat(status).as("Expected status: " + status + " doesn't match obtained one: " + response).matches(response);

    }
562126
synchronized void statusUpdate(TaskStatus status) {
    setProgress(status.getProgress());
    this.runState = status.getRunState();
    this.stateString = status.getStateString();
    this.nextRecordRange = status.getNextRecordRange();

    setDiagnosticInfo(status.getDiagnosticInfo());
    
    if (status.getStartTime() > 0) {
      this.startTime = status.getStartTime(); 
    }
    if (status.getFinishTime() > 0) {
      setFinishTime(status.getFinishTime()); 
    }
    
    this.phase = status.getPhase();
    this.counters = status.getCounters();
    this.outputSize = status.outputSize;
  }
261755
synchronized boolean processHeartbeat(
                                 TaskTrackerStatus trackerStatus,
                                 boolean initialContact) {
    String trackerName = trackerStatus.getTrackerName();

    synchronized (taskTrackers) {
      synchronized (trackerExpiryQueue) {
        boolean seenBefore = updateTaskTrackerStatus(trackerName,
                                                     trackerStatus);
        TaskTracker taskTracker = getTaskTracker(trackerName);
        if (initialContact) {
          // If it's first contact, then clear out
          // any state hanging around
          if (seenBefore) {
            LOG.warn("initialContact but seenBefore from Tracker : " + trackerName);
            lostTaskTracker(taskTracker);
          }
        } else {
          // If not first contact, there should be some record of the tracker
          if (!seenBefore) {
            LOG.warn("Status from unknown Tracker : " + trackerName);
            updateTaskTrackerStatus(trackerName, null);
            return false;
          }
        }

        if (initialContact) {
          // if this is lost tracker that came back now, and if it blacklisted
          // increment the count of blacklisted trackers in the cluster
          if (isBlacklisted(trackerName)) {
            faultyTrackers.incrBlackListedTrackers(1);
          }
          addNewTracker(taskTracker);
        }
      }
    }

    updateTaskStatuses(trackerStatus);
    updateNodeHealthStatus(trackerStatus);

    return true;
  }
1329853
public void sendStatus(Status status) {
        if (connection != null) {
            final boolean andReturn = !status.getCode().equals(StatusCodes.NS_DATA_START);
            final Invoke event = new Invoke();
            if (andReturn) {
                final PendingCall call = new PendingCall(null, CALL_ON_STATUS, new Object[] { status });
                if (status.getCode().equals(StatusCodes.NS_PLAY_START)) {
                    IScope scope = connection.getScope();
                    if (scope.getContext().getApplicationContext().containsBean(IRtmpSampleAccess.BEAN_NAME)) {
                        IRtmpSampleAccess sampleAccess = (IRtmpSampleAccess) scope.getContext().getApplicationContext().getBean(IRtmpSampleAccess.BEAN_NAME);
                        boolean videoAccess = sampleAccess.isVideoAllowed(scope);
                        boolean audioAccess = sampleAccess.isAudioAllowed(scope);
                        if (videoAccess || audioAccess) {
                            final Call call2 = new Call(null, "|RtmpSampleAccess", null);
                            Notify notify = new Notify();
                            notify.setCall(call2);
                            notify.setData(IoBuffer.wrap(new byte[] { 0x01, (byte) (audioAccess ? 0x01 : 0x00), 0x01, (byte) (videoAccess ? 0x01 : 0x00) }));
                            write(notify, connection.getStreamIdForChannelId(id));
                        }
                    }
                }
                event.setCall(call);
            } else {
                final Call call = new Call(null, CALL_ON_STATUS, new Object[] { status });
                event.setCall(call);
            }
            // send directly to the corresponding stream as for some status codes, no stream has been created  and thus "getStreamByChannelId" will fail
            write(event, connection.getStreamIdForChannelId(id));
        }
    }
1093926
@Override
    public final JsHealthState getHealthState()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            SibTr.entry(this, tc, "getHealthState");
            SibTr.exit(this, tc, "getHealthState", "return=" + _healthState);
        }
        return _healthState;
    }
608762
public void status(int statusTag, Object[] o) {
        switch (statusTag) {
            case STATUS_INST_BPD_INIT:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_INST_DATA"));
                break;
            case STATUS_INST_BPD_INIT_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_INST_DATA_DONE"));
                break;
            case STATUS_INST_GET_KEYS:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_INST_KEYS"));
                break;
            case STATUS_INST_GET_KEYS_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_INST_KEYS_DONE"));
                break;
            case STATUS_SEND_KEYS:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_SEND_MY_KEYS"));
                break;
            case STATUS_SEND_KEYS_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_SEND_MY_KEYS_DONE"));
                getOutStream().println("status: " + ((HBCIMsgStatus) o[0]).toString());
                break;
            case STATUS_INIT_SYSID:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_SYSID"));
                break;
            case STATUS_INIT_SYSID_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_SYSID_DONE", o[1].toString()));
                getOutStream().println("status: " + ((HBCIMsgStatus) o[0]).toString());
                break;
            case STATUS_INIT_SIGID:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_SIGID"));
                break;
            case STATUS_INIT_SIGID_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_SIGID_DONE", o[1].toString()));
                getOutStream().println("status: " + ((HBCIMsgStatus) o[0]).toString());
                break;
            case STATUS_INIT_UPD:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_USER_DATA"));
                break;
            case STATUS_INIT_UPD_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_REC_USER_DATA_DONE"));
                break;
            case STATUS_LOCK_KEYS:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_USR_LOCK"));
                break;
            case STATUS_LOCK_KEYS_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_USR_LOCK_DONE"));
                getOutStream().println("status: " + ((HBCIMsgStatus) o[0]).toString());
                break;
            case STATUS_DIALOG_INIT:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_DIALOG_INIT"));
                break;
            case STATUS_DIALOG_INIT_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_DIALOG_INIT_DONE", o[1]));
                getOutStream().println("status: " + ((HBCIMsgStatus) o[0]).toString());
                break;
            case STATUS_SEND_TASK:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_DIALOG_NEW_JOB",
                    ((AbstractHBCIJob) o[0]).getName()));
                break;
            case STATUS_SEND_TASK_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_DIALOG_JOB_DONE",
                    ((AbstractHBCIJob) o[0]).getName()));
                break;
            case STATUS_DIALOG_END:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_DIALOG_END"));
                break;
            case STATUS_DIALOG_END_DONE:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_DIALOG_END_DONE"));
                getOutStream().println("status: " + ((HBCIMsgStatus) o[0]).toString());
                break;
            case STATUS_MSG_CREATE:
                getOutStream().println("  " + HBCIUtils.getLocMsg("STATUS_MSG_CREATE", o[0].toString()));
                break;
            case STATUS_MSG_SIGN:
                getOutStream().println("  " + HBCIUtils.getLocMsg("STATUS_MSG_SIGN"));
                break;
            case STATUS_MSG_CRYPT:
                getOutStream().println("  " + HBCIUtils.getLocMsg("STATUS_MSG_CRYPT"));
                break;
            case STATUS_MSG_SEND:
                getOutStream().println("  " + HBCIUtils.getLocMsg("STATUS_MSG_SEND"));
                break;
            case STATUS_MSG_RECV:
                getOutStream().println("  " + HBCIUtils.getLocMsg("STATUS_MSG_RECV"));
                break;
            case STATUS_MSG_PARSE:
                getOutStream().println("  " + HBCIUtils.getLocMsg("STATUS_MSG_PARSE", o[0].toString() + ")"));
                break;
            case STATUS_MSG_DECRYPT:
                getOutStream().println("  " + HBCIUtils.getLocMsg("STATUS_MSG_DECRYPT"));
                break;
            case STATUS_MSG_VERIFY:
                getOutStream().println("  " + HBCIUtils.getLocMsg("STATUS_MSG_VERIFY"));
                break;
            case STATUS_SEND_INFOPOINT_DATA:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_SEND_INFOPOINT_DATA"));
                break;

            case STATUS_MSG_RAW_SEND:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_MSG_RAW_SEND", o[0].toString()));
                break;

            case STATUS_MSG_RAW_RECV:
                getOutStream().println(HBCIUtils.getLocMsg("STATUS_MSG_RAW_RECV", o[0].toString()));
                break;

            default:
                throw new HBCI_Exception(HBCIUtils.getLocMsg("STATUS_INVALID", Integer.toString(statusTag)));
        }
    }
582703
public void setInstanceHealthSummary(java.util.Collection<InstanceHealthSummary> instanceHealthSummary) {
        if (instanceHealthSummary == null) {
            this.instanceHealthSummary = null;
            return;
        }

        this.instanceHealthSummary = new java.util.ArrayList<InstanceHealthSummary>(instanceHealthSummary);
    }
1141953
protected void onServiceInstanceUnavailable(ServiceInstance instance){
        if(instance == null){
            return ;
        }
        String serviceName = instance.getServiceName();
        synchronized(notificationHandlers){
            if(notificationHandlers.containsKey(serviceName)){
                for(NotificationHandler h : notificationHandlers.get(serviceName)){
                    h.serviceInstanceUnavailable(instance);
                }
            }
        }
    }
641999
private void setStatus(ConnectionStatus status){
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("Set status to - " + status);
        }
        if(! this.status.equals(status)){
            ConnectionStatus pre = this.status;
            this.status = status;
            eventThread.queueClientEvent(new ClientStatusEvent(pre, status));
        }
    }
892515
protected void onServiceInstanceChanged(ServiceInstance instance){
        String serviceName = instance.getServiceName();
        List<NotificationHandler> handlerList = new ArrayList<NotificationHandler>();
        synchronized (notificationHandlers) {
            if (notificationHandlers.containsKey(serviceName)) {
                handlerList.addAll(notificationHandlers.get(serviceName));
            }
        }
        for (NotificationHandler h : handlerList) {
            h.serviceInstanceChange(instance);
        }
    }
67165
private void printServiceInstance(ServiceInstance instance) {
        print("\nServiceInstance\n-------------------------");
        if (instance == null) {
            print("null");
            return;
        }
        print("serviceName:  " + instance.getServiceName());
        print("status:  " + instance.getStatus());
        print("uri:  " + instance.getUri());
        print("address:  " + instance.getAddress());
        print("monitorEnabled:  " + instance.isMonitorEnabled());
        print("metadata:");
        Map<String, String> meta = instance.getMetadata();
        for (Entry<String, String> entry : meta.entrySet()) {
            print("  " + entry.getKey() + "  =>  " + entry.getValue());
        }
    }
344949
public void setTopologyStatus(TopologyAssignEvent event) throws Exception {
        StormClusterState stormClusterState = nimbusData.getStormClusterState();

        String topologyId = event.getTopologyId();
        String topologyName = event.getTopologyName();
        String group = event.getGroup();

        StormStatus status = new StormStatus(StatusType.active);
        if (event.getOldStatus() != null) {
            status = event.getOldStatus();
        }

        boolean isEnable = ConfigExtension.isEnablePerformanceMetrics(nimbusData.getConf());
        StormBase stormBase = stormClusterState.storm_base(topologyId, null);
        if (stormBase == null) {
            stormBase = new StormBase(topologyName, TimeUtils.current_time_secs(), status, group);
            stormBase.setEnableMonitor(isEnable);
            stormClusterState.activate_storm(topologyId, stormBase);
        } else {
            stormClusterState.update_storm(topologyId, status);
            stormClusterState.set_storm_monitor(topologyId, isEnable);

            // here exist one hack operation
            // when monitor/rebalance/startup topologyName is null
            if (topologyName == null) {
                event.setTopologyName(stormBase.getStormName());
            }
        }

        LOG.info("Update " + topologyId + " " + status);
    }
1267478
def wait_for_instance(instance):
    

    status = None
    print("getting status for instance {} ...".format(instance.id))
    while status is None:
        try:
            status = instance.update()
            if status is None:
                time.sleep(2)
        except EC2ResponseError:
            time.sleep(2)

    print("waiting for instance {} ...".format(instance.id))

    while status == "pending":
        time.sleep(2)
        status = instance.update()

    if status != "running":
        print("Invalid status when starting instance {}: {}".format(instance.id, status))
        return False

    print("New instance {} started: {}".format(instance.id, instance.ip_address))
    return True
543127
void heartbeat() {
        if (!clusterService.isJoined()) {
            return;
        }

        checkClockDrift(heartbeatIntervalMillis);

        final long clusterTime = clusterClock.getClusterTime();
        if (clusterService.isMaster()) {
            heartbeatWhenMaster(clusterTime);
        } else {
            heartbeatWhenSlave(clusterTime);
        }
    }