Verify system status.
480529
def verify_system_status(self):
        """"""
        if not sys.platform.startswith('linux'):
            raise InstallError('Supported platform is Linux only.')

        if self.python.is_system_python():
            if self.python.is_python_binding_installed():
                message = '''
RPM Python binding already installed on system Python.
Nothing to do.
'''
                Log.info(message)
                raise InstallSkipError(message)
            elif self.sys_installed:
                pass
            else:
                message = '''
RPM Python binding on system Python should be installed manually.
Install the proper RPM package of python{,2,3}-rpm,
or set a environment variable RPM_PY_SYS=true
'''
                raise InstallError(message)

        if self.rpm.is_system_rpm():
            self.verify_package_status()
406956
def system_status():  # noqa: E501
    
    if(not hasAccess()):
        return redirectUnauthorized()

    body = State.config.serialize(["driver", "log", "log-file", "log-colorize"])
    body.update({'debug': State.options.debug, 'sensitive': State.options.sensitive})
    return Response(status=200, body=body)
666300
def status(self):
        """"""
        if self.pidfile is None:
            raise DaemonError('Cannot get status of daemon without PID file')

        pid = self._read_pidfile()
        if pid is None:
            self._emit_message(
                '{prog} -- not running\n'.format(prog=self.prog))
            sys.exit(1)

        proc = psutil.Process(pid)
        # Default data
        data = {
            'prog': self.prog,
            'pid': pid,
            'status': proc.status(),
            'uptime': '0m',
            'cpu': 0.0,
            'memory': 0.0,
        }

        # Add up all the CPU and memory usage of all the
        # processes in the process group
        pgid = os.getpgid(pid)
        for gproc in psutil.process_iter():
            try:
                if os.getpgid(gproc.pid) == pgid and gproc.pid != 0:
                    data['cpu'] += gproc.cpu_percent(interval=0.1)
                    data['memory'] += gproc.memory_percent()
            except (psutil.Error, OSError):
                continue

        # Calculate the uptime and format it in a human-readable but
        # also machine-parsable format
        try:
            uptime_mins = int(round((time.time() - proc.create_time()) / 60))
            uptime_hours, uptime_mins = divmod(uptime_mins, 60)
            data['uptime'] = str(uptime_mins) + 'm'
            if uptime_hours:
                uptime_days, uptime_hours = divmod(uptime_hours, 24)
                data['uptime'] = str(uptime_hours) + 'h ' + data['uptime']
                if uptime_days:
                    data['uptime'] = str(uptime_days) + 'd ' + data['uptime']
        except psutil.Error:
            pass

        template = ('{prog} -- pid: {pid}, status: {status}, '
                    'uptime: {uptime}, %cpu: {cpu:.1f}, %mem: {memory:.1f}\n')
        self._emit_message(template.format(**data))
901299
async def sysinfo(dev: Device):
    """"""
    click.echo(await dev.get_system_info())
    click.echo(await dev.get_interface_information())
1089959
def _perform_system_check(self):
        
        if Global.CONFIG_MANAGER.tracing_mode:
            Global.LOGGER.debug("performing a system check")

        now = datetime.datetime.now()
        sent = Global.MESSAGE_DISPATCHER.dispatched
        received = self.fetched
        queue_length = sent - received
        message_sleep_interval = Global.CONFIG_MANAGER.message_fetcher_sleep_interval

        if Global.CONFIG_MANAGER.show_stats:
            if (now - self.last_stats_check_date).total_seconds() > Global.CONFIG_MANAGER.stats_timeout:
                self.last_stats_check_date = now
                stats_string = f"showing stats\n--- [STATS] ---\nMessage Sent: {sent}\nMessage Received: {received}\nMessage Sleep Interval = {message_sleep_interval}\nQueue length = {queue_length}\n--- [ END ] ---"
                Global.LOGGER.info(stats_string)

        # if we are accumulating messages, or we have processed at least 5000 messages
        # since last check, we need to speed up the process
        messages_limit_reached = sent - self.last_queue_check_count > Global.CONFIG_MANAGER.messages_dispatched_for_system_check
        queue_limit_reached = queue_length > Global.CONFIG_MANAGER.queue_length_for_system_check
        time_limit_since_last_check_is_over = (now - self.last_queue_check_date).total_seconds() > Global.CONFIG_MANAGER.seconds_between_queue_check

        if not Global.CONFIG_MANAGER.fixed_message_fetcher_interval:
            if (messages_limit_reached) or (queue_limit_reached and time_limit_since_last_check_is_over):
                cause = "messages limit reached" if messages_limit_reached else "queue limit reached"
                Global.LOGGER.debug(f"triggering the throttle function due to {cause}")
                self._adapt_sleep_interval(sent, received, queue_length, now)
1113644
def do_status(self, _):
        '''  '''
        server_status = self.server.is_server_running()
        if server_status == 'yes':
            print 'Server: ' + colorize('currently online', 'green')
        elif server_status == 'no':
            print 'Server: ' + colorize('currently offline', 'red')
        elif server_status == 'maybe':
            print 'Server: ' + colorize('status unknown', 'yellow')
        elif server_status == 'blocked':
            print 'Server: ' + colorize('blocked', 'red')
891751
def status(self):
        """"""
        self._check_valid()
        if self._ret_val == swiglpk.GLP_ENOPFS:
            return 'No primal feasible solution'
        elif self._ret_val == swiglpk.GLP_ENODFS:
            return 'No dual feasible solution'
        return str(swiglpk.glp_get_status(self._problem._p))
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();
        }
    }
1099755
def status():
    '''
    
    '''
    ret = {}
    apcaccess = _check_apcaccess()
    res = __salt__['cmd.run_all'](apcaccess)
    retcode = res['retcode']
    if retcode != 0:
        ret['Error'] = 'Something with wrong executing apcaccess, is apcupsd running?'
        return ret

    for line in res['stdout'].splitlines():
        line = line.split(':')
        ret[line[0].strip()] = line[1].strip()

    return ret
760866
def check_status_logfile(self, checker_func):
        """"""
        self.status = checker_func(self.logfile)
        return self.status
1204374
def normal_check(name, status, device_type):
    """"""
    status_string = NORMAL_STATE.get(int(status), "unknown")

    if status_string == "ok":
        return ok, "{} '{}': {}".format(device_type, name, status_string)

    elif status_string == "unknown":
        return unknown, "{} '{}': {}".format(device_type, name, status_string)

    return critical, "{} '{}': {}".format(device_type, name, status_string)
1010425
def on_status(self, status):
        """"""
        self.out.write(json.dumps(status))
        self.out.write(os.linesep)

        self.received += 1
        return not self.terminate
1291425
def status(name, sig=None):
    '''
    
    '''
    cmd = 'svstat {0}'.format(_service_path(name))
    out = __salt__['cmd.run_stdout'](cmd, python_shell=False)
    try:
        pid = re.search(r'\(pid (\d+)\)', out).group(1)
    except AttributeError:
        pid = ''
    return pid
1338579
def build_system_error(cls, errors=None):
        """"""
        errors = [errors] if not isinstance(errors, list) else errors
        return cls(Status.SYSTEM_ERROR, errors)
401418
def system_info(url, auth, verify_ssl):
    
    sysinfo_response = requests.get(url + '/info', headers=X_REQ_BY, auth=auth, verify=verify_ssl)
    sysinfo_response.raise_for_status()
    return sysinfo_response.json()
1068456
def verify_state(self):
        
        if self.state == SESSION_STATE.CONNECTING:
            self.state = SESSION_STATE.OPEN

            self.conn.connectionMade(self.conn_info)
242418
def main(argv=sys.argv, stream=sys.stderr):
    """"""
    args = parse_args(argv)
    suite = build_suite(args)
    runner = unittest.TextTestRunner(verbosity=args.verbose, stream=stream)
    result = runner.run(suite)

    return get_status(result)