Check SERVER_UPTIME metric and if its value is lower than the stored one -
monitored apache server was restarted. In this case all DIFFLONG statValues
need resetting.

@param status latest status data.
333428
protected void handleStatsResetIfNeeded(StatusData<ApacheMetrics> status) {
        StatValue uptime = getStatValue(ApacheMetrics.SERVER_UPTIME);
        Long currUptime = Long.class.cast(status.get(ApacheMetrics.SERVER_UPTIME));
        if (uptime != null && currUptime != null && uptime.getValueAsLong() > currUptime) {
            for (ApacheMetrics metric : getAvailableMetrics()) {
                if (metric.getType() == StatValueTypes.DIFFLONG) {
                    StatValue stat = getStatValue(metric);
                    if (stat != null)
                        stat.reset();
                }
            }
        }
    }
263301
def check_rest_server(rest_port):
    ''''''
    retry_count = 5
    for _ in range(retry_count):
        response = rest_get(check_status_url(rest_port), REST_TIME_OUT)
        if response:
            if response.status_code == 200:
                return True, response
            else:
                return False, response
        else:
            time.sleep(3)
    return  False, response
1046761
public static function checkStatus($status) {
        switch ($status) {
            case Status::STATUS_OK:
                return true;
            case self::STATUS_UNREADABLE_JSON_OBJECT:
                return UnreadableRequestException::getClass();
            case self::STATUS_MALFORMED_RECEIPT_DATA:
                return MalformedReceiptDataException::getClass();
            case self::STATUS_UNAUTHENTICATED_RECEIPT:
                return UnauthenticatedReceiptException::getClass();
            case self::STATUS_UNAVAILABLE_SERVER:
                return UnavailableServerException::getClass();
            case self::STATUS_IS_PRODUCTION_RECEIPT_ON_SANDBOX:
                return ProductionReceiptOnSandboxException::getClass();
            case self::STATUS_IS_SANDBOX_RECEIPT_ON_PRODUCTION:
                return SandboxReceiptOnProductionException::getClass();
            default:
                return InvalidReceiptException::getClass();
        }
    }
742981
public function theServerShouldReturnStatusCode($status)
    {
        Assertions::assertNotNull($this->response, 'Missing response. Can you not send request?');
        Assertions::assertEquals($status, $this->response->getStatusCode(), 'Invalid HTTP status code.');
    }
627902
@GuardedBy("lock")
  private void updateStats() {
    mInternalStatFs = updateStatsHelper(mInternalStatFs, mInternalPath);
    mExternalStatFs = updateStatsHelper(mExternalStatFs, mExternalPath);
    mLastRestatTime = SystemClock.uptimeMillis();
  }
387171
private void serverInventoryInitialized()
  {
    long start = System.currentTimeMillis();
    long serverSyncWaitTimeout = config.getServerTimeout() + 2 * ChangeRequestHttpSyncer.HTTP_TIMEOUT_EXTRA_MS;

    List<DruidServerHolder> uninitializedServers = new ArrayList<>();
    for (DruidServerHolder server : servers.values()) {
      if (!server.isSyncedSuccessfullyAtleastOnce()) {
        uninitializedServers.add(server);
      }
    }

    while (!uninitializedServers.isEmpty() && ((System.currentTimeMillis() - start) < serverSyncWaitTimeout)) {
      try {
        Thread.sleep(5000);
      }
      catch (InterruptedException ex) {
        throw new RE(ex, "Interrupted while waiting for queryable server initial successful sync.");
      }

      log.info("Checking whether all servers have been synced at least once yet....");
      Iterator<DruidServerHolder> iter = uninitializedServers.iterator();
      while (iter.hasNext()) {
        if (iter.next().isSyncedSuccessfullyAtleastOnce()) {
          iter.remove();
        }
      }
    }

    if (uninitializedServers.isEmpty()) {
      log.info("All servers have been synced successfully at least once.");
    } else {
      for (DruidServerHolder server : uninitializedServers) {
        log.warn(
            "Server[%s] might not yet be synced successfully. We will continue to retry that in the background.",
            server.druidServer.getName()
        );
      }
    }

    log.info("Calling SegmentCallback.segmentViewInitialized() for all callbacks.");

    runSegmentCallbacks(
        new Function<SegmentCallback, CallbackAction>()
        {
          @Override
          public CallbackAction apply(SegmentCallback input)
          {
            return input.segmentViewInitialized();
          }
        }
    );
  }
1214644
public StatusData<ApacheMetrics> parse(String status) {
        if (StringUtils.isEmpty(status))
            throw new IllegalArgumentException("Empty status to parse!");

        final StatusData<ApacheMetrics> result = new StatusData<>();
        String[] lines = StringUtils.tokenize(status, '\n');
        //extract hostname separately
        result.put(ApacheMetrics.HOSTNAME, lines[0]);
        lines = Arrays.copyOfRange(lines, 1, lines.length);

        for (String line : lines) {
            line = line.trim();
            final int delimIndex = line.indexOf(": ");
            if (delimIndex <= 0) {
                LOGGER.warn("ApacheStatusParser: failed to parse status line: '" + line + "'.");
            } else {
                final String metric = line.substring(0, delimIndex);
                final String value  = line.substring(2+ delimIndex);
                switch (metric) {
                    case "ServerVersion": break;
                    case "ServerMPM": break;
                    case "Server Built": break;
                    case "CurrentTime": break;
                    case "RestartTime": break;
                    case "ParentServerConfigGeneration": break;
                    case "ParentServerMPMGeneration": break;
                    case "ServerUptimeSeconds": result.put(ApacheMetrics.SERVER_UPTIME, value); break;
                    case "ServerUptime": result.put(ApacheMetrics.UPTIME, value); break;
                    case "Load1": result.put(ApacheMetrics.LOAD_1M, value); break;
                    case "Load5": result.put(ApacheMetrics.LOAD_5M, value); break;
                    case "Load15": result.put(ApacheMetrics.LOAD_15M, value); break;
                    case "Total Accesses":
                        result.put(ApacheMetrics.TOTAL_ACCESSES, value);
                        result.put(ApacheMetrics.REQUESTS_PER_SEC, value);
                        break;
                    case "Total kBytes":
                        result.put(ApacheMetrics.TOTAL_KBYTES, value);
                        result.put(ApacheMetrics.KBYTES_PER_SEC, value);
                        break;
                    case "CPUUser": result.put(ApacheMetrics.CPU_USER, value); break;
                    case "CPUSystem": result.put(ApacheMetrics.CPU_SYSTEM, value); break;
                    case "CPUChildrenUser": result.put(ApacheMetrics.CPU_CHILDREN_USER, value); break;
                    case "CPUChildrenSystem": result.put(ApacheMetrics.CPU_CHILDREN_SYSTEM, value); break;
                    case "CPULoad": result.put(ApacheMetrics.CPU_LOAD, value); break;
                    case "Uptime": break;
                    case "ReqPerSec": break;
                    case "BytesPerSec": break;
                    case "BytesPerReq": break;
                    case "BusyWorkers": result.put(ApacheMetrics.WORKERS_BUSY, value); break;
                    case "IdleWorkers": result.put(ApacheMetrics.WORKERS_IDLE, value); break;
                    case "ConnsTotal": result.put(ApacheMetrics.CONNECTIONS_TOTAL, value); break;
                    case "ConnsAsyncWriting": result.put(ApacheMetrics.CONNECTIONS_ASYNC_WRITING, value); break;
                    case "ConnsAsyncKeepAlive": result.put(ApacheMetrics.CONNECTIONS_ASYNC_KEEPALIVE, value); break;
                    case "ConnsAsyncClosing": result.put(ApacheMetrics.CONNECTIONS_ASYNC_CLOSING, value); break;
                    case "Scoreboard": parseScoreboard(result, value); break;
                    default: LOGGER.warn("ApacheStatusParser: found unhandled status line: '" + line + "'.");
                }
            }
        }
        return result;
    }
1232508
public synchronized InstanceStatus setStatus(InstanceStatus status) {
        if (this.status != status) {
            InstanceStatus prev = this.status;
            this.status = status;
            setIsDirty();
            return prev;
        }
        return null;
    }
891781
def status(name, init_system, verbose):
    
    try:
        status = Serv(init_system, verbose=verbose).status(name)
    except ServError as ex:
        sys.exit(ex)
    click.echo(json.dumps(status, indent=4, sort_keys=True))
857809
private boolean checkVmIsOnline() {

		String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
		Server server = this.novaApi.getServerApiForZone( zoneName ).get(this.machineId);
		return Status.ACTIVE.equals(server.getStatus());
	}
1077630
public void noteOpenConnection(ServerStats serverStats) {
        if (serverStats == null) {
            return;
        }
        try {
            serverStats.incrementActiveRequestsCount();
        } catch (Exception ex) {
            logger.error("Error noting stats for client {}", clientName, ex);
        }            
    }
225485
protected function checkResqueStatus($status) {
		switch($status) {
			case "Complete":
				return true;
			case "Failed":
			case "Invalid":
				$this->log("{$this->Title} failed with task status $status");
				$this->markFailed();
				return false;
			case "Queued":
			case "Running":
			default:
				// For running or queued tasks ensure that we have not exceeded
				// a reasonable time-elapsed to consider this job inactive
				if($this->isTimedOut()) {
					$this->log("{$this->Title} took longer than {$this->MaxDuration} seconds to run and has timed out");
					$this->markFailed();
					return false;
				} else {
					// While still running report no error, waiting for resque job to eventually finish
					// some time in the future
					$this->log("{$this->Title} is still in progress");
					return false;
				}
		}
	}
1124754
def _CheckStatusAnalysisProcess(self, pid):
    
    # TODO: Refactor this method, simplify and separate concerns (monitoring
    # vs management).
    self._RaiseIfNotRegistered(pid)

    if pid in self._completed_analysis_processes:
      status_indicator = definitions.STATUS_INDICATOR_COMPLETED
      process_status = {
          'processing_status': status_indicator}
      used_memory = 0

    else:
      process = self._processes_per_pid[pid]

      process_status = self._QueryProcessStatus(process)
      if process_status is None:
        process_is_alive = False
      else:
        process_is_alive = True

      process_information = self._process_information_per_pid[pid]
      used_memory = process_information.GetUsedMemory() or 0

      if self._worker_memory_limit and used_memory > self._worker_memory_limit:
        logger.warning((
            'Process: {0:s} (PID: {1:d}) killed because it exceeded the '
            'memory limit: {2:d}.').format(
                process.name, pid, self._worker_memory_limit))
        self._KillProcess(pid)

      if isinstance(process_status, dict):
        self._rpc_errors_per_pid[pid] = 0
        status_indicator = process_status.get('processing_status', None)

        if status_indicator == definitions.STATUS_INDICATOR_COMPLETED:
          self._completed_analysis_processes.add(pid)

      else:
        rpc_errors = self._rpc_errors_per_pid.get(pid, 0) + 1
        self._rpc_errors_per_pid[pid] = rpc_errors

        if rpc_errors > self._MAXIMUM_RPC_ERRORS:
          process_is_alive = False

        if process_is_alive:
          rpc_port = process.rpc_port.value
          logger.warning((
              'Unable to retrieve process: {0:s} (PID: {1:d}) status via '
              'RPC socket: http://localhost:{2:d}').format(
                  process.name, pid, rpc_port))

          processing_status_string = 'RPC error'
          status_indicator = definitions.STATUS_INDICATOR_RUNNING
        else:
          processing_status_string = 'killed'
          status_indicator = definitions.STATUS_INDICATOR_KILLED

        process_status = {
            'processing_status': processing_status_string}

    self._UpdateProcessingStatus(pid, process_status, used_memory)

    if status_indicator in definitions.ERROR_STATUS_INDICATORS:
      logger.error((
          'Process {0:s} (PID: {1:d}) is not functioning correctly. '
          'Status code: {2!s}.').format(
              process.name, pid, status_indicator))

      self._TerminateProcessByPid(pid)
297966
public void prepareStatus() {
        globalLineCounter = new AtomicLong(0);
        time = new AtomicLong(System.currentTimeMillis());
        startTime = System.currentTimeMillis();
        lastCount = 0;

        // Status thread regularly reports on what is happening
        Thread statusThread = new Thread() {
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        System.out.println("Status thread interrupted");
                    }

                    long thisTime = System.currentTimeMillis();
                    long currentCount = globalLineCounter.get();

                    if (thisTime - time.get() > 1000) {
                        long oldTime = time.get();
                        time.set(thisTime);
                        double avgRate = 1000.0 * currentCount / (thisTime - startTime);
                        double instRate = 1000.0 * (currentCount - lastCount) / (thisTime - oldTime);
                        lastCount = currentCount;
                        System.out.println(currentCount + " AvgRage:" + ((int) avgRate) + " lines/sec  instRate:"
                                + ((int) instRate) + " lines/sec  Unassigned Work: "
                                + remainingBlocks.get() + " blocks");
                    }
                }
            }
        };
        statusThread.start();
    }
323072
@com.fasterxml.jackson.annotation.JsonProperty("status")
    public void setStatus(String status) {
        this.status = status;
    }
1283531
private void checkState() {
        if (startWith == null && lastResult == null) {
            final String msg = "Please call startWith(uri) first.";
            LOG.error(msg);
            throw new IllegalStateException(msg);
        }
    }
1067896
public void setStatusInfos(java.util.Collection<DBInstanceStatusInfo> statusInfos) {
        if (statusInfos == null) {
            this.statusInfos = null;
            return;
        }

        this.statusInfos = new java.util.ArrayList<DBInstanceStatusInfo>(statusInfos);
    }