# Copyright (c) Cloud Linux Software, Inc # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENCE.TXT import json import base64 import os import time import platform import zlib from . import kcare from . import platform_utils from . import http_utils from . import utils from . import constants from . import auth if False: # pragma: no cover from typing import Dict, Any # noqa: F401 def server_info(reason, now=None): data = dict() # type: Dict[str, Any] data['ts'] = int(now or time.time()) data['reason'] = reason data['machine'] = platform.machine() data['processor'] = platform.processor() data['release'] = platform.release() data['system'] = platform.system() data['version'] = platform.version() distro = platform_utils.get_distro() data['distro'] = distro[0] data['distro_version'] = distro[1] data['euname'] = kcare.kcare_uname() data['kcare_version'] = utils.strip_version_timestamp(constants.VERSION) data['last_stop'] = kcare.get_last_stop() data['node'] = platform_utils.get_hostname() data['uptime'] = platform_utils.get_uptime() data['virt'] = platform_utils.get_virt() data['proxy'] = http_utils.proxy_is_used() description = kcare.parse_patch_description(kcare.loaded_patch_description()) data['ltimestamp'] = description['last-update'] data['patch_level'] = description['patch-level'] data['patch_type'] = description['patch-type'] data['kmod'] = kcare.get_current_kmod_version() or '' data['crashreporter_ts'] = kcare.crashreporter_latest_event_timestamp() data['kdump_status'] = kcare.kdump_status() try: data['kdump_ts'] = kcare.kdumps_latest_event_timestamp() except Exception: # Not critical data pass server_id = auth.get_serverid() if server_id: data['server_id'] = server_id state = kcare.get_state() if state is not None: data['state'] = state return data def server_lib_info(reason, patch_level, now=None): data = dict() # type: Dict[str, Any] data['ts'] = int(now or time.time()) data['reason'] = reason data['patch_level'] = patch_level distro = platform_utils.get_distro() data['distro'] = distro[0] data['distro_version'] = distro[1] data['machine'] = platform.machine() data['kcare_version'] = utils.strip_version_timestamp(constants.VERSION) data['node'] = platform_utils.get_hostname() data['uptime'] = platform_utils.get_uptime() data['virt'] = platform_utils.get_virt() stop_ts = 0.0 if os.path.exists('/var/lib/libcare/stop'): stop_ts = os.path.getctime('/var/lib/libcare/stop') data['stop_ts'] = stop_ts return data def based_server_info(reason): return utils.nstr(base64.b16encode(utils.bstr(str(server_info(reason))))) def encode_server_lib_info(info): data = json.dumps(info, ensure_ascii=False, separators=(',', ':')) return utils.nstr(base64.urlsafe_b64encode(zlib.compress(utils.bstr(data, 'utf-8'))))
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__init__.py | File | 69.58 KB | 0644 |
|
__init__.pyc | File | 64.25 KB | 0644 |
|
__init__.pyo | File | 64.25 KB | 0644 |
|
__main__.py | File | 829 B | 0644 |
|
__main__.pyc | File | 926 B | 0644 |
|
__main__.pyo | File | 926 B | 0644 |
|
auth.py | File | 11.87 KB | 0644 |
|
auth.pyc | File | 11.82 KB | 0644 |
|
auth.pyo | File | 11.82 KB | 0644 |
|
config.py | File | 1.71 KB | 0644 |
|
config.pyc | File | 2.01 KB | 0644 |
|
config.pyo | File | 2.01 KB | 0644 |
|
config_handlers.py | File | 7.26 KB | 0644 |
|
config_handlers.pyc | File | 8.47 KB | 0644 |
|
config_handlers.pyo | File | 8.47 KB | 0644 |
|
constants.py | File | 1.27 KB | 0644 |
|
constants.pyc | File | 1.34 KB | 0644 |
|
constants.pyo | File | 1.34 KB | 0644 |
|
errors.py | File | 1.29 KB | 0644 |
|
errors.pyc | File | 2.94 KB | 0644 |
|
errors.pyo | File | 2.94 KB | 0644 |
|
fetch.py | File | 4.88 KB | 0644 |
|
fetch.pyc | File | 5.47 KB | 0644 |
|
fetch.pyo | File | 5.47 KB | 0644 |
|
http_utils.py | File | 4.06 KB | 0644 |
|
http_utils.pyc | File | 4.16 KB | 0644 |
|
http_utils.pyo | File | 4.16 KB | 0644 |
|
kcare.py | File | 8.56 KB | 0644 |
|
kcare.pyc | File | 11.09 KB | 0644 |
|
kcare.pyo | File | 11.09 KB | 0644 |
|
libcare.py | File | 17.24 KB | 0644 |
|
libcare.pyc | File | 19.16 KB | 0644 |
|
libcare.pyo | File | 19.16 KB | 0644 |
|
log_utils.py | File | 2.82 KB | 0644 |
|
log_utils.pyc | File | 3.75 KB | 0644 |
|
log_utils.pyo | File | 3.75 KB | 0644 |
|
platform_utils.py | File | 3.4 KB | 0644 |
|
platform_utils.pyc | File | 4.56 KB | 0644 |
|
platform_utils.pyo | File | 4.56 KB | 0644 |
|
process_utils.py | File | 3.81 KB | 0644 |
|
process_utils.pyc | File | 3.67 KB | 0644 |
|
process_utils.pyo | File | 3.67 KB | 0644 |
|
py23.py | File | 1.74 KB | 0644 |
|
py23.pyc | File | 2.15 KB | 0644 |
|
py23.pyo | File | 2.15 KB | 0644 |
|
selinux.py | File | 1.68 KB | 0644 |
|
selinux.pyc | File | 2.43 KB | 0644 |
|
selinux.pyo | File | 2.43 KB | 0644 |
|
server_info.py | File | 2.99 KB | 0644 |
|
server_info.pyc | File | 3.48 KB | 0644 |
|
server_info.pyo | File | 3.48 KB | 0644 |
|
update_utils.py | File | 923 B | 0644 |
|
update_utils.pyc | File | 1.18 KB | 0644 |
|
update_utils.pyo | File | 1.18 KB | 0644 |
|
utils.py | File | 7.07 KB | 0644 |
|
utils.pyc | File | 7.8 KB | 0644 |
|
utils.pyo | File | 7.8 KB | 0644 |
|