Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/lib/chart/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/lib/chart/__pycache__/lvechartmain.cpython-311.pyc

�

)�f;>���ddlmZddlmZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZmZdd	lmZdd
lmZddlmZd�Zd
ZGd�de
��ZdS)�)�absolute_import)�division)�range)�getuser)�uid_to_username)�HistoryShow�FIELD_LIMIT)�	ChartMain)�dateutil�sizeutil)�X_LEGEND_POINTS)�lveinfolib_gov)�funcc��|pddzdzS)Nr�i�)�vs ��/builddir/build/BUILDROOT/lve-stats-4.2.8-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/chart/lvechartmain.py�_4k_page_to_bytesrs��
�F��a�<�$���)�From�aCPU�lVMem�aPMem�lPMem�NprocF�PMemF�VMemF�aIO�lIO�lIOPS�IOPSf�IOf�lCPU�CPUf�aVMem�aEP�lEP�aNproc�lNproc�EPf�aIOPS�mIOPSc���eZdZ�fd�Zd�Zd�Zed���Z	d
d�Zd�Z	d�Z
ed	���Zd
d
�Zed���Z
d�Z�xZS)�LveChartc���tt|���dd|��t|�dd����|_d|_tj��|_	d|_
dS)N�lvechartz7Creates a chart representing usage pattern for LVE/user�aggregation_period�<iF)�superr/�__init__�int�get�MINIMAL_TIME_STEP�BYTES_IN_MBr�get_governor_mode�
governor_mode�user_ignore)�self�config�	__class__s  �rr5zLveChart.__init__su���
�h����&�&�z�'`�'-�	/�	/�	/�"%�V�Z�Z�0D�b�%I�%I�!J�!J���&���!�3�5�5��� ����rc���t��dk}|�|���}|�dddt���|�ddd	d�
��|S)N�root)�requiredz--idz2LVE id -- will display record only for that LVE id�user_id)�help�dest�typez--userzBUse username instead of LVE id, and show only record for that user�	user_name)rDrE�default)r�add_mutually_exclusive_group�add_argumentr6)r=�parser�is_admin�
id_user_groups    r�customize_parserzLveChart.customize_parser's���9�9��&���;�;�X�;�N�N�
��"�"�6�(\�(1�(+�	#�	-�	-�	-�	�"�"�8�(l�(3�+/�	#�	1�	1�	1��
rc�4�|dkr�|r�|d�t||z|d|����	|d�t||z|jz|d|����dS#ttf$rYdSwxYw|d�||z��|d�||z|jz��dS|d�d��|d�d��dS)a�
        :param dictionary: dict to wich we append dbgov data
        :param governor_mode_is_all:
        :param num: number of dbgov data points near this LVEStatsHistory time
        :param dbcpu_sum: sum value of dbgov cpu near this LVEStatsHistory time
        :param dbio_sum: sum value of dbgov io near this LVEStatsHistory time
        :param _lve_time_index: index of lve point
        :return:
        r�dbcpu�acpu�dbio�aioN)�append�minr9�KeyError�
IndexError)r=�
dictionary�governor_mode_is_all�num�	dbcpu_sum�dbio_sum�_lve_time_indexs       r�append_dbgov_data_to_dictz"LveChart.append_dbgov_data_to_dict5sH����7�7�#�
M��7�#�*�*�3�y�3��
�6�@R�Sb�@c�+d�+d�e�e�e���v�&�-�-��H�s�N�T�-=�=�z�%�?P�Q`�?a�b�b�d�d�d�d�d�� �*�-�����D�D������7�#�*�*�9�s�?�;�;�;��6�"�)�)�(�S�.�4�;K�*K�L�L�L�L�L�
�w��&�&�q�)�)�)��v��%�%�a�(�(�(�(�(s�AB�B�Bc
�r�����fd�}t��}d}t|||��D�]}�rF||dzz
||��cxkr||dzzkr$nn!|��|��|dz
}�Kt��}	�D]�}
|
dkr|	�|���|
tvr^�rF|	��t	d|dz
����|
�����o|	�d����|	�d����|�|	����
|S)Nc���	t�|��d����S#t$rYdSwxYw)Nrr)r6�indexrW)ra�lvedata�show_columnss ��r�
get_time_fromz6LveChart.make_lvedata_with_idle.<locals>.get_time_fromTsO���
��7�5�>�,�*<�*<�V�*D�*D�E�F�F�F���
�
�
��q�q�
���s�-1�
?�?r��r)�listrrTr	�maxra)rbrc�period_from�	period_to�	time_steprd�lvedata_with_idle�indx_�period_from_�line_�items``         r�make_lvedata_with_idlezLveChart.make_lvedata_with_idleQs~����	�	�	�	�	�	�!�F�F����!�+�y�)�D�D�	0�	0�L��
0�<�)�a�-�7�-�-��:N�:N�n�n�n�n�R^�aj�mn�an�Rn�n�n�n�n�n�!�(�(����8�8�8���
�������(�(�(�D��v�~�~����\�2�2�2�2���,�,�"�,�!�L�L���Q���	�1B�1B�)C�L�DV�DV�W[�D\�D\�)]�^�^�^�^�!�L�L��O�O�O�O����Q�����!�(�(��/�/�/�/� � rFc
����t||j�dd��||���}tj|��|_t
j|��}t
j|��}	|�||	��\}
}|�	||||||	����fd�tt��D��}t�
|��}
|
d}|
d=d}|jdk�ri|j�satj|||	||||j������}t�||��}|d	}|d	=|d
z}t|��D]�\}}d\}}|dd�}t|��D]�\}}|||zkrn||d�d
��z
}||d�d
��|d�d
��zz
}|�d
���||�|
|jdk||||��n0|�|
|jdkt+|��|||����|
||
fS)N�	server_id�	localhost)�uid�local_server_idrs�	db_enginec�Z���i|]&\�}|����fd��D����'S)c� ��g|]
}|���Srr)�.0�row�	col_indexs  �r�
<listcomp>z6LveChart.get_chart_data.<locals>.<dictcomp>.<listcomp>�s��� M� M� M�C��Y�� M� M� Mr��lower)rz�colr|rls  @�r�
<dictcomp>z+LveChart.get_chart_data.<locals>.<dictcomp>�sM����,�,�,�R`�R[�]`�3�9�9�;�;� M� M� M� M�;L� M� M� M�,�,�,r�from)�ts�cpu�lcpu�read�lread�write�lwrite�none)rursrc�cfgr�g@)rrr�rr�r��all)rr�r7r�get_governor_ignore_for_userr<r�local_to_gm�
get_time_step�	load_data�	enumerate�SHOW_COLUMNSr/�convert_lvedata_to_dictr;r�HistoryShowDBGov�history_dbgov_show�convert_dbdata_to_dict�popr^�len)r=�engine�from_ts�to_ts�serverrC�show_all�username�utc_from�utc_to�
period_secrk�by_key_�by_key�	lve_timesrc�dbdata�data_collected�dbtimes�
time_step2�lve_time_index�lve_timerPrR�tmp_dbtimes_list�dbtime_index�dbtimerls                           @r�get_chart_datazLveChart.get_chart_dataqs����#�� �H�L�L��k�B�B���	
�
�
�� �<�X�F�F����'��0�0���%�e�,�,�� $� 2� 2�8�V� D� D��
�I� �N�N�6�6�9�g�x�Y_�`�`��,�,�,�,��\�*�*�,�,�,���1�1�'�:�:���6�N�	��6�N�P�����'�'��0@�'�#�4����� �)��H����!� �"�"�
�&�<�<�V�\�R�R�N�$�T�*�G��t�$�"�S��J�,5�i�,@�,@�
(�
(�(���"���t�#*�1�1�1�:� �,5�6F�,G�,G�(�(�(�L�&���:� 5�5�5����!6�!:�!:�1�!=�!=�=����v� 6� :� :�1� =� =��w�@W�@[�@[�\]�@^�@^� ^�^�����A������6�6�"� �.�%�7�(�!� �*�
,�,�,����2�2���*�e�3��,�-�-���&�
(�(�(���y�*�,�,rc	���t||||t||���}t|�����}|�|t|j|j|��}	|	S)N)�dbenginerirjrurcrs�	time_unit)rr�rg�proceedrqrirj)
r=r�r�rkrCr�r��history_showrbrls
          rr�zLveChart.load_data�st��"�F��TZ�`g�0<��Zc�e�e�e���|�+�+�-�-�.�.�� �7�7���|�Og�8D�8N�PY�[�[�� � rc�F�||z
}|���}||jfS�N)�
total_secondsr8)r=r�r��dtr�s     rr�zLveChart.get_time_step�s+��
�h�
���%�%�'�'�
��4�1�1�1rc	�l��ddddddd�}|dkr|�d	d
i��td�t|�����D����}t	t�fd�|D������}|sd
nd}|��d||dtj|���dS)N)r%z#8DB600)r+�green)rz#00DDFF)r�red)r�blue)r#z#9966CC)r%r+rrrr#�r")r"z#007FFFc3�>K�|]}|���V��dSr�r~)rz�keys  r�	<genexpr>z-LveChart._add_faults_graph.<locals>.<genexpr>�s*����G�G�C�C�I�I�K�K�G�G�G�G�G�Grc3�B�K�|]}t�|��V��dSr�)�any)rzr�r�s  �rr�z-LveChart._add_faults_graph.<locals>.<genexpr>�s0�����"S�"S��3�~�c�':�#;�#;�"S�"S�"S�"S�"S�"Srz	No Faults�Faultsr)�legend�x_values�min_y�y_legend_converter�message)�update�tuplerg�keysr��	add_graphr� convert_powers_of_1000_for_graph)�rendererr��times�lve_versionr��legend_keys�faults_presentr�s `      r�_add_faults_graphzLveChart._add_faults_graph�s����(�$�)�'�&�%�
'�'���!����M�M��-��
�
�
��G�G�4����
�
�3F�3F�G�G�G�G�G���U�"S�"S�"S�"S�{�"S�"S�"S�S�S�T�T��%3�=�+�+�������H��E��'�H��		�	�	�	�	�	rc
��|�|��}t|d��}|s|ro|r|jr|r|�|��ddd�}	|r|s|	d=t	|d��dkrd|	d<|�|d	|z|	|dd
td���t|d
��}
|
s|rAddtfddtfd�}|r|
s|d=|�|d|d|tj	���t|d��}|s|rAddtfddtfd�}
|r|s|
d=|�|d|
|dtj	���t|d��}|s|rTddd�}|r|s|d=t	|d��dkrd|d<|�|d|z||dtj	d d!�"��|d#krLt|d$��}|s|r3ddd%�}|r|s|d&=|�|d'||dtj
d d(�"��t|d)��}|s|r1ddd*�}|r|s|d+=|�|d,||dtj
���t|d-��}|s|r1ddd.�}|r|s|d/=|�|d0||dtj
���|�||||��|�|t��dS)1Nr�)�averager�)�limitr�)rr$r$rPr)�databaser�z	CPU Usage�%)r%rr$)r�r�r��unitr��faults�lvmemr�r�r�r�)�lVmem�aVmemr�zVirtual Memory Usage)r�r�r�r��lpmem)rrrzPhysical Memory Usage)r�r�r�r��lio)r rr rRzInput/Output Usagez/s)r#rr )r�r�r�r�r�r���liops)r!r,r!z
Io operations)r"r,r!�lep)�lEp�aEpr�zEntry Processes�lnproc)r*r)r*�	Processes)�_get_title_suffixr��is_normalized_user_cpu�_normalize_cpur�r�r6rr�convert_bytes_for_graphr�r��add_common_x_legendr
)r=r�r�r�r�r��is_user�title_suffix�is_lcpu_limited�
cpu_legend�is_lvmem_limited�vmem_legend�is_lpmem_limited�pmem_legend�is_lio_limited�	io_legend�is_liops_limited�iops_legend�is_lep_limited�	ep_legend�is_lnproc_limited�nproc_legends                      r�
add_graphszLveChart.add_graphs�s����-�-�n�=�=���n�V�4�5�5���
	@�h�
	@��
4�4�6�
4�?�
4��#�#�N�3�3�3�"6�@P�Q�Q�J��
'��
'��v�&��>�'�*�+�+�a�/�/�&:�
�7�#����~�{�\�/I�&0�(-�Q�S�25�&>�	
�
@�
@�
@��~�g�6�7�7���	T�x�	T�!�5�*;�<�#�W�.?�@�B�B�K��
)� 0�
)���(����~�/E�&1��U�2:�2R�
�
T�
T�
T��~�g�6�7�7���	T�x�	T�!�5�*;�<�#�W�.?�@�B�B�K��
)� 0�
)���(����~�/F�&1�E��2:�2R�
�
T�
T�
T��^�E�2�3�3���	=�X�	=�'�+�-�-�I��
%��
%��e�$��>�&�)�*�*�Q�.�.�$8�	�&�!����~�/C�l�/R�&/�%�q�2:�2R�$(�&;�	
�
=�
=�
=�
��?�?�"�>�'�#:�;�;���

G�8�

G�-�1�3�3���-�$4�-�#�G�,��"�"�>�?�*5��Q�6>�6_�(,�*E�	#�G�G�G�
�^�E�2�3�3���	]�X�	]�'�+�-�-�I��
%��
%��e�$����~�/@�&/�%�q�2:�2[�
�
]�
]�
]� ��x� 8�9�9���	]��	]�*�.�0�0�L��
+� 1�
+� ��*����~�{�&2�U�!�2:�2[�
�
]�
]�
]�	
���x����L�L�L��$�$�U�O�<�<�<�<�<rc���t|d��}g}g}g}tdt|d����D]�}|�|d|dz|z��|�|d|dz|z��t|d��dkr'|�|d|dz|z����||d<||d<|r||d<dSdS)Nr�rgY@rQrP)rhrr�rT)r��	max_limit�	a_cpu_new�	l_cpu_new�
db_cpu_new�idxs      rr�zLveChart._normalize_cpu7s����v�.�/�/�	��	��	��
���C��v� 6�7�7�8�8�	T�	T�C����^�F�3�C�8�5�@�9�L�M�M�M����^�F�3�C�8�5�@�9�L�M�M�M��>�'�*�+�+�a�/�/��!�!�.��"9�#�">��"F��"R�S�S�S��!*��v��!*��v���	1�&0�N�7�#�#�#�	1�	1rc��t|d��dks|jdks|jrd}n,|jdkrd}n|jdkrd}n|jd	krd
}nd}|S)NrPrr��r�z. DB usage included�abusersz'. DB usage included, only if restricted�offz,. DB usage is not limited, nor accounted forz*. DB usage is not accounted as part of LVE)r�r;r<)r=r�r�s   rr�zLveChart._get_title_suffixNs����~�g�&�'�'�1�,�,��0B�f�0L�0L�PT�P`�0L��L�L�
�
�5�
(�
(�0�L�L�
�
�9�
,�
,�D�L�L�
�
�5�
(�
(�I�L�L�H�L��r)F)�__name__�
__module__�__qualname__r5rNr^�staticmethodrqr�r�r�r�r�r�r��
__classcell__)r?s@rr/r/s�������!�!�!�!�!����)�)�)�8�!�!��\�!�J!&�
G-�G-�G-�G-�R!�!�!�2�2�2�
����\��*X=�X=�X=�X=�t�1�1��\�1�,
�
�
�
�
�
�
rr/N)�
__future__rr�builtinsr�clcommon.cpapi.pluginlibr�lvestats.lib.uidconverterr�lvestats.lib.lveinfolibrr	�lvestats.lib.chartr
�lvestats.lib.commonsrr�lvestats.lib.chart.utilr
�lvestats.librrrr�r/rrr�<module>rs-��'�&�&�&�&�&�������������,�,�,�,�,�,�5�5�5�5�5�5�<�<�<�<�<�<�<�<�(�(�(�(�(�(�3�3�3�3�3�3�3�3�3�3�3�3�3�3�'�'�'�'�'�'�%�%�%�%�%�%����*��~�~�~�~�~�y�~�~�~�~�~r

Hacked By AnonymousFox1.0, Coded By AnonymousFox