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__/controller.cpython-39.pyc
a

,�g�F�@s�ddlmZddlZddlZddlmZddlZddlmZddlm	Z	ddl
mZdgZej
��ZGdd�de�ZGd	d�dejjj�ZdS)
�)�exportsN)�TunedException)�commands)�hotplug�
Controllerc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
TimerStorecCst�|_t��|_dS�N)�dict�_timers�	threading�Lock�_timers_lock��self�r�;/usr/lib/python3.9/site-packages/tuned/daemon/controller.py�__init__szTimerStore.__init__cCs4|j�||j|<Wd�n1s&0YdSr)r
r
�r�token�timerrrr�store_timerszTimerStore.store_timercCsV|j�<z|j|}|��|j|=WnYn0Wd�n1sH0YdSr)r
r
�cancelrrrr�
drop_timers
zTimerStore.drop_timercCsL|j�2|j��D]}|��q|j��Wd�n1s>0YdSr)r
r
�valuesr�clear)rrrrr�
cancel_all s
zTimerStore.cancel_allN)�__name__�
__module__�__qualname__rrrrrrrrrs	rcs�eZdZdZ�fdd�Zdd�Zdd�Zdd	�Ze�	d
�dd��Z
d
d�Ze�dd�dZdd��Z
e�dd�d[dd��Ze�dd�d\dd��Zd]dd�Ze�dd�d^dd��Ze�dd�d_dd ��Zd!d"�Ze�dd#�d`d$d%��Ze�dd#�dad&d'��Ze�dd�dbd(d)��Ze�dd*�dcd+d,��Ze�dd�ddd-d.��Ze�dd�ded/d0��Ze�dd�dfd1d2��Ze�dd3�dgd4d5��Ze�dd6�dhd7d8��Ze�dd9�did:d;��Ze�dd�djd<d=��Ze�dd�dkd>d?��Ze�dd�dld@dA��Z e�ddB�dmdCdD��Z!e�dd�dndEdF��Z"e�ddG�dodHdI��Z#e�dd�dpdJdK��Z$e�dLd#�dqdMdN��Z%e�ddO�drdPdQ��Z&e�ddR�dsdSdT��Z'e�dUd#�dtdVdW��Z(e�dd#�dudXdY��Z)�Z*S)vrz�
	Controller's purpose is to keep the program running, start/stop the tuning,
	and export the controller interface (currently only over D-Bus).
	cs8tt|���||_||_t��|_t�|_	t
�|_dSr)�superrr�_daemon�_global_configr�Event�
_terminater�_cmdr�_timer_store)r�daemonZ
global_config��	__class__rrr,s
zController.__init__cCsrt�d�|��}|j�tjtj�}|s4|r4t��|r\|j	�
�|j�|j	d�s\t�
�qBt�d�|��dS)z1
		Controller main loop. The call is blocking.
		zstarting controller�zterminating controllerN)�log�info�startr!�get_bool�consts�
CFG_DAEMON�CFG_DEF_DAEMONrr#rr$�waitZperiod_check�stop)r�resr&rrr�run4s



zController.runcCs|j��dSr)r#�setrrrr�	terminateGszController.terminatecCs`|jj��r|jj��nBd}|r\|jj��|jj��|��sN|jj��|jj��}qdS)NT)r Z_sighup_processing�is_setZ_sighup_pendingr5r�reload)rZ	do_reloadrrr�sighupJszController.sighupZsbscCsdSrr)r�profile_name�resultZerrstrrrr�profile_changedVszController.profile_changedcCstj�|�|j�|�dSr��tuned�logs�log_capture_finishr%r)rrrrr�_log_capture_abort_szController._log_capture_abort�ii�sNcCsf|dkrdStj�|�}|dur$dS|dkrVtj||j|gd�}|j�||�|��|durbdS|S)N�r)�args)	r>r?�log_capture_startr�TimerrAr%rr,)rZ	log_level�timeout�callerrrrrrrFcs�zController.log_capture_startcCs4|dkrdStj�|�}|j�|�|dur0dS|S�NrDr=)rrrIr3rrrr@qs
zController.log_capture_finishrD�bcCsD|dkrdS|j�tjtj�r:|j��r,dS|j��s:dS|j��S)NrDFT)	r!r-r.r/r0r �
is_running�
is_enabledr,�rrIrrrr,ys

zController.startFcCs,|j��sd}n|jj|d�}|j��|S)NT��profile_switch)r rLr2r%r)rrPr3rrr�_stop�s


zController._stopcCs|dkrdS|jdd�S)NrDFrO)rQrNrrrr2�szController.stopc
Csv|dkrdS|j��r*|jdd�}|s*dSz|j��Wn4tyl}zt�d|�WYd}~dSd}~00|��S)NrDFTrOzFailed to reload TuneD: %s)r rLrQZreload_profile_configrr*�errorr,)rrIZstop_ok�errrr8�s
zController.reloadc
Cs|j��}d}d}d}z�z$|r,|jjdd�|j�||�Wnhtjjy�}zLd}t|�}|r�|jjj	|kr�t
�d|�d}nt
�d|�WYd}~n
d}~00W|r�|r�t
�d|�n|s�t
�
d�|j��n6|�r|r�t
�d|�n|�st
�
d�|j��0||fS)	N�OKTFrOz@Failed to reapply profile '%s'. Did it change on disk and break?zFailed to apply profile '%s'z>Applying previously applied (possibly out-dated) profile '%s'.z$Applying previously applied profile.)r rLr2Zset_profiler>�
exceptionsr�str�profile�namer*rRZwarningr+r,)rr:�manualZwas_running�msg�successZreapplyrSrrr�_switch_profile�s8
&
�
zController._switch_profilez(bs)cCs(|dkrdS|j�|�sdS|�|d�S)NrD�F�Unauthorized)FzInvalid profile_nameT)r$�
is_valid_namer\�rr:rIrrr�switch_profile�s
zController.switch_profilecCs |dkrdS|��}|�|d�S)NrDr]F)�recommend_profiler\)rrIr:rrr�auto_profile�szController.auto_profilecCs*|dkrdS|jjdur"|jjjSdSdSrJ)r rWrXrNrrr�active_profile�s

zController.active_profilez(ss)c
Cs�|dkrdS|jj}|durxz"|j��\}}|dur<|du}Wn8tyv}z d}t|�}||fWYd}~Sd}~00|r�tjntj}|dfS)NrD)�unknownr^re)	r rYr$Zget_active_profilerrVr.ZACTIVE_PROFILE_MANUALZACTIVE_PROFILE_AUTO)rrIrYrWrS�moderRrrr�profile_mode�szController.profile_modecCs|dkrdS|jjpdSrJ)r �post_loaded_profilerNrrrrh�szController.post_loaded_profilecCsB|dkrdS|j��r |j��|j��r>|jjddddd�dS)NrDFT)Zsave_instantly)r rLr2rMZset_all_profilesrNrrr�disable�s


�zController.disablecCs|dkrdS|j��S)NrDF)r rLrNrrrrL�szController.is_running�ascCs|dkrgS|jjj��SrJ)r �profile_loader�profile_locatorZget_known_namesrNrrr�profiles�szController.profilesza(ss)cCs|dkrgS|jjj��SrJ)r rkrlZget_known_names_summaryrNrrr�	profiles2szController.profiles2z(bsss)cCsR|dks|j�|�sdS|dus(|dkr0|��}t|jjj�|tj	tj
gdg��S)NrD)FrDrDrD)r$r_rd�tupler rkrlZget_profile_attrsr.ZPROFILE_ATTR_SUMMARYZPROFILE_ATTR_DESCRIPTIONr`rrr�profile_info	s
zController.profile_infocCs|dkrdS|jj��SrJ)r Zprofile_recommenderZ	recommendrNrrrrbszController.recommend_profilecCs|dkrdS|jjdd�S)NrDF�Zignore_missing�r �verify_profilerNrrrrsszController.verify_profilecCs|dkrdS|jjdd�S)NrDFTrqrrrNrrr�verify_profile_ignore_missingsz(Controller.verify_profile_ignore_missingz	a{sa{ss}}cCsr|dkriSi}|j��D]R}|j�d�d�dd�d}|��}i||<|��D]\}}t|�|||<qRq|S)zuReturn dictionary with accesible plugins

		Return:
		dictionary -- {plugin_name: {parameter_name: default_value}}
		rD�.����_r))r �get_all_pluginsr�splitZ_get_config_options�itemsrV)rrI�pluginsZplugin_class�plugin_nameZconf_options�key�valrrrrx#szController.get_all_pluginscCs(|dks|j�|�sdS|j�t|��S)z"Return docstring of plugin's classrD)r$r_r �get_plugin_documentationrV�rr|rIrrrr5sz#Controller.get_plugin_documentationza{ss}cCs(|dks|j�|�siS|j�t|��S)z�Return dictionary with plugin's parameters and their hints

		Parameters:
		plugin_name -- name of plugin

		Return:
		dictionary -- {parameter_name: hint}
		rD)r$r_r �get_plugin_hintsrVr�rrrr�<s
zController.get_plugin_hintscCsB|dks|j�|�sdS|jjr>|jjjr>|jjj�|�dSdS)z�Allows to dynamically add sockets to send signals to

		Parameters:
		path -- path to socket to register for sending signals

		Return:
		bool -- True on success
		rDFT)r$r_r Z_applicationZ_unix_socket_exporterZregister_signal_path)r�pathrIrrr�register_socket_signal_pathJs
z&Controller.register_socket_signal_path�ssc
Cs�|dkrdS|j�|�sdS|j�|�s,dSd}|jjjD]&}|j|kr:t�d|j�d}qbq:|s�d|}t�|�d|fSt	|j
tj�s�d	|j
j}t�|�d|fSt
|j�|��}t�d
|jt|�f�|jjjD]�}|j|@}	t|	�r�||	8}t�dt|	�|j|jf�|j
j|j
jk�rbd|j|j
jt|	�|j|j
jf}t�|�d|fS|j
�||	�|j
�||	�q�t|��r�d
t|�}t�|�d|fSdS)NrDr])FzInvalid devices�F�Invalid instance_nameFzFound instance '%s'.T�Instance '%s' not found�>Plugin '%s' does not support hotplugging or dynamic instances.z-Instance '%s' trying to acquire devices '%s'.�8Moving devices '%s' from instance '%s' to instance '%s'.ztTarget instance '%s' is of type '%s', but devices '%s' are currently handled by instance '%s' which is of type '%s'.z2Ignoring devices not handled by any instance '%s'.�TrT)r$r_r �
_unit_manager�	instancesrXr*�debugrR�
isinstance�pluginr�Pluginr5Zdevstr2devsrV�processed_devices�lenr+�_remove_devices_nocheck�_add_devices_nocheck)
r�devices�
instance_namerI�foundZinstance_target�retsZdevs�instance�devs_movingrrr�instance_acquire_devices^sX



���


z#Controller.instance_acquire_devicesz	(bsa(ss))cs�|dkrddgfS|j���s(ddgfS�dkr\�|����vr\d�}t�|�d|gfStdd�|jjj	�}�dkr�t�fdd�|�}d	d
t
tdd�|��fS)aReturn a list of active instances of a plugin or all active instances

		Parameters:
		plugin_name -- name of the plugin or an empty string

		Return:
		bool -- True on success
		string -- error message or "OK"
		list of string pairs -- [(instance_name, plugin_name)]
		rDFr^�Invalid plugin_namezPlugin '%s' does not existcSs|jSr)Zactive�r�rrr�<lambda>��z*Controller.get_instances.<locals>.<lambda>cs|jj�kSr)r�rXr��r|rrr��r�TrTcSs|j|jjfSr)rXr�r�rrrr��r�)r$r_rx�keysr*rR�filterr r�r��list�map)rr|rIr�r�rr�r�
get_instances�s



zController.get_instancesz(bsas)cCsv|dkrddgfS|j�|�s(ddgfS|jjjD]&}|j|kr2ddtt|j��fSq2d|}t	�
|�d|gfS)z�Return a list of devices assigned to an instance

		Parameters:
		instance_name -- name of the instance

		Return:
		bool -- True on success
		string -- error message or "OK"
		list of strings -- device names
		rDFr^r�TrTr�)r$r_r r�r�rX�sortedr�r�r*rR)rr�rIr�r�rrr�instance_get_devices�s



zController.instance_get_deviceszssa{ss}c
Cs:|dkrdS|j�|�sdS|j�|�s,dS|��D]&\}}|j�|�rT|j�|�s4dSq4dd�|jjjD�}||��vr�d|}t�|�d	|fS||}	t	|	t
j�s�d
|	j}t�|�d	|fS|�
dd�}
|�
d
d�}|�
dd�}|�
dd�}
t|�
d|jjj��}z4|	�|||
|||
|�}|	�|�|jjj�|�WnHt�y�}z.d|t|�f}t�|�d	|fWYd}~Sd}~00t�d||f�|	�|�|	�|�|jjjD]z}||k�s�|j|	k�s�|j|jk�r�q�|	�||j�}t|��r�t�dt|�|j|jf�|	�||�|	�||��q�dS)aDynamically create a plugin instance

		Parameters:
		plugin_name -- name of the plugin
		instance_name -- name of the new instance
		dict of string-string -- options for the new instance

		Return:
		bool -- True on success
		string -- error message or "OK"
		rDr])Fr�r�)FzInvalid optionscSsi|]}|j|�qSr�rX)�.0�prrr�
<dictcomp>�r�z.Controller.instance_create.<locals>.<dictcomp>zPlugin '%s' not foundFr�r�N�devices_udev_regex�
script_pre�script_post�priorityz Error creating instance '%s': %sz,Created dynamic instance '%s' of plugin '%s'r�r�) r$r_rzr r�r{r�r*rRr�rr�rX�pop�intZ_def_instance_priorityZcreate_instanceZinitialize_instancer��append�	ExceptionrVr+Zassign_free_devicesZinstance_apply_tuningr�r�Z_get_matching_devicesr�r�r�r�)rr|r��optionsrIr}�valuer{r�r�r�r�r�r�r�r�rSZother_instancer�rrr�instance_create�sd








�
�
�zController.instance_createc	
sH|dkrdS|j���sdSz �fdd�|jjjD�d}Wn,tyhd�}t�|�d|fYS0|j}t	|t
j�s�d	|j}t�|�d|fS|j
��}z4|�||�|jjj�|�|�|�|�|�WnHt�y}z.d
�t|�f}t�|�d|fWYd}~Sd}~00t�d��|D]}|�|��q2d
S)z�Destroy a dynamically created plugin instance

		Parameters:
		instance_name -- name of the new instance

		Return:
		bool -- True on success
		string -- error message or "OK"
		rDr]r�csg|]}|j�kr|�qSrr�)r��i�r�rr�
<listcomp>
r�z/Controller.instance_destroy.<locals>.<listcomp>rr�Fr�z Error deleting instance '%s': %sNzDeleted instance '%s'r�)r$r_r r�r��
IndexErrorr*rRr�r�rr�rXr��copyr��removeZinstance_unapply_tuningZdestroy_instancer�rVr+Z_add_device)	rr�rIr�r�r�r�rSZdevicerr�r�instance_destroy�s: 





zController.instance_destroy)N)N)N)F)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)+rrr�__doc__rr4r6r9r�signalr<rAZexportrFr@r,rQr2r8r\rarcrdrgrhrirLrmrnrprbrsrtrxrr�r�r�r�r�r�r��
__classcell__rrr'rr&s�


























+


?
)r>rZ
tuned.logsZtuned.exceptionsrrZtuned.constsr.Ztuned.utils.commandsrZ
tuned.pluginsr�__all__r?�getr*�objectrZ
interfacesZExportableInterfacerrrrr�<module>s


Youez - 2016 - github.com/yon3zu
LinuXploit