HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/sos/report/plugins/__pycache__/foreman.cpython-312.pyc
�

G%@iH���ddlmZddlmZddlmZmZmZmZm	Z	Gd�de�Z
Gd�de
e�ZGd�d	e
ee�Zy
)�)�match)�quote)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPlugin�	PluginOptc��eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
d	iZe
ddd
��e
ddd��e
ddd��e
ddd��gZdZd�Zd�Zd�Zd�Zdd�Zd�Zy)�Foremanz$Foreman/Satellite systems management�foremani)�sysmgmt)rN�	localhosti8��
PGPASSWORD�days�z!number of days for dynflow output)�default�desc�
proxyfeaturesFz!collect features of smart proxies�puma-gczcollect Puma GC stats�	cvfiltersz'collect content view filters definitionz/pumactl %s -S /usr/share/foreman/tmp/puma.statec��d}	d}t|dd��5}|j�j�}ddd�D]�}|r|ddk(r�|jd�rd	}�"|r$t	d
|�r|j�d|_|r$t	d|�r|j�d|_|r$t	d
|�r|j�d|_|jd�r��d}��	|jjd�r|jjd�s6|jjd�r/|jjd�r|jdd|_d|ji|_|jddddd��|jddg�|jd�d}|j�}|jd�d}|j�}|j!dd|j"�d�gd� �|j!d!d"d#d$d%d&d'd(d)d*d+d,d-d.d|j"�d/�d|j"�d0�d|j"�d1�d2|j"�d3�d2|j"�d4�d|j"�d5�g�|j%d6d7d8d9d:d;|��d;|��d<g�|j'gd=�d	�>�|j%d?d@�A�|j%dBdCdD�E�|j%dFdG�A�|j)dHdI�A�|j+dJ�K�|j-dL�r |j%|j.dMzdN�A�|j%|j.dOzdP�A�|j%dQ�|j1dR�}|j%|dS|j�T�|j3�|j5�|j-dU�r|j7�yy#1swY���xYw#t$rY�� wxYw)VNFz/etc/foreman/database.yml�rzUTF-8)�encodingr�#zproduction:Tz\s+host:\s+\S+�z\s+port:\s+\S+z\s+password:\s+\S+� �"�'���r�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/z*/foreman-ssl_*_ssl.logi�)�	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
*/foreman*z&*/katello-reverse-proxy_error_ssl.log*z*/error_log*z/etc/z*/conf/z	*/conf.d/z'*/katello-reverse-proxy_access_ssl.log*zforeman-selinux-relabel -nvzpassenger-status --show poolz passenger-status --show requestsz"passenger-status --show backtraceszpassenger-memory-statsz
ping -c1 -W1 zping -c1 -W1 localhost)z/root/ssl-buildz/usr/share/foreman/config/hooksz"/var/lib/foreman/red_hat_inventory)�	recursivez�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�x)�tags�timeoutzsystemctl 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)�envr)�open�read�
splitlines�
startswithr�split�dbhost�dbport�dbpasswd�IOError�endswithr4�
add_file_tags�add_forbidden_path�exec_cmd�strip�
add_copy_spec�	apachepkg�add_cmd_output�add_dir_listing�add_service_status�add_journal�
get_option�pumactl�build_query_cmd�collect_foreman_db�collect_proxies�collect_cv_filters)	�self�production_scope�
foreman_db�dfile�
foreman_lines�line�	_hostname�_host_f�_cmds	         �</usr/lib/python3/dist-packages/sos/report/plugins/foreman.py�setupz
Foreman.setup+sa��
!��	�4�J��j�#��8�
:�E� %�
�
�� 7� 7� 9�
�
:�%�
-���t�A�w�#�~���?�?�=�1�'+�$��#��.?��(F�"&�*�*�,�q�/�D�K�#��.?��(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���-�-�/�����-�����'�'>�?�
��	�	�	
����$�%�"�4�8�1�)�.�+�2�2�4�)�����'�z�2�����'�'M�N�����'�|�4��D�N�N�#�7�+��D�N�N�#�9�-�����'�'N�O�)
�	�.	
���)�*�.�0�$��I�;�'��G�9�%�$�	
�		�	
���
��		�	�	
���
0�,�	�	
�	
���M�
�s��K�	
���;�-<�	�	>���� D�1I�	 �	K����2��3��?�?�9�%�������z� 9�1C�
 �
E����D�L�L�7�2�-<�	�	>����;�<��#�#�
�
��	
���D�3L� $���	�	*����!������?�?�;�'��#�#�%�(�[
:�
:��$�	��	�s.�O<�O/�B/O<�#O<�/O9�4O<�<	P	�P	c
�
�|jd��d�}t|�}d}d|�d�}d|�d�}d|�d�}d	|�d�}d
}d}	d}
|d
d|ddd|	|
d�	}||||d�}|j�D]6\}
}|j|�}|j	||
dd|j
���8|j
d�}|j�D]D\}}d}|dk7r|rd}|j|d|��}|j	||dd|j
���Fy)z% Collect foreman db and dynflow data rz dayszRselect id,name,value from settings where name not similar to '%(pass|key|secret)%'zFselect * from foreman_tasks_tasks where started_at > NOW() - interval z order by started_at ascz�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 z, order by foreman_tasks_tasks.started_at ascz�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 z�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 z�SELECT id,network,mask,name,vlanid,gateway,dns_primary,dns_secondary,boot_mode,ipam,type,description,mtu,template_id,nic_delay,externalipam_id,externalipam_group,dhcp_id,tftp_id,dns_id,discovery_id,httpboot_id,externalipam_id FROM subnets ORDER BY id DESCz�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 sp.id, sp.name, sp.url, sp.download_policy, STRING_AGG(f.name, ', ') AS features FROM smart_proxies AS sp INNER JOIN smart_proxy_features AS spf ON sp.id = spf.smart_proxy_id INNER JOIN features AS f ON spf.feature_id = f.id GROUP BY sp.idzselect * from schema_migrationsz`select id,type,name,host,port,account,base_dn,attr_login,onthefly_register,tls from auth_sourcesz!select * from dynflow_schema_infozselect count(*) from auditszselect count(*) from logs)	�foreman_settings_table�foreman_schema_migrations�foreman_auth_table�foreman_subnets_table�dynflow_schema_info�audits_table_count�logs_table_count�fact_names_prefixes�
smart_proxies)�foreman_tasks_tasks�dynflow_execution_plans�dynflow_actions�
dynflow_steps�X�d)r)r-r'r4z
dynflow-utils�psqlrdz /usr/libexec/psql-msgpack-decodeT)�csv�binaryN)rIr�itemsrKrEr4�is_installed)rOr�interval�scmd�dtaskcmd�dyncmd�
dactioncmd�	dstepscmd�
subnetscmd�factnamescmd�smartcmd�	foremandb�
foremancsv�table�valrW�dynutils�dynrls                   rXrLzForeman.collect_foreman_db�s����/�/�&�)�*�%�0����;��
$�	
�
(�(0�z�1I�K��
-�.6�J�71�
1�	�B�CK��L;�;�	�
A�BJ�
�K:�
:�	�
H�	�
�	�
�	�'+�)J�#6�&0�#F�"?� ;�#/�%�
�	�"$,�'-�)�&�	
�
�$�/�/�+�	=�J�E�3��'�'��,�D�����u�c�*-�4�8�8�
 �
=�	=��$�$�_�5��"�(�(�*�	=�H�C���F��+�+��;���'�'���f�'�E�D�����s�C�*-�4�8�8�
 �
=�	=�c�4�|jd�r�|jdd��}|j||j��}|ddk(rN|dj	�d	d
D]4}|jd�}d|d	�d
�}|j
||ddd���6y
y
y
)z Collect foreman proxies rz"select name,url from smart_proxiesT)rk)r4�statusrr&rN�,zNcurl -s --key /etc/foreman/client_key.pem --cert /etc/foreman/client_cert.pem z/v2/features�smart_proxies_features�
)r)�subdirr-)rIrKrAr4r7r9rE)rOrW�proxies�proxys    rXrMzForeman.collect_proxies0s����?�?�?�+��'�'�(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�B�#�A�h�Z�|�5�D��'�'��u�Q�x�/G�02�(�4�
4�&�
,r~c	���d}d}d}d}d}d}d}|||||||d�}|j�D]7\}	}
|j|
�}|j||	d	d
d|j���9y
)z6 Collect content view filters definition if requested z�select f.id, f.name, f.type, f.content_view_id, cv.name as content_view_name, f.description from katello_content_view_filters as f inner join katello_content_views as cv on f.content_view_id = cv.idzpselect id, content_view_filter_id, name, min_version, max_version from katello_content_view_package_filter_ruleszbselect id, content_view_filter_id, name, uuid from katello_content_view_package_group_filter_ruleszxselect id, content_view_filter_id, errata_id, start_date, end_date, types from katello_content_view_erratum_filter_rulesz=select * from katello_content_view_module_stream_filter_ruleszUselect id, content_view_filter_id, name from katello_content_view_docker_filter_ruleszuselect id, content_view_filter_id, name, version, min_version, max_version from katello_content_view_deb_filter_rules)�katello_cv_filters�katello_cv_package_rules�katello_cv_group_rules�katello_cv_errata_rules�katello_cv_module_rules�katello_cv_docker_rules�katello_cv_deb_rules�content_view_filtersrhri)r)r�r-r'r4N)rmrKrEr4)rO�cv_filters_cmd�cv_pkg_rules_cmd�cv_group_rules_cmd�cv_errata_rules_cmd�cv_module_rules_cmd�cv_docker_rules_cmd�cv_deb_rules_cmd�
filter_tablesrz�queryrWs            rXrNzForeman.collect_cv_filtersDs���
+�	�
I�	�

C�	�

8�	�
>�	�

<�	�

9�	�#1�(8�&8�':�':�':�$4�
�
�*�/�/�1�	J�L�E�5��'�'��.�D�����u�'=�(+�s����
 �
J�	Jr~c�b�|rd|�d�}d}|||j|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
        zCOPY (z6) TO STDOUT WITH (FORMAT 'csv', DELIMITER ',', HEADER)z8%s --no-password -h %s -p %s -U foreman -d foreman -c %s)r:r;r)rOr�rkrl�_dbcmds     rXrKzForeman.build_query_cmdxsA����U�G�$A�A�E�K�������d�k�k�5��<�H�H�Hr~c��|jddd�|jddd�|jdg�|jddd	�y)
Nz/etc/foreman/(.*)((conf)(.*)?)z5((\:|\s*)(passw|cred|token|secret|key).*(\:\s|=))(.*)z
\1********z"/etc/foreman/(.*)((yaml|yml)(.*)?)z\1"********"z /var/log/foreman/production.log*zfrom settings wherez(http(s)?://)\S+:\S+(@.*)z\1******:******\3)�do_path_regex_sub�do_paths_http_sub�do_cmd_output_sub)rOs rX�postproczForeman.postproc�sc�����-�D��	�
	
���1�D��	�
	
���.� 
�	�	
���!�(� �	"r~)Frj)�__name__�
__module__�__qualname__�
short_desc�plugin_name�plugin_timeout�profiles�packagesrDr:r;r<r4r	�option_listrJrYrLrMrNrKr��r~rXrrs���7�J��K��N��H��H��I�
�F�
�F��H���
�C��&�"�:�	<��/�5�:�	<��)�U�.�	0��+�u�@�	B�	�K�@�G�V&�pk=�Z4�(2J�hI�"r~rc�"��eZdZdZ�fd�Z�xZS)�
RedHatForeman�httpdc�j��|jddi�t�|�	�|jd�y)Nz"/usr/share/foreman/.ssh/ssh_config�ssh_foreman_configzgem list)r?�superrYrE)rO�	__class__s �rXrYzRedHatForeman.setup�s5������0�2F�
�	�	��
�����J�'r~)r�r�r�rDrY�
__classcell__)r�s@rXr�r��s����I�(�(r~r�c��eZdZdZy)�
DebianForeman�apache2N)r�r�r�rDr�r~rXr�r��s���Ir~r�N)
�rer�shlexr�sos.report.pluginsrrrrr	rr�r�r�r~rX�<module>r�sD����9�9�F"�f�F"�X(�G�\�(��G�\�<�r~