HEX
Server: Apache
System: Linux br384.hostgator.com.br 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User: regi8665 (2159)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //usr/libexec/kcare/python/kcarectl/platform_utils.pyo
�
��ic@s~ddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
er�ddlmZmZmZmZndZdZd�Ze
jd��Zd	�Zed
�ZdZidd
6dd6Zdd�Zd�Zd�Zd�Z e
jd��Z!e
jd��Z"e
jd��Z#d�Z$d�Z%d�Z&d�Z'e
j(de
j)�d��Z*e
j(de
j)�d��Z+e
je
j(de
j)�d���Z,e
j(de
j)d d!�d"��Z-e
j(de
j)d d!�d#��Z.e
j(de
j)�d$��Z/e
j(de
j)d d'�d%��Z0d&�Z1dS((i����Ni(tconfigt	constantst	log_utilst
process_utilstselinuxtutils(tAnytDicttOptionaltTuples/usr/libexec/kcare/virt-whats/proccCs=tjd dkrtj�Sddl}|jdt�SdS(Niiii����tfull_distribution_name(ii(tsystversion_infotplatformtlinux_distributiontdistrotFalse(R((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pyt
get_distros
cCstj�dS(Ni(R
tuname(((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_system_unamescCsdtjdtjdfS(Ns%s.%sii(RR(((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_python_version$sc	Cs�it�d6tjd6}tj�r�tjddddttj	��gdt
�\}}}|sx|j�d}n
d	|}||d
<n|r�tj
|�St|�}d}x&|D]}|d|||f7}q�W|j�S(
Ntpython_versiont
agent_versiontpss-Zs--no-headerss--pidtcatch_stdoutis	error: %stselinux_contextts%s: %s
(RRtVERSIONRtis_selinux_enabledRtrun_commandtstrtostgetpidtTruetsplittjsontdumpstsortedtrstrip(	tis_jsontinfotrctstdouttstderrRt	info_keystinfo_strtinfo_key((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytapp_info(s 

9



s/sys/firmware/efi/efivarss$8be4df61-93ca-11d2-aa0d-00e098032b8ctglobals$605dab50-e046-4300-abb6-3dd810dd8b23tshimicCs^tjjtd||f�}tjj|�s5dSt|d��}|j|�SWdQXdS(Ns%s-%strb(RtpathtjointEFIVARS_PATHtexiststNonetopentread(tnametvendort	max_bytestvar_pathtvar((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pyt_read_uefi_varIs
cCsCy+tdtd�}|r*|ddkSWntk
r>nXtS(Nt
SecureBootR0i����s(R?tEFI_VENDORSt	ExceptionR(tsecure_boot_var((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytis_secure_bootRs
cCsay#t||�}|dkr"dSWn%tk
rJ}t|�j�}nXtjtj|��S(N(	R?R7RBRtencodeRtnstrtbase64turlsafe_b64encode(R:R;tvalue_byteste((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pyt_get_uefi_var_encoded]sc	Cs�tjtjjtd��}|rCt|�dkrC|d }ni|d6tjjtjjt	��d6}|ds}|Sy�t
d�dD��|d<tgtjt	�D]5}|j
td�r�|d	ttd�d
!^q��}i|d6|d<tdd
ddg�}xS|D]K}|dksH|j
d�r||krt|td�|d|<qqWWn tk
r�}tj|�nX|S(Ntcmdlineithas_eficss(|]}|t|td�fVqdS(R0N(RKRA(t.0R>((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pys	<genexpr>rsR@t	SetupModeR0R1iitvarst	MokListRTt
MokListXRTtMokListTrustedRTtSbatLevelRTt	HSIStatustMokIgnoreDBtRT(s
SecureBootRO(RURV(Rttry_to_readRR3R4tPROC_DIRtlenR6tdirnameR5tdictR%tlistdirtendswithRAtsetRKRBRtlogwarn(RLR(R>t	shim_varstshim_exclude_varsterr((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytsecure_boot_infohs$
,
N
'&cCs�tjrqy3tjtj�ddddtj�dd}Wq}tjk
rm}tj|�t	j
�}q}Xnt	j
�}|S(Nii(RtREPORT_FQDNtsockettgetaddrinfotgethostnametAI_CANONNAMEtgaierrorRtlogerrorR
tnode(thostnametge((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_hostname�s	3
cCsvtjjtd�}tjj|�rrt|d�}|j�}ttt	|j
�d���}|j�|SdS(Ntuptimetris-1(RR3R4RYtisfileR8treadlineRtinttfloatR"tclose(tuptime_filetftlinetresult((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pyt
get_uptime�s"
cCs,tjjt�r(tjtg�j�SdS(Nsno-virt-what(RR3RrtVIRTWHATRtcheck_outputtstrip(((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_virt�scCstjjd�S(Ns/usr/local/cpanel/cpanel(RR3Rr(((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pyt	is_cpanel�scCsGtjjtjjtdd��oFtjjtjjtdd��S(Ntvztveinfotversion(RR3R6R4RY(((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytinside_vz_container�scCs(dttjjtdd��j�kS(Ns/lxc/t1tcgroup(R8RR3R4RYR9(((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytinside_lxc_container�scCstjjd�S(Ns/.dockerenv(RR3Rr(((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytinside_docker_container�stloggercCsetjtjjtd��}|s(dS|jdd�\}}}}t|�t|�t|�fS(Ntloadavgt i(	RRXRR3R4RYR7R"Ru(R�tm1tm5tm15t_((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_load_average�s
csXtjtjjtd��}|s(dSd	�t�fd�d�|j�D�D��S(
s!Returns dict of memory info in kBtmeminfotMemTotaltMemFreet	SwapTotaltSwapFreec3s3|])\}}|�kr|t|�fVqdS(N(Rt(RNtktv(t
filter_params(s4/usr/libexec/kcare/python/kcarectl/platform_utils.pys	<genexpr>�scss%|]}tjd|�d VqdS(s[\s:]+iN(treR"(RNRy((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pys	<genexpr>�sN(R�R�R�R�(	RRXRR3R4RYR7R\t
splitlines(R�((R�s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_mem_info�s
cCsDtjtjjtd��}|s(dSg|jd�D](}|r8td�|j	�D��^q8}i	t
|�d6t
td�|D���d6|djd�d6t
|djd	d��d	6|djd
�d6t
|djdd��d
6t
|djdd��d6|djd�d6|djdd�j�d6S(Ntcpuinfos

css!|]}tjd|�VqdS(s\s*:\s*N(R�R"(RNRy((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pys	<genexpr>�st
logical_corescss-|]#}|jd�|jd�fVqdS(sphysical idscore idN(tget(RNtcpu((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pys	<genexpr>�stphysical_coresit	vendor_idtmodels
model namet
model_names
cpu familyt
cpu_familytsteppingt	microcodetflagsR(RRXRR3R4RYR7R"R\R�RZR_R�Rt(R�t	cpu_linestcpus((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_cpu_info�s (
tdefault_returnicCs2tgtjt�D]}|j�r|^q�S(N(RZRR]RYtisdigit(td((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_process_count�scCs8tjtjjtd��}t|p*dj�d�S(Nssys/fs/file-nrt0i(RRXRR3R4RYRtR"(tfd_info((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_opened_files_count�scCs.x'tjd�D]\}}}t|�SWdS(Ns/sys/kernel/debug/kvm(RtwalkRZR7(t_roottdirst_files((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_vm_count_kvm�scCs3d�}|d�|d�|d�|d�fS(s8Return tuple of total numbers of TCP and UDP connectionscSsHtjtjjtd|��}|s+dStt|j��dd�S(Ntnetii(	RRXRR3R4RYtmaxRZR�(tprototrecords((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytconn_records_count�s!ttcpttcp6tudptudp6((R�((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_network_connections_count�s	cCs]t�\}}it�d6t�d6t�d6t�d6t�d6t�d6|d6|d6S(	Ntload_averagetmem_infotcpu_infotvm_countt	processest
open_filesttcp_connectionstudp_connections(R�R�R�R�R�R�R�(tconn_tcptconn_udp((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pytget_performance_metricss





(ii(2RGR#RR
R�RfRRRRRRRRRttypingRRRR	R|RYRtcachedRRR/R5RAR?RDRKRdRoR{RR�R�R�R�tcatch_errorsR`R�R�R�R�R�R�R�R�(((s4/usr/libexec/kcare/python/kcarectl/platform_utils.pyt<module>sN.%			
				
				

!$$$