HOME


Mini Shell 1.0
DIR: /usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/foreman.cpython-312.pyc
�

i��d':���ddlmZmZmZmZmZmZddlmZddl	m
Z
ddlmZGd�de�Z
Gd�de
ee�ZGd	�d
e
ee�Zy)�)�Plugin�RedHatPlugin�	SCLPlugin�DebianPlugin�UbuntuPlugin�	PluginOpt)�quote)�match)�
is_executablec�x�eZdZdZdZdZdZdZeddd�	�ed
dd�	�ed
dd�	�gZ	dZ
d�Zdd�Zd�Z
y)�Foremanz$Foreman/Satellite systems management�foremani)�sysmgmt)r�months�z#number of months for dynflow output)�default�desc�
proxyfeaturesFz!collect features of smart proxies�puma-gczcollect Puma GC statsz/pumactl %s -S /usr/share/foreman/tmp/puma.statec�
�d}d|_d|_	td�j�j	�D]�}|r|ddk(r�|jd�rd}�"|r$t
d	|�r|j�d
|_|r$t
d|�r|j�d
|_|jd�r��d}��	|jjd
�r|jjd
�s6|jjd�r/|jjd�r|jd
d|_d|ji|_
|jddddd��|jddg�|jd�d}|j�}|jd�d}|j�}|jddj!|j"�gd��|jdddd d!d"d#d$d%d&d'd(d)d*d+j!|j"�d,j!|j"�d-j!|j"�d.j!|j"�d/j!|j"�d0j!|j"�g�|j%d1d2d3d4d5d6d7d8|zd8|zd9g
�|j%d:d;�<�|j%d=d>�?�|j%d@dA�<�|j'dBdC�<�|j)dD�E�|j+dF�r |j%|j,dGzdH�<�|j%|j,dIzdJ�<�|j%dK�|j/dL�}|j%|dM|j�N�dO|j+dP�z}dQ}dR}dSt1|�z}	dTt1|�z}
dUt1|�z}dV}||dWdXdY|dZd[�}
d\|	|
|d]�}|
D]6}|j/|
|�}|j%||d^d_|j�`��8|j3da�}|D]D}db}|dck7r|rdd}|j/||d|�e�}|j%||d^d_|j�`��F|j+df�r�|j/dgd�h�}|j||j�i�}|djdk(rL|dj	�d
dD]3}|jdk�}dl|d
z}|j%||ddmdn�o��5|j5dpdqg�y#t$rY���wxYw)rNF�	localhost�z/etc/foreman/database.ymlr�#zproduction:Tz\s+host:\s+\S+rz\s+password:\s+\S+� �"�'����
PGPASSWORD�foreman_production_log�foreman_tasks_config�foreman_ssl_access_ssl_log)z!/var/log/foreman/production.log.*z/etc/sysconfig/foreman-tasks�/etc/sysconfig/dynflowdz)/var/log/httpd/foreman-ssl_access_ssl.logz/etc/foreman/*key.pemz/etc/foreman/encryption_key.rb�hostname�outputzhostname -fz/var/log/foreman/production.logz"/var/log/{}*/foreman-ssl_*_ssl.log)�	sizelimitz
/etc/foreman/z/etc/sysconfig/foremanr"z/etc/default/foremanz&/var/log/foreman/dynflow_executor*log*z*/var/log/foreman/dynflow_executor*.output*z#/var/log/foreman/apipie_cache*.log*z/var/log/foreman/cron*.log*z /var/log/foreman/db_migrate*log*z/var/log/foreman/db_seed*log*z$/var/log/foreman/production.log[.-]*z$/var/log/foreman-selinux-install.logz&/var/log/foreman-proxy-certs-generate*z/usr/share/foreman/Gemfile*z/var/log/{}*/foreman*z2/var/log/{}*/katello-reverse-proxy_access_ssl.log*z1/var/log/{}*/katello-reverse-proxy_error_ssl.log*z/var/log/{}*/error_log*z/etc/{}*/conf/z/etc/{}*/conf.d/zforeman-selinux-relabel -nvzpassenger-status --show poolz passenger-status --show requestsz"passenger-status --show backtraceszpassenger-memory-statszls -lanR /root/ssl-buildz(ls -lanR /usr/share/foreman/config/hookszping -c1 -W1 %szping -c1 -W1 localhostz�qpid-stat -b amqps://localhost:5671 -q                     --ssl-certificate=/etc/pki/katello/qpid_router_client.crt                     --ssl-key=/etc/pki/katello/qpid_router_client.key                     --sasl-mechanism=ANONYMOUSzqpid-stat_-q��suggest_filenamezhammer ping�hammer_ping)�tagszsystemctl list-units dynflow*�
dynflow_unitsz!"system-dynflow\x2dsidekiq.slice"�dynflow_sidekiq_statuszdynflow-sidekiq@*)�unitsrzgc-statszpumactl_gc-stats�stats�
pumactl_statsz/usr/sbin/foreman-puma-statusa[SELECT table_name, pg_size_pretty(total_bytes) AS total, pg_size_pretty(index_bytes) AS INDEX , pg_size_pretty(toast_bytes) AS toast, pg_size_pretty(table_bytes) AS TABLE FROM ( SELECT *, total_bytes-index_bytes-COALESCE(toast_bytes,0) AS table_bytes FROM (SELECT c.oid,nspname AS table_schema, relname AS TABLE_NAME, c.reltuples AS row_estimate, pg_total_relation_size(c.oid) AS total_bytes, pg_indexes_size(c.oid) AS index_bytes, pg_total_relation_size(reltoastrelid) AS toast_bytes FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE relkind = 'r') a) a order by total_bytes DESC�foreman_db_tables_sizes)r'�envz	%s monthsrzRselect id,name,value from settings where name not similar to '%(pass|key|secret)%'z]select type,name,host,port,account,base_dn,attr_login,onthefly_register,tls from auth_sourcesz�select dynflow_execution_plans.* from foreman_tasks_tasks join dynflow_execution_plans on (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid::varchar) where foreman_tasks_tasks.started_at > NOW() - interval %sz�select dynflow_actions.* from foreman_tasks_tasks join dynflow_actions on (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid::varchar) where foreman_tasks_tasks.started_at > NOW() - interval %sz�select dynflow_steps.* from foreman_tasks_tasks join dynflow_steps on (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid::varchar) where foreman_tasks_tasks.started_at > NOW() - interval %sz�WITH prefix_counts AS (SELECT split_part(name,'::',1) FROM fact_names) SELECT COUNT(*), split_part AS "fact_name_prefix" FROM prefix_counts GROUP BY split_part ORDER BY count DESC LIMIT 100z!select * from dynflow_schema_infozselect count(*) from auditszselect count(*) from logsz2select name,url,download_policy from smart_proxies)�foreman_settings_table�foreman_auth_table�dynflow_schema_info�audits_table_count�logs_table_count�fact_names_prefixes�
smart_proxiesz!select * from foreman_tasks_tasks)�foreman_tasks_tasks�dynflow_execution_plans�dynflow_actions�
dynflow_stepsiX�d)r'�timeoutr%r0z
dynflow-utils�psqlr8z /usr/libexec/psql-msgpack-decode)�csv�binaryrz"select name,url from smart_proxies)r?)r0�status�,z\curl -s --key /etc/foreman/client_key.pem --cert /etc/foreman/client_cert.pem %s/v2/features�smart_proxies_features�
)r'�subdirr=�
http_proxy�https_proxy)�dbhost�dbpasswd�open�read�
splitlines�
startswithr
�split�IOError�endswithr0�
add_file_tags�add_forbidden_path�exec_cmd�strip�
add_copy_spec�format�	apachepkg�add_cmd_output�add_service_status�add_journal�
get_option�pumactl�build_query_cmdr	�is_installed�add_env_var)�self�production_scope�line�	_hostname�_host_f�_cmdr�scmd�authcmd�dyncmd�
dactioncmd�	dstepscmd�factnamescmd�	foremandb�
foremancsv�table�dynutils�dynr@�proxies�proxys                     �</usr/lib/python3/dist-packages/sos/report/plugins/foreman.py�setupz
Foreman.setup%s$��
!��!�����
�	��8�9�>�>�@�K�K�M�

-���t�A�w�#�~���?�?�=�1�'+�$��#��.?��(F�"&�*�*�,�q�/�D�K�#��.C�T�(J�$(�J�J�L��O�D�M����s�+�',�$�

-�$
�M�M�$�$�S�)�d�m�m�.D�.D�S�.I��M�M�$�$�T�*�t�}�}�/E�/E�d�/K� �M�M�!�B�/�D�M�!�$�-�-�0������1I�,B�'=�,�
�	�	
���#�,�!
�	�
�M�M�*�-�h�7�	��O�O�%�	��-�-�
�.�x�8���-�-�/��	
���-�0�7�7����G�
��	�	�	
����$�%�"�4�8�1�)�.�+�2�2�4�)�#�*�*�4�>�>�:�@�G�G����
 �?�F�F����
 �%�,�,�T�^�^�<��#�#�D�N�N�3��%�%�d�n�n�5�-
�	�2	
���)�*�.�0�$�&�6��	�)���'�$�
�	�	
���
0�,�	�	
�	
���M�
��>�	
���;�-<�	�	>���� D�1I�	 �	K����2��3��?�?�9�%�������z� 9�1C�
 �
E����D�L�L�7�2�-<�	�	>����;�<��#�#�
�
��	
���D�3L� $���	�	*��t���x�8�8��
$�	
�
6�	�
/�27�v��
?�	�D��V�}�	�	�
C��F�m�	
�	�
�	�'+�")�#F�"?� ;�#/�2�	
�	�$G�'-�)�&�	
�
��	=�E��'�'�	�%�(8�9�D�����u�c�*-�4�8�8�
 �
=�	=��$�$�_�5���	=�C��F��+�+��;���'�'�
�3��T�/5�(�7�D�����s�C�*-�4�8�8�
 �
=�
	=��?�?�?�+��'�'�(L�,0�(�2�D��m�m�D�d�h�h�m�7�G��x� �A�%�$�X�.�9�9�;�A�B�?�4�E�!�K�K��,�E�,�.3�A�h�7�D��'�'��u�Q�x�/G�02�(�4�
4�	
���,�
�6�7��I�	��	�s�B&U�9U�	U�Uc�J�|rd|z}d}|||jt|�fzS)aI
        Builds the command needed to invoke the pgsql query as the postgres
        user.
        The query requires significant quoting work to satisfy both the
        shell and postgres parsing requirements. Note that this will generate
        a large amount of quoting in sos logs referencing the command being run
        z>COPY (%s) TO STDOUT WITH (FORMAT 'csv', DELIMITER ',', HEADER)z:%s --no-password -h %s -p 5432 -U foreman -d foreman -c %s)rHr	)r`�queryr?r@�_dbcmds     rsr]zForeman.build_query_cmd"s7���A�CH�I�E�M�������e�E�l�;�;�;�c��|jd|jzdd�|jddd�|jddd�y)	Nz(/var/log/%s*/foreman-ssl_access_ssl.log*z7(.*\?(passw|cred|token|secret|key).*=)(.*) (HTTP.*(.*))z
\1******** \4z/etc/foreman/(.*)((conf)(.*)?)z5((\:|\s*)(passw|cred|token|secret|key).*(\:\s|=))(.*)z
\1********z"/etc/foreman/(.*)((yaml|yml)(.*)?)z\1"********")�do_path_regex_subrW)r`s rs�postproczForeman.postproc0sT�����6����G�F��	�	
���-�D��	�
	
���1�D��	rxN)Fr>)�__name__�
__module__�__qualname__�
short_desc�plugin_name�plugin_timeout�profiles�packagesr�option_listr\rtr]r{�rxrsr
r
sh��7�J��K��N��H��H��(�A�<�	>��/�5�:�	<��)�U�.�	0��K�@�G�{8�z<�
rxr
c�"��eZdZdZ�fd�Z�xZS)�
RedHatForeman�httpdc����|jddi�|jj�dk(rtd�rd|jz|_t
t|��|jddd�	�y)
Nz"/usr/share/foreman/.ssh/ssh_config�ssh_foreman_config��sclzscl enable tfm '%s'�tfmzgem listzscl enable tfm gem listr&)	rQ�policy�dist_versionrr\�superr�rt�add_cmd_output_scl)r`�	__class__s �rsrtzRedHatForeman.setupGsr������0�2F�
�	�
�;�;�#�#�%��*�}�U�/C�0�4�<�<�?�D�L�
�m�T�(�*�����z�1J�	 �	Lrx)r|r}r~rWrt�
__classcell__)r�s@rsr�r�Cs����I�L�Lrxr�c��eZdZdZy)�
DebianForeman�apache2N)r|r}r~rWr�rxrsr�r�Vs���Irxr�N)�sos.report.pluginsrrrrrr�pipesr	�rer
�
sos.utilitiesrr
r�r�r�rxrs�<module>r�sK��G�G���'�j�f�j�`	L�G�Y��L�&�G�\�<�rx