id':ddlmZmZmZmZmZmZddlmZddl m Z ddl m Z GddeZ Gdde eeZGd d e eeZy ) )Plugin RedHatPlugin SCLPlugin DebianPlugin UbuntuPlugin PluginOpt)quote)match) is_executablecxeZdZdZdZdZdZdZeddd ed d d ed d d gZ dZ dZ ddZ dZ y)Foremanz$Foreman/Satellite systems managementforemani)sysmgmt)rmonthsz#number of months for dynflow output)defaultdesc proxyfeaturesFz!collect features of smart proxiespuma-gczcollect Puma GC statsz/pumactl %s -S /usr/share/foreman/tmp/puma.statec d}d|_d|_ tdjj D]}|r|ddk(r|j drd}"|r$t d |r|jd |_|r$t d |r|jd |_|j d rd} |jj d r|jjd s6|jj dr/|jjdr|jd d|_d|ji|_ |jddddd|jddg|jdd}|j}|jdd}|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)dDE|j+dFr |j%|j,dGzdH<|j%|j,dIzdJ<|j%dK|j/dL}|j%|dM|jNdO|j+dPz}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+dfr|j/dgdh}|j||ji}|djdk(rL|dj d dD]3}|jdk}dl|d z}|j%||ddmdno5|j5dpdqgy#t$rYwxYw)rNF localhostz/etc/foreman/database.ymlr#z production:Tz\s+host:\s+\S+rz\s+password:\s+\S+ "' PGPASSWORDforeman_production_logforeman_tasks_configforeman_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/{}*/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 localhostzqpid-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_-qsuggest_filenamez hammer ping hammer_ping)tagszsystemctl list-units dynflow* dynflow_unitsz!"system-dynflow\x2dsidekiq.slice"dynflow_sidekiq_statuszdynflow-sidekiq@*)unitsrzgc-statszpumactl_gc-statsstats 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 DESCforeman_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_sourceszselect 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 %szselect 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 %szselect 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 %szWITH 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_tableforeman_auth_tabledynflow_schema_infoaudits_table_countlogs_table_countfact_names_prefixes smart_proxiesz!select * from foreman_tasks_tasks)foreman_tasks_tasksdynflow_execution_plansdynflow_actions dynflow_stepsiXd)r'timeoutr%r0z dynflow-utilspsqlr8z /usr/libexec/psql-msgpack-decode)csvbinaryrz"select name,url from smart_proxies)r?)r0status,z\curl -s --key /etc/foreman/client_key.pem --cert /etc/foreman/client_cert.pem %s/v2/featuressmart_proxies_features )r'subdirr= http_proxy https_proxy)dbhostdbpasswdopenread splitlines startswithr splitIOErrorendswithr0 add_file_tagsadd_forbidden_pathexec_cmdstrip add_copy_specformat apachepkgadd_cmd_outputadd_service_status add_journal get_optionpumactlbuild_query_cmdr is_installed add_env_var)selfproduction_scopeline _hostname_host_f_cmdrscmdauthcmddyncmd dactioncmd dstepscmd factnamescmd foremandb foremancsvtabledynutilsdynr@proxiesproxys >@KKM -tAw#~??=1'+$#.?(F"&**,q/DK#.CT(J$(JJLODMs+',$ -$ MM $ $S )dmm.D.DS.I MM $ $T *t}}/E/Ed/K MM!B/DM!$--0 1I,B'=,     # ,!  MM*-h7 OO% -- .x8--/  - 0 7 7 G      $ % " 4 8 1 ) . + 2 2 4 ) # * *4>> : @ G G ? F F % , ,T^^ <  # #DNN 3  % %dnn 5-  2  ) * . 0 $ & 6  )  ' $    0,   M > ;-<  >  D1I  K 23 ??9 %    z 91C  E DLL72-<  > ;<##   D3L $  *tx88  $  6   /27v ? DV}   CFm     '+")#F"? ;#/2  $G'-)&   =E'' %(89D   uc*-488  = =$$_5 =CF++;'' 3T/5(7D   sC*-488  =  = ??? +''(L,0(2DmmDdhhm7Gx A%$X.99;AB?4E!KK,E,.3Ah7D''uQx/G02(4 4 , 67I   sB&U9U UUcJ|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 ACHIEMeEl;;;c|jd|jzdd|jddd|jdddy) 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 rspostproczForeman.postproc0sT  6 G F    - D    1 D  rxN)Fr>)__name__ __module__ __qualname__ short_desc plugin_nameplugin_timeoutprofilespackagesr option_listr\rtr]r{rxrsr r sh7JKNHH(A< >/5: <)U. 0 K@G{8z < rxr c"eZdZdZfdZxZS) RedHatForemanhttpdc|jddi|jjdk(rtdrd|jz|_t t ||jddd y) Nz"/usr/share/foreman/.ssh/ssh_configssh_foreman_configsclzscl enable tfm '%s'tfmzgem listzscl enable tfm gem listr&) rQpolicy dist_versionr r\superrrtadd_cmd_output_scl)r` __class__s rsrtzRedHatForeman.setupGsr  02F  ;; # # % *}U/C04<<?DL mT(* z1J  Lrx)r|r}r~rWrt __classcell__)rs@rsrrCsI L LrxrceZdZdZy) DebianForemanapache2N)r|r}r~rWrrxrsrrVsIrxrN)sos.report.pluginsrrrrrrpipesr rer sos.utilitiesr r rrrrxrsrsKGG'jfj` LGY L&G\<rx