MOON
Server: Apache
System: Linux s5.yayogua.com.py 6.12.0-124.55.3.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:54:02 EDT 2026 x86_64
User: sanbercountryclu (1012)
PHP: 8.2.33
Disabled: NONE
Upload Files
File: //lib/python3.12/site-packages/tuned/daemon/__pycache__/daemon.cpython-312.pyc
�

�]�i�4���ddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddlm
Z
ddlmZddlZej"j%�ZGd�de�Zy)	�N)�TunedException)�InvalidProfileException)�commands)�exports)�ProfileRecommenderc���eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z		dd	�Z
ed
��Zed��Z
ed��Zed
��Zed��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zy) �DaemonNc�"�tjd�tj|_ttj�|_ttj�|_	tj|_d|_tj|_|��D|jtj tj�|_t|j#tj$tj��|_t|j#tj&tj��|_	|jtj(tj�|_|jtj*tj,�|_|j#tj.tj�|_||_|jdkrttj�|_|jdk(rd|_n*|j|jkr|j|_	|j|jz|_tj5d|jz�|jrPtj5d�tj5d|j2|jz|j2fz�t7|j��|_||_||_|j?�tA�|_!	|jE|�y#tF$r9}tjId	|z�|jstGd
��Yd}~yd}~wwxYw)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))�is_hardcodedz:Cannot set initial profile. No tunings will be enabled: %sz<Applying TuneD profile failed, check TuneD logs for details.)%�log�debug�consts�CFG_DEF_DAEMON�_daemon�int�CFG_DEF_SLEEP_INTERVAL�_sleep_interval�CFG_DEF_UPDATE_INTERVAL�_update_interval�CFG_DEF_DYNAMIC_TUNING�_dynamic_tuning�_recommend_command�CFG_DEF_ROLLBACK�	_rollback�get_bool�
CFG_DAEMON�get�CFG_SLEEP_INTERVAL�CFG_UPDATE_INTERVAL�CFG_DYNAMIC_TUNING�CFG_RECOMMEND_COMMAND�CFG_DEF_RECOMMEND_COMMAND�CFG_ROLLBACK�_application�
_sleep_cycles�infor�_profile_recommender�
_unit_manager�_profile_loader�
_init_threadsr�_cmd�
_init_profiler�error)�self�unit_manager�profile_loader�
profile_names�config�application�es       �8/usr/lib/python3.12/site-packages/tuned/daemon/daemon.py�__init__zDaemon.__init__s����)�)�!�"��&�&�$�,��V�:�:�;�$���f�<�<�=�$���6�6�$�� �$���*�*�$�.����/�/�&�"3�"3�V�5J�5J�K�4�<��f�j�j��)B�)B�F�Da�Da�b�c�4���v�z�z�&�*D�*D�f�Fd�Fd�e�f�4�� �/�/�&�*C�*C�V�Eb�Eb�c�4��#�_�_�V�-I�-I�6�Kk�Kk�l�4���J�J�v�2�2�F�4K�4K�L�4�>�!�$��	���Q���f�;�;�<�4��	���a���4�����t�3�3�3��/�/�4���,�,��0D�0D�D�$���(�(�1�D�4H�4H�H�I�	����8�8�F�G��8�8�T�X\�Xj�Xj�mq�nB�nB�YB�DH�DV�DV�XW�
W�X�0�D�D[�D[�@[�\�$��#�$��'�$�������j�$�)�Y����m�$��	�Y��9�9�
I�A�
M�N�
�,�,�
�W�
X�X���Y�s�:M�	N�/N	�	Nc�r�d|_tj�|_tj�|_tj�|_tj�|_tj�|_|j
j�tj�|_	y�N)
�_thread�	threading�Event�
_terminate�_terminate_profile_switch�	_not_used�_sighup_processing�_sighup_pending�set�_profile_applied�r.s r5r*zDaemon._init_threads9sq���$�,��O�O�%�$�/�#,�?�?�#4�$� ��?�?�$�$�.�%�O�O�-�$��"���*�$���.�.����#�/�/�+�$��c�&�|jd�y)zARead configuration files again and load profile according to themN)r,rCs r5�reload_profile_configzDaemon.reload_profile_configGs�����T�rDc�v�d}|jj�}|�:|j�\}}|�Wd}|r|dz
}n|dz
}tj	|�n2|dk(r-|rtj	d�ntj	d�d|_d|_g|_d|_|j|||�y)NTz.No profile is preset, running in manual mode. z(Only post-loaded profile will be enabledzNo profile will be enabled.�)
r+�get_post_loaded_profile�_get_startup_profilerr&�_profile�_manual�_active_profiles�_post_loaded_profile�set_all_profiles)r.r1�manual�post_loaded_profile�msgs     r5r,zDaemon._init_profileKs����&��	�	�9�9�;����!�6�6�8��M�6���
:�C���6�6�S��)�)�S��H�H�S�M������H�H�
7�8��H�H�
*�+��$�-��$�,��$��"�$�����
�v�/B�CrDc�f�|xsd}|j�}|jr2tjd|jz�||jgz}|D]K}||jj
j
�vs�*d|z}|j|d|�t|��	|r!|jj|�|_nd|_||_|j�|_
y#t$r:}ddj|��d|��}|j|d|�t|��d}~wwxYw)NrHzUsing post-loaded profile '%s'z%Requested profile '%s' doesn't exist.FzCannot load profile(s) '� z': )�splitrNrr&r0�profile_locator�get_known_names�_notify_profile_changedrr)�loadrKrLrMr�join)r.r1rP�profile_list�profile�errstrr4s       r5�_load_profileszDaemon._load_profilesds ���%�2�-��$�$�&�,�	����8�8�,�� � �
!�"��$�";�";�!<�<�<��g�
�T�(�(�8�8�H�H�J�J�
4�w�
>�F�� � ���v�>�
��
 � �	�
 ���(�(�-�-�l�;�D�M��D�M��4�<�(�.�.�0�4���	 � �14���,�1G��K�6����
�u�f�=�	��	��� �s�&AC-�-	D0�65D+�+D0c��|j�r d}|j|d|�t|��|j||�y�Nz/Cannot set profile while the daemon is running.F)�
is_runningrXrr^)r.r1rPr]s    r5�set_profilezDaemon.set_profile~sA��	�_�_��=�6����
�u���	��	�����m�V�,rDc�x�|sd|_yt|j��dkDr
d}t|��||_y)N�zYWhitespace is not allowed in profile names; only a single post-loaded profile is allowed.)rN�lenrUr)r.�profile_namer]s   r5�_set_post_loaded_profilezDaemon._set_post_loaded_profile�s;��	�#�4��
�<���� �1�$�g�6�	��	��+�4�rDc��|j�r d}|j|d|�t|��|j|�|j	||�|r$|j||�|j
|�yyr`)rarXrrgr^�_save_active_profile�_save_post_loaded_profile)r.�active_profilesrPrQ�save_instantlyr]s      r5rOzDaemon.set_all_profiles�sw��	�_�_��=�6��������	��	����� 3�4����o�v�.�����_�f�5��!�!�"5�6�rDc��|jSr8�rKrCs r5r\zDaemon.profile�s��	
���rDc��|jSr8)rLrCs r5rPz
Daemon.manual�s��	
���rDc�6�|jr|jSdSr8)rKrNrCs r5rQzDaemon.post_loaded_profile�s��'+�m�m��	"�	"�=��=rDc��|jSr8)r'rCs r5�profile_recommenderzDaemon.profile_recommender�s��	
�	"�	"�"rDc��|jSr8)r)rCs r5r0zDaemon.profile_loader�s��	
�	�	�rDc�j�|j�&tjtj|||�|Sr8)r$r�send_signalr�SIGNAL_PROFILE_CHANGED)r.r1�resultr]s    r5rXzDaemon._notify_profile_changed�s-��	���"�
���v�4�4�m�V�V�T�	�-rDc���|jjddgdg��\}}|dkry|dddk(ry|jjddgdg��\}}tjd	|�duxr|S)
N�	systemctlzis-system-runningr)�	no_errorsF��stoppingz	list-jobsz0\b(shutdown|reboot|halt|poweroff)\.target.*start)r+�execute�re�search)r.�retcode�outs   r5�_full_rollback_requiredzDaemon._full_rollback_required�s������"�"�K�1D�#E�TU�SV�"�W�,�'�3��q�[�
���!�W�
��
����"�"�K��#=�A�3�"�O�,�'�3�	���F��	L�PT�	T�	d�]d�Yd�drDc�L�|j�td��|jj|jj�|jdj
|j�|j�|j|j�|jj�|jj�tjd|jj z�|j"rt%j&�dj
|j�}|j)|dd�|j*j-�|j"r�|j.}|j0j3|j4|j6�s�|j8rt|dz}|dkrj|j.}tj;d�|jj=�tj;d	�|jj?�|j0j3|j4|j6�s��|jj-�d}|j0j3|j@|j6�s@|d
kr;|dz
}|j0j3|j@|j6�s|d
kr�;|jBjE�rtFjH}n�tFjJ}|jM�stjd�n�|jNdk(rItFjP}tjd
tFjR�dtFjT�d��nG|j"r&tjd�tFjH}ntjd�|j"r|jjW|�|jjY�y)Nz2Cannot start the daemon without setting a profile.rTz'static tuning from profile '%s' appliedT�OKrdrzupdating monitorszperforming tunings�z1terminating TuneD due to system shutdown / reboot�not_on_exitz;terminating TuneD and not rolling back any changes due to 'z
' option in '�'z+terminating TuneD, rolling back all changesz"terminating TuneD in one-shot mode)-rKrr(�create�unitsrirZrMrLrjrN�start_tuningrBrArr&�namerr�startrXr?�clearr%r+�waitr<rrr
�update_monitors�
update_tuningr>r=�is_setr�
ROLLBACK_FULL�
ROLLBACK_SOFTr�r�
ROLLBACK_NONEr#�GLOBAL_CONFIG_FILE�stop_tuning�destroy_all)r.r1�
_sleep_cnt�i�rollbacks     r5�_thread_codezDaemon._thread_code�s���	�]�]��	�L�	M�M������D�M�M�/�/�0����C�H�H�T�%:�%:�;��|�|��� � ��!:�!:�;����!�!�#��������(�(�4�t�}�}�7I�7I�I�J�	�\�\�
�=�=�?��(�(�4�0�0�1�-����}�d�D�9������!�	�\�\��"�"�:�
�Y�Y�^�^�D�O�O�T�-A�-A�
B�����1�_�Z��a���%�%�j�	�i�i�#�$�
���(�(�*�	�i�i�$�%�
���&�&�(��Y�Y�^�^�D�O�O�T�-A�-A�
B��������!��I�I�N�N�4�>�>�4�+?�+?�@�Q��U���6�1�
�I�I�N�N�4�>�>�4�+?�+?�@�Q��U�
�#�#�*�*�,��"�"�8��"�"�8�
�
&�
&�
(��H�H�
@�A����-�'��#�#�H��H�H�`f�`s�`s�u{�vO�vO�P�Q��|�|��X�X�;�<��$�$�X��X�X�2�3�	�\�\����!�!�(�+���� � �"rDc��	|jj||�y#t$r(}tj	t|��Yd}~yd}~wwxYwr8)r+�save_active_profilerrr-�str)r.r1rPr4s    r5rizDaemon._save_active_profiles>����9�9� � ���7��	���9�9�S��V�����s��	A�A�Ac��	|jj|�y#t$r(}tj	t|��Yd}~yd}~wwxYwr8)r+�save_post_loaded_profilerrr-r�)r.rfr4s   r5rjz Daemon._save_post_loaded_profiles<����9�9�%�%�l�3��	���9�9�S��V�����s��	A�A
�
Ac��tjd�|jj�}tjd|z�|S)NzWRunning in automatic mode, checking what profile is recommended for your configuration.zUsing '%s' profile)rr&r'�	recommend)r.r\s  r5�_get_recommended_profilezDaemon._get_recommended_profiles:���(�(�d�e��%�%�/�/�1�'��(�(��'�)�*�	�.rDc�t�|jj�\}}|�|du}|s|j�}||fSr8)r+�get_active_profiler�)r.r\rPs   r5rJzDaemon._get_startup_profilesB���I�I�0�0�2�/�'�6��^��4��6�	�
�
*�
*�
,�7�	�&��rDc�J�|jjj�S)z$Return all accessible plugin classes)r(�plugins_repository�load_all_classesrCs r5�get_all_pluginszDaemon.get_all_plugins&s��	
�	�	�	.�	.�	?�	?�	A�ArDc��	|jjj|�}|jS#t$rYywxYw)zReturn plugin class docstringrH)r(r��
load_class�ImportError�__doc__�r.�plugin_name�plugin_classs   r5�get_plugin_documentationzDaemon.get_plugin_documentation*sH��
��$�$�7�7�B�B���<�

�	�	���
�
�
�
�s�%3�	?�?c��	|jjj|�}|j	�S#t$ricYSwxYw)z�Return plugin's parameters and their hints

		Parameters:
		plugin_name -- plugins name

		Return:
		dictionary -- {parameter_name: hint}
		)r(r�r�r��get_config_options_hintsr�s   r5�get_plugin_hintszDaemon.get_plugin_hints4sM��
��$�$�7�7�B�B���<�

�	.�	.�	0�0��
�
�
�9�
�s�%7�A�Ac��|jduSr8rnrCs r5�
is_enabledzDaemon.is_enabledEs��	
���d�	"�"rDc�V�|jduxr|jj�Sr8)r9�is_aliverCs r5razDaemon.is_runningHs#��	
���T�	!�	=�d�l�l�&;�&;�&=�=rDc��|j�ry|j�ytjd�|jj�t
j|j��|_	|jj�|jj�|jj�y)NFzstarting tuning)�targetT)rarKrr&r>rAr:�Threadr�r9r=r�r<r�rCs r5r�zDaemon.startKs���	�_�_��
�	�]�]��
��(�(����.�.�����!�!��):�):�;�$�,�� � �&�&�(��/�/�����,�,����	
rDc���|j�stjd�y|j�tjd�y|jj�stjd�y|jj�tjd|jjz�|jj|�}|jj�|S)NzTuneD is not runningFzno profile is setzprofile is not appliedzverifying profile(s): %s)
rarr-rKrBr�r>r�r&r�r(�
verify_tuningrA)r.�ignore_missing�rets   r5�verify_profilezDaemon.verify_profileZs���	
���	��9�9�
#�$�
�	�]�]���9�9�
 �!�
�	
�	�	�	%�	%�	'��9�9�
%�&�
��.�.�����(�(�%��
�
�(:�(:�:�;����(�(��8�#��.�.����	�*rDc��|j�sytjd�|r|jj	�|j
j	�|jj�d|_y)NFzstopping tuningT)rarr&r=rAr<r9rZ)r.�profile_switchs  r5�stopzDaemon.stopps[��	
���	�
��(�(�����!�!�%�%�'��/�/�����,�,�����$�,�	
rD)NNN)F) �__name__�
__module__�__qualname__r6r*rFr,r^rbrgrO�propertyr\rPrQrrr0rXr�r�rirjr�rJr�r�r�r�rar�r�r��rDr5r	r	s���&Y�P,��D�2 �4-�,��
7����������>��>�
�#��#�����
�
e�E#�N����B��1�"#�>�
�
�,
rDr	)�os�errnor:�
tuned.logs�tuned�tuned.exceptionsr�tuned.profiles.exceptionsr�tuned.constsr�tuned.utils.commandsrr�tuned.utils.profile_recommenderrr~�logsrr�objectr	r�rDr5�<module>r�sD��	����+�=��)��>�	��j�j�n�n���j�V�jrD