403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.9/site-packages/tuned/daemon/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/tuned/daemon/__pycache__/daemon.cpython-39.opt-1.pyc
a

,�g4�@s�ddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddlm
Z
ddlmZddlZej��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)>�DaemonNc
Cs�t�d�tj|_ttj�|_ttj�|_	tj
|_d|_tj
|_|dur�|�tjtj�|_t|�tjtj��|_t|�tjtj��|_	|�tjtj
�|_|�tjtj�|_|�tjtj
�|_||_|jdkr�ttj�|_|j	dkr�d|_n|j	|jkr�|j|_	|j	|j|_t�d|j�|j�rJt�d�t�d|j|j|jf�t|jd�|_||_||_|��t �|_!z|�"|�Wn4t#�y�}zt�$d	|�WYd}~n
d}~00dS)
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_commandZCFG_DEF_ROLLBACK�	_rollbackZget_boolZ
CFG_DAEMON�getZCFG_SLEEP_INTERVALZCFG_UPDATE_INTERVALZCFG_DYNAMIC_TUNINGZCFG_RECOMMEND_COMMANDZCFG_DEF_RECOMMEND_COMMAND�CFG_ROLLBACK�_application�
_sleep_cycles�infor�_profile_recommender�
_unit_manager�_profile_loader�
_init_threadsr�_cmd�
_init_profiler�error)�selfZunit_manager�profile_loader�
profile_namesZconfigZapplication�e�r �7/usr/lib/python3.9/site-packages/tuned/daemon/daemon.py�__init__sF



zDaemon.__init__cCsPd|_t��|_t��|_t��|_t��|_t��|_|j��t��|_	dS�N)
�_thread�	threading�Event�
_terminate�_terminate_profile_switch�	_not_used�_sighup_processingZ_sighup_pending�set�_profile_applied�rr r r!r7s





zDaemon._init_threadscCs|�d�dS)zARead configuration files again and load profile according to themN)rr-r r r!�reload_profile_configEszDaemon.reload_profile_configcCs�d}|j��}|durP|��\}}|durrd}|r<|d7}n|d7}t�|�n"|dkrr|rht�d�n
t�d�d|_d|_g|_d|_|�	|||�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�msgr r r!rIs&


zDaemon._init_profilec
Cs�|pd}|��}|jr2t�d|j�||jg}|D]2}||jj��vr6d|}|�|d|�t|��q6z.|r�|j	�
|�|_nd|_||_|��|_
WnLty�}z4dd�|�|f}|�|d|�t|��WYd}~n
d}~00dS)Nr/zUsing post-loaded profile '%s'z%Requested profile '%s' doesn't exist.FzCannot load profile(s) '%s': %s� )�splitr4rrrZprofile_locatorZget_known_names�_notify_profile_changedrr�loadr1r2r3r�join)rrr6Zprofile_list�profile�errstrrr r r!�_load_profilesbs,�
zDaemon._load_profilescCs2|��r"d}|�|d|�t|��|�||�dS�Nz/Cannot set profile while the daemon is running.F)�
is_runningr;rr@)rrr6r?r r r!�set_profile|s�zDaemon.set_profilecCs4|sd|_n$t|���dkr*d}t|��n||_dS)N�zYWhitespace is not allowed in profile names; only a single post-loaded profile is allowed.)r4�lenr:r)r�profile_namer?r r r!�_set_post_loaded_profile�s
zDaemon._set_post_loaded_profileFcCsV|��r"d}|�|d|�t|��|�|�|�||�|rR|�||�|�|�dSrA)rBr;rrGr@�_save_active_profile�_save_post_loaded_profile)rZactive_profilesr6r7Zsave_instantlyr?r r r!r5�s�
zDaemon.set_all_profilescCs|jSr#�r1r-r r r!r>�szDaemon.profilecCs|jSr#)r2r-r r r!r6�sz
Daemon.manualcCs|jr|jSdSr#)r1r4r-r r r!r7�szDaemon.post_loaded_profilecCs|jSr#)rr-r r r!�profile_recommender�szDaemon.profile_recommendercCs|jSr#)rr-r r r!r�szDaemon.profile_loadercCs |jdurt�tj|||�|Sr#)rrZsend_signalr
ZSIGNAL_PROFILE_CHANGED)rr�resultr?r r r!r;�s
zDaemon._notify_profile_changedcCsj|jjddgdgd�\}}|dkr&dS|dd�dkr:dS|jjddgdgd�\}}t�d	|�duoh|S)
NZ	systemctlzis-system-runningr)Z	no_errorsF�Zstoppingz	list-jobsz0\b(shutdown|reboot|halt|poweroff)\.target.*start)rZexecute�re�search)rZretcode�outr r r!�_full_rollback_required�szDaemon._full_rollback_requiredcCs�|jdurtd��|j�|jj�|�d�|j�|j�|�	|j
�|j��|j�
�t�d|jj�|jrxt��d�|j�}|�|dd�|j��|j�r|j}|j�|j|j��s|jr�|d8}|dkr�|j}t�d�|j��t�d	�|j��q�|j��d}|j�|j |j��s<|d
k�r<|d7}�q|j!�"��rPt#j$}njt#j%}|�&��slt�d�nN|j'dk�r�t#j(}t�d
t#j)t#j*f�n$|j�r�t�d�t#j$}n
t�d�|j�r�|j�+|�|j�,�dS)Nz2Cannot start the daemon without setting a profile.r9z'static tuning from profile '%s' appliedTZOKrDrzupdating monitorszperforming tunings�z1terminating TuneD due to system shutdown / rebootZnot_on_exitzMterminating TuneD and not rolling back any changes due to '%s' option in '%s'z+terminating TuneD, rolling back all changesz"terminating TuneD in one-shot mode)-r1rrZcreateZunitsrHr=r3r2rIr4Zstart_tuningr,r+rr�namerr�startr;r*�clearrr�waitr'r
rr	Zupdate_monitorsZ
update_tuningr)r(�is_setr
Z
ROLLBACK_FULLZ
ROLLBACK_SOFTrQrZ
ROLLBACK_NONErZGLOBAL_CONFIG_FILEZstop_tuningZdestroy_all)rrZ
_sleep_cnt�iZrollbackr r r!�_thread_code�sZ
�










zDaemon._thread_codec
CsJz|j�||�Wn2tyD}zt�t|��WYd}~n
d}~00dSr#)rZsave_active_profilerrr�str)rrr6rr r r!rH
szDaemon._save_active_profilec
CsHz|j�|�Wn2tyB}zt�t|��WYd}~n
d}~00dSr#)rZsave_post_loaded_profilerrrrZ)rrFrr r r!rIsz Daemon._save_post_loaded_profilecCs&t�d�|j��}t�d|�|S)NzWRunning in automatic mode, checking what profile is recommended for your configuration.zUsing '%s' profile)rrrZ	recommend)rr>r r r!�_get_recommended_profiles

zDaemon._get_recommended_profilecCs2|j��\}}|dur|du}|s*|��}||fSr#)rZget_active_profiler[)rr>r6r r r!r0szDaemon._get_startup_profilecCs|jj��S)z$Return all accessible plugin classes)r�plugins_repositoryZload_all_classesr-r r r!�get_all_plugins$szDaemon.get_all_pluginscCs.z|jj�|�}Wnty&YdS0|jS)zReturn plugin class docstringr/)rr\�
load_class�ImportError�__doc__�rZplugin_nameZplugin_classr r r!�get_plugin_documentation(s�zDaemon.get_plugin_documentationcCs2z|jj�|�}Wnty(iYS0|��S)z�Return plugin's parameters and their hints

		Parameters:
		plugin_name -- plugins name

		Return:
		dictionary -- {parameter_name: hint}
		)rr\r^r_Zget_config_options_hintsrar r r!�get_plugin_hints2s	�
zDaemon.get_plugin_hintscCs
|jduSr#rJr-r r r!�
is_enabledCszDaemon.is_enabledcCs|jduo|j��Sr#)r$�is_aliver-r r r!rBFszDaemon.is_runningcCs`|��rdS|jdurdSt�d�|j��tj|jd�|_	|j
��|j��|j	�
�dS)NFzstarting tuning)�targetT)rBr1rrr)r+r%�ThreadrYr$r(rUr'rTr-r r r!rTIs





zDaemon.startcCs||��st�d�dS|jdur.t�d�dS|j��sFt�d�dS|j��t�d|jj	�|j
�|�}|j��|S)NzTuneD is not runningFzno profile is setzprofile is not appliedzverifying profile(s): %s)
rBrrr1r,rWr)rUrrSrZ
verify_tuningr+)rZignore_missing�retr r r!�verify_profileXs






zDaemon.verify_profilecCsB|��sdSt�d�|r$|j��|j��|j��d|_dS)NFzstopping tuningT)rBrrr(r+r'r$r=)rZprofile_switchr r r!�stopns



zDaemon.stop)NNN)F)F) �__name__�
__module__�__qualname__r"rr.rr@rCrGr5�propertyr>r6r7rKrr;rQrYrHrIr[r0r]rbrcrdrBrTrirjr r r r!rsD
&	
�





	G
r)�os�errnor%Z
tuned.logsZtunedZtuned.exceptionsrZtuned.profiles.exceptionsrZtuned.constsr
Ztuned.utils.commandsrrZtuned.utils.profile_recommenderrrNZlogsrr�objectrr r r r!�<module>s


Youez - 2016 - github.com/yon3zu
LinuXploit