Famously interesting uptime
325142
public function getUpTime()
    {

        // Time?
        if (!empty($this->settings['timer'])) {
            $t = new Timer('Uptime');
        }

        // Get contents
        $contents = Common::getContents('/proc/uptime', false);

        // eh?
        if ($contents === false) {
            Errors::add('Linfo Core', '/proc/uptime does not exist.');

            return 'Unknown';
        }

        // Seconds
        list($seconds) = explode(' ', $contents, 1);

        // Get it textual, as in days/minutes/hours/etc
        $uptime = Common::secondsConvert(ceil($seconds));

        // Now find out when the system was booted
        $contents = Common::getContents('/proc/stat', false);

        // Ugh
        if ($contents === false) {
            return $uptime;
        } // Settle for just uptime

        // Get date of boot
        if (preg_match('/^btime (\d+)$/m', $contents, $boot) != 1) {
            return $uptime;
        }

        // Okay?
        list(, $boot) = $boot;

        return array(
            'text' => $uptime,
            'bootedTimestamp' => $boot,
        );
    }
1294462
def enable_service_freshness_checks(self):
        
        if not self.my_conf.check_service_freshness:
            self.my_conf.modified_attributes |= \
                DICT_MODATTR["MODATTR_FRESHNESS_CHECKS_ENABLED"].value
            self.my_conf.check_service_freshness = True
            self.my_conf.explode_global_conf()
            self.daemon.update_program_status()
167455
def device_time_str(self, resp, indent="  "):
        
        time = resp.time
        uptime = resp.uptime
        downtime = resp.downtime
        time_s = datetime.datetime.utcfromtimestamp(time/1000000000) if time != None else None
        uptime_s = round(nanosec_to_hours(uptime), 2) if uptime != None else None
        downtime_s = round(nanosec_to_hours(downtime), 2) if downtime != None else None
        s = "Current Time: {} ({} UTC)\n".format(time, time_s)
        s += indent + "Uptime (ns): {} ({} hours)\n".format(uptime, uptime_s)
        s += indent + "Last Downtime Duration +/-5s (ns): {} ({} hours)\n".format(downtime, downtime_s)
        return s
656498
def refresh!
      _require_connection!
      max_wait ||= 1.5 # Use ||= due to the retry
      @services = Hash[@o_dev.subnodes.map {|p_srv|
          p_srv = [@o_dev.path, p_srv].join '/'
          o_srv = BLUEZ.object(p_srv)
          o_srv.introspect
          srv   = o_srv.GetAll(I_GATT_SERVICE).first
          char  = Hash[o_srv.subnodes.map {|char|
              p_char = [o_srv.path, char].join '/'
              o_char = BLUEZ.object(p_char)
              o_char.introspect
              uuid  = o_char[I_GATT_CHARACTERISTIC]['UUID' ].downcase
              flags = o_char[I_GATT_CHARACTERISTIC]['Flags']
              [ uuid, Characteristic.new({ :uuid => uuid, :flags => flags, :obj => o_char }) ]
            }]
          uuid = srv['UUID'].downcase
          [ uuid, { :uuid            => uuid,
              :primary         => srv['Primary'],
              :characteristics => char } ]
        }]
      self
    rescue DBus::Error => e
      case e.name
      when E_UNKNOWN_OBJECT
        raise StalledObject
      when E_INVALID_ARGS
        # That's probably because all the bluez information
        # haven't been collected yet on dbus for GattServices
        if max_wait > 0
          sleep(0.25) ; max_wait -= 0.25 ; retry
        end
        raise NotReady

      else raise ScriptError
      end
    end
735252
private function _uptime()
    {
        if (CommonFunctions::executeProgram('uptime', '', $buf)) {
            if (preg_match("/up (\d+) day[s]?,\s*(\d+):(\d+),/", $buf, $ar_buf)) {
                $min = $ar_buf[3];
                $hours = $ar_buf[2];
                $days = $ar_buf[1];
                $this->sys->setUptime($days * 86400 + $hours * 3600 + $min * 60);
            } elseif (preg_match("/up (\d+):(\d+),/", $buf, $ar_buf)) {
                $min = $ar_buf[2];
                $hours = $ar_buf[1];
                $this->sys->setUptime($hours * 3600 + $min * 60);
            }
        }
    }
124477
function updateCpu (cpu, next) {
  if (cpu !== null) {
    getRealUptime(function (err, uptime) {
      if (err) return next(err)
      cpu.uptime = uptime
      next(null, cpu)
    })
    return
  }

  parallel([
    getClockAndPageSize,
    getRealUptime
  ], function (err, data) {
    if (err) return next(err)

    cpu = {
      clockTick: data[0].clockTick,
      pageSize: data[0].pageSize,
      uptime: data[1]
    }

    next(null, cpu)
  })
}
1126927
def has_reset(self):
        """"""
        currentTime = self._read_as_int(Addr.Uptime, 4)
        if currentTime <= self._ticks:
            self._ticks = currentTime
            return True
        self._ticks = currentTime
        return False
268669
protected function uptime()
    {
        $linfo = $this->linfo->getParser();

        $uptime = $booted_at = null;

        $systemUptime = $this->ifExists($linfo->getUpTime());

        if (! empty($systemUptime['text'])) {
            $uptime = $systemUptime['text'];
        }

        if (! empty($systemUptime['bootedTimestamp'])) {
            $booted_at = date('Y-m-d H:i:s', $systemUptime['bootedTimestamp']);
        }

        $this->results['server']['uptime'] = compact(
            'uptime', 'booted_at'
        );

        return $this;
    }
1069627
def up_by_arrival(*filters, local_dir=".", remote_dir=DEFAULT_REMOTE_DIR):
    """"""
    local_monitor = watch_local_files(*filters, local_dir=local_dir)
    _, file_set = next(local_monitor)
    _notify_sync_ready(len(file_set), local_dir, remote_dir)
    for new_arrivals, file_set in local_monitor:
        yield Direction.up, new_arrivals  # where new_arrivals is possibly empty
        if new_arrivals:
            _notify_sync(Direction.up, new_arrivals)
            up_by_files(new_arrivals, remote_dir)
            _notify_sync_ready(len(file_set), local_dir, remote_dir)
1301601
function setup(done) {
    crontab.load(function(err, ct) {
      if (err) return done(err);
      clean(ct);
      load(ct);
      ct.save(done);
    });
  }
1282632
public void doEvents() {
		while (!isInterrupted()) {
			Iterator<Map.Entry<Timer, Runnable>> it = timerMap.entrySet().iterator();
			if (it.hasNext()) {
				long timeout = it.next().getKey().uptime - System.currentTimeMillis();
				doEvents(timeout > 0 ? timeout : 0);
			} else {
				doEvents(-1);
			}
		}
	}
1021608
def uptime():
    """"""
    from datetime import timedelta

    with open('/proc/uptime', 'r') as f:
        uptime_seconds = float(f.readline().split()[0])
        uptime_string = str(timedelta(seconds=uptime_seconds))

    bob.says(uptime_string)
739706
def UpdateProtoResources(self, status):
    """"""
    user_cpu = status.cpu_time_used.user_cpu_time
    system_cpu = status.cpu_time_used.system_cpu_time
    self.context.client_resources.cpu_usage.user_cpu_time += user_cpu
    self.context.client_resources.cpu_usage.system_cpu_time += system_cpu

    user_cpu_total = self.context.client_resources.cpu_usage.user_cpu_time
    system_cpu_total = self.context.client_resources.cpu_usage.system_cpu_time

    self.context.network_bytes_sent += status.network_bytes_sent

    if self.runner_args.cpu_limit:
      if self.runner_args.cpu_limit < (user_cpu_total + system_cpu_total):
        # We have exceeded our limit, stop this flow.
        raise FlowRunnerError("CPU limit exceeded.")

    if self.runner_args.network_bytes_limit:
      if (self.runner_args.network_bytes_limit <
          self.context.network_bytes_sent):
        # We have exceeded our byte limit, stop this flow.
        raise FlowRunnerError("Network bytes limit exceeded.")
57257
def service_up(s_name, **connection_args):
    '''
    
    '''
    service = _service_get(s_name, **connection_args)
    return service is not None and service.get_svrstate() == 'UP'
93399
def health():
    """"""
    up_time = time.time() - START_TIME
    response = dict(service=__service_id__,
                    uptime='{:.2f}s'.format(up_time))
    return response, HTTPStatus.OK
613938
def enable_performance_data(self):
        
        if not self.my_conf.process_performance_data:
            self.my_conf.modified_attributes |= \
                DICT_MODATTR["MODATTR_PERFORMANCE_DATA_ENABLED"].value
            self.my_conf.process_performance_data = True
            self.my_conf.explode_global_conf()
            self.daemon.update_program_status()
531933
def on_up(self, host):
        
        if self.is_shutdown:
            return

        log.debug("Waiting to acquire lock for handling up status of node %s", host)
        with host.lock:
            if host._currently_handling_node_up:
                log.debug("Another thread is already handling up status of node %s", host)
                return

            if host.is_up:
                log.debug("Host %s was already marked up", host)
                return

            host._currently_handling_node_up = True
        log.debug("Starting to handle up status of node %s", host)

        have_future = False
        futures = set()
        try:
            log.info("Host %s may be up; will prepare queries and open connection pool", host)

            reconnector = host.get_and_set_reconnection_handler(None)
            if reconnector:
                log.debug("Now that host %s is up, cancelling the reconnection handler", host)
                reconnector.cancel()

            if self.profile_manager.distance(host) != HostDistance.IGNORED:
                self._prepare_all_queries(host)
                log.debug("Done preparing all queries for host %s, ", host)

            for session in tuple(self.sessions):
                session.remove_pool(host)

            log.debug("Signalling to load balancing policies that host %s is up", host)
            self.profile_manager.on_up(host)

            log.debug("Signalling to control connection that host %s is up", host)
            self.control_connection.on_up(host)

            log.debug("Attempting to open new connection pools for host %s", host)
            futures_lock = Lock()
            futures_results = []
            callback = partial(self._on_up_future_completed, host, futures, futures_results, futures_lock)
            for session in tuple(self.sessions):
                future = session.add_or_renew_pool(host, is_host_addition=False)
                if future is not None:
                    have_future = True
                    future.add_done_callback(callback)
                    futures.add(future)
        except Exception:
            log.exception("Unexpected failure handling node %s being marked up:", host)
            for future in futures:
                future.cancel()

            self._cleanup_failed_on_up_handling(host)

            with host.lock:
                host._currently_handling_node_up = False
            raise
        else:
            if not have_future:
                with host.lock:
                    host.set_up()
                    host._currently_handling_node_up = False

        # for testing purposes
        return futures