| Current Path : /lib/python3/dist-packages/sos/report/plugins/__pycache__/ |
| Current File : //lib/python3/dist-packages/sos/report/plugins/__pycache__/foreman.cpython-38.pyc |
U
-�_g�; � @ sn d dl mZ d dlmZ d dlmZmZmZmZm Z G dd� de�Z
G dd� de
e�ZG dd � d e
ee�Zd
S )� )�match)�quote)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPlugin� PluginOptc @ s� e Zd ZdZdZdZdZdZdZdZ dZ
d diZed
ddd
�edddd
�edddd
�gZ
dZdd� Zdd� Zdd� Zddd�Zdd� ZdS ) �Foremanz$Foreman/Satellite systems management�foremani )Zsysmgmt)r
NZ localhost� �
PGPASSWORD�days� z!number of days for dynflow output)�defaultZdesc�
proxyfeaturesFz!collect features of smart proxies�puma-gczcollect Puma GC statsz/pumactl %s -S /usr/share/foreman/tmp/puma.statec C s� d}z�d}t |ddd��}|�� �� }W 5 Q R X |D ]l}|r4|d dkrJq4|�d�rZd }q4|rvtd
|�rv|�� d | _|r�td|�r�|�� d | _|�d
�s4d}q4W n tk
r� Y nX | j�d�r�| j� d�s�| j�d�r�| j� d�r�| jdd� | _d| ji| _
| �ddddd�� | �ddg� | �
d�d }|�� }| �
d�d }|�� }| jdd| j� d�gdd� | �d d!d"d#d$d%d&d'd(d)d*d+d,d-d| j� d.�d| j� d/�d| j� d0�d1| j� d2�d1| j� d3�d| j� d4�g� | �d5d6d7d8d9d:|� �d:|� �d;g� | jd<d=gd d>� | jd?d@dA� | jdBdCdDdE� | jdFdGdA� | jdHdIdA� | jdJdK� | �dL��r|| j| jdM dNdA� | j| jdO dPdA� | �dQ� | �dR�}| j|dS| j
dT� | �� | �� d S )UNFz/etc/foreman/database.yml�rzUTF-8)�encodingr �#zproduction:Tz\s+host:\s+\S+� z\s+password:\s+\S+� �"�'���r Zforeman_production_logZforeman_tasks_configZforeman_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.rbZhostname�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 localhostz/root/ssl-buildz/usr/share/foreman/config/hooks)� 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=ANONYMOUSzqpid-stat_-q)�suggest_filenamezhammer pingZhammer_ping�x )Ztags�timeoutzsystemctl list-units dynflow*Z
dynflow_unitsz!"system-dynflow\x2dsidekiq.slice"Zdynflow_sidekiq_statuszdynflow-sidekiq@*)Zunitsr zgc-statszpumactl_gc-statsZstatsZ
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 DESCZforeman_db_tables_sizes)r �env)�open�read�
splitlines�
startswithr �split�dbhost�dbpasswd�IOError�endswithr! �
add_file_tagsZadd_forbidden_path�exec_cmd�stripZ
add_copy_spec� apachepkg�add_cmd_outputZadd_dir_listingZadd_service_statusZadd_journal�
get_option�pumactl�build_query_cmd�collect_foreman_db�collect_proxies) �selfZproduction_scopeZ
foreman_db�dfileZ
foreman_lines�lineZ _hostnameZ_host_f�_cmd� r9 �</usr/lib/python3/dist-packages/sos/report/plugins/foreman.py�setup( s�
�
��������������
��z
Foreman.setupc C s | � d�� d�}t|�}d}d|� d�}d|� d�}d|� d�}d |� d�}d
}|ddd
dd|dd�} ||||d�}
| �� D ](\}}| �|�}
| j|
|dd| jd� q|| �d�}|
�� D ]B\}}d}|dkr�|r�d}| j|d|d�}
| j|
|dd| jd� q�dS )z% Collect foreman db and dynflow data r
z 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�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 100zselect * 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 logsz2select name,url,download_policy from smart_proxies)Zforeman_settings_tableZforeman_schema_migrationsZforeman_auth_tableZdynflow_schema_infoZaudits_table_countZlogs_table_countZfact_names_prefixesZ
smart_proxies)�foreman_tasks_tasksZdynflow_execution_plansZdynflow_actionsZ
dynflow_stepsiX �d )r r r r! z
dynflow-utils�psqlr<