a G%@iH@snddlmZddlmZddlmZmZmZmZm Z GdddeZ Gddde eZ Gdd d e eeZ d S) )match)quote)Plugin RedHatPlugin DebianPlugin UbuntuPlugin PluginOptc@seZdZdZdZdZdZdZdZdZ dZ d Z d d iZ e d d d de dddde dddde ddddgZdZddZddZddZddZd$d d!Zd"d#ZdS)%Foremanz$Foreman/Satellite systems managementforemani)Zsysmgmt)r NZ localhosti8 PGPASSWORDdaysz!number of days for dynflow output)defaultZdesc proxyfeaturesFz!collect features of smart proxiespuma-gczcollect Puma GC stats cvfiltersz'collect content view filters definitionz/pumactl %s -S /usr/share/foreman/tmp/puma.statec Csd}zd}t|ddd}|}Wdn1s:0Y|D]}|rH|ddkr^qH|drnd }qH|rtd |r|d |_|rtd |r|d |_|rtd |r|d |_|dsHd}qHWnt yYn0|jdr|j ds |jdr0|j dr0|jd d|_d|ji|_ | ddddd| ddg|dd}|}|dd}|}|jdd|jdgdd |d!d"d#d$d%d&d'd(d)d*d+d,d-d.d|jd/d|jd0d|jd1d2|jd3d2|jd4d|jd5g|d6d7d8d9d:d;|d;|d|jd?d@dA|jdBdCdDdE|jdFdGdA|jdHdIdA|jdJdK|dLr|j|jdMdNdA|j|jdOdPdA|dQ|dR}|j|dS|j dT|||dUr|dS)VNFz/etc/foreman/database.ymlrzUTF-8)encodingr#z production:Tz\s+host:\s+\S+z\s+port:\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.rbhostnameoutputz hostname -fz/var/log/foreman/production.logz /var/log/z*/foreman-ssl_*_ssl.logi) sizelimitz /etc/foreman/z/etc/sysconfig/foremanrz/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) recursivezqpid-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_filenamez hammer pingZ hammer_pingx)tagstimeoutzsystemctl list-units dynflow*Z dynflow_unitsz!"system-dynflow\x2dsidekiq.slice"Zdynflow_sidekiq_statuszdynflow-sidekiq@*)Zunitsrzgc-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 envr)openread splitlines startswithrsplitdbhostdbportdbpasswdIOErrorendswithr$ add_file_tagsZadd_forbidden_pathexec_cmdstripZ add_copy_spec apachepkgadd_cmd_outputZadd_dir_listingZadd_service_statusZ add_journal get_optionpumactlbuild_query_cmdcollect_foreman_dbcollect_proxiescollect_cv_filters) selfZproduction_scopeZ foreman_dbdfileZ foreman_lineslineZ _hostnameZ_host_f_cmdr>>/usr/lib/python3.9/site-packages/sos/report/plugins/foreman.pysetup+s*                     z Foreman.setupc Cs |dd}t|}d}d|d}d|d}d|d}d |d}d }d } d } |d d|ddd| | d } ||||d} | D](\} }||}|j|| dd|jdq|d}| D]B\}}d}|dkr|rd}|j|d|d}|j||dd|jdqdS)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 asczselect 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 asczselect 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 zselect 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 zSELECT 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 DESCzWITH 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 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) 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_stepsXd)r r#rr$z dynflow-utilspsqlrAz /usr/libexec/psql-msgpack-decodeT)csvbinaryN)r4ritemsr6r3r$Z is_installed)r:r intervalZscmdZdtaskcmdZdyncmdZ dactioncmdZ dstepscmdZ subnetscmdZ factnamescmdZsmartcmdZ foremandbZ foremancsvtablevalr=ZdynutilsZdynrFr>r>r?r7sl      zForeman.collect_foreman_dbcCs|dr~|jddd}|j||jd}|ddkr~|dd d D]4}|d }d |d d }|j||ddddqHd S)z Collect foreman proxies rz"select name,url from smart_proxiesT)rE)r$statusrrrN,zNcurl -s --key /etc/foreman/client_key.pem --cert /etc/foreman/client_cert.pem z /v2/featuresZsmart_proxies_features )r subdirr#)r4r6r0r$r'r)r3)r:r=Zproxiesproxyr>r>r?r80s    zForeman.collect_proxiesc Cshd}d}d}d}d}d}d}|||||||d}|D]*\} } || } |j| | d d d |jd q8d S)z6 Collect content view filters definition if requested zselect 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)Zkatello_cv_filtersZkatello_cv_package_rulesZkatello_cv_group_rulesZkatello_cv_errata_rulesZkatello_cv_module_rulesZkatello_cv_docker_rulesZkatello_cv_deb_rulesZcontent_view_filtersrBrC)r rNr#rr$N)rGr6r3r$) r:Zcv_filters_cmdZcv_pkg_rules_cmdZcv_group_rules_cmdZcv_errata_rules_cmdZcv_module_rules_cmdZcv_docker_rules_cmdZcv_deb_rules_cmdZ filter_tablesrIqueryr=r>r>r?r9Ds8  zForeman.collect_cv_filtersrDcCs,|rd|d}d}|||j|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)z8%s --no-password -h %s -p %s -U foreman -d foreman -c %s)r*r+r)r:rPrErFZ_dbcmdr>r>r?r6xs zForeman.build_query_cmdcCs:|ddd|ddd|dg|ddd 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_subr:r>r>r?postprocs$zForeman.postproc)FrD)__name__ __module__ __qualname__Z short_descZ plugin_nameZplugin_timeoutZprofilesZpackagesr2r*r+r,r$rZ option_listr5r@r7r8r9r6rRr>r>r>r?r s> m4 r cs eZdZdZfddZZS) RedHatForemanZhttpdcs&|ddit|ddS)Nz"/usr/share/foreman/.ssh/ssh_configZssh_foreman_configzgem list)r/superr@r3rQ __class__r>r?r@s  zRedHatForeman.setup)rSrTrUr2r@ __classcell__r>r>rXr?rVsrVc@seZdZdZdS) DebianForemanZapache2N)rSrTrUr2r>r>r>r?r[sr[N) rerZshlexrZsos.report.pluginsrrrrrr rVr[r>r>r>r? s