dbfdg 3 wh @sddlZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd d Z dd d ZdddZddZdS)N)kcare)platform_utils) http_utils)utils) constants)serveridFc Cst}t|ptj|d<||d<tj|d<tj|d<tj|d<tj|d<tj|d<t j }|d|d <|d |d <t j |d <t jtj|d <t j|d<t j|d<t j|d<t j|d<tj|d<t jt j}|d|d<|d|d<|d|d<t jpd|d<t j|d<t j|d<yt j|d<Wntk rXYnXtj}|rp||d<t j }|dk r||d<|rt j!|d <|S)!Ntsreasonmachine processorreleasesystemversionrdistrordistro_versionZeuname kcare_versionZ last_stopnodeuptimevirtproxyz last-updateZ ltimestampz patch-level patch_levelz patch-typeZ patch_typekmodZcrashreporter_ts kdump_statusZkdump_ts server_idstateZ secure_boot)"dictinttimeplatformr r r rrr get_distror kcare_unamerstrip_version_timestamprVERSIONZ get_last_stop get_hostname get_uptimeget_virtr proxy_is_usedparse_patch_descriptionZloaded_patch_descriptionZget_current_kmod_versionZ$crashreporter_latest_event_timestamprZkdumps_latest_event_timestamp Exceptionr get_serverid get_statesecure_boot_info)r nowr-datar descriptionrrr11/usr/libexec/kcare/python/kcarectl/server_info.py server_infosL                    r3cCst}t|ptj|d<||d<||d<tj}|d|d<|d|d<tj|d<tjt j |d <tj |d <tj |d <tj |d <d }tjjdrtjjd}||d<|S)Nr r rrrrrr rrrrgz/var/lib/libcare/stopstop_ts)rrrrr!r r rr#rr$r%r&r'ospathexistsgetctime)r rr.r/rr4r1r1r2server_lib_infoIs"        r9cCs"tjtjtjtt||dS)N)r-)rnstrbase64 b16encodebstrstrr3)r r-r1r1r2based_server_infoasr?cCs.tj|ddd}tjtjtjtj|dS)NF,:) ensure_ascii separatorszutf-8)r@rA) jsondumpsrr:r;urlsafe_b64encodezlibcompressr=)infor/r1r1r2encode_server_lib_infoesrJ)NF)N)F)rDr;r5rr rGrrrrrrrr3r9r?rJr1r1r1r2s       2