a >hu@sjddlZddlmZmZmZmZmZddlmZGdddeZ Gddde eZ Gdd d e eeZ dS) N)Plugin UbuntuPlugin DebianPlugin RedHatPlugin PluginOpt)findc @seZdZdZdZdZdZdZedddd ed d e d d edde ded edde dd edde dd edde dd gZ dddZ ddZ dS) PostgreSQLzPostgreSQL RDBMS postgresql)Zservices)r zpostgresql-commonz' (password visible in process listings)pghomez/var/lib/pgsqlzpsql server home directory)defaultdescusernameZpostgreszusername for pg_dump)r Zval_typer passwordzpassword for pg_dumpdbnamez"database name to dump with pg_dumpdbhostz.database hostname/IP address (no unix sockets)dbporti8zdatabase server listening port pgdump.tarc Cs|dr|dsdtjvr|dr8|dtjd<|drxd|dd|dd|d d |d}nd |dd |d}|j||d d dn|jd|ddS)z- Extract PostgreSQL database into a tar file rrZ PGPASSWORDrz pg_dump -U r z -h z -p rz -w -F t zpg_dump -C -U Tr)Zsuggest_filenameZbinaryZ sizelimitz-password must be supplied to dump a database.z3WARN: password must be supplied to dump a database.N) get_optionosenvironadd_cmd_outputZsoslogZwarningZ add_alert)selffilenamecmdrA/usr/lib/python3.9/site-packages/sos/report/plugins/postgresql.py do_pg_dump0s0   zPostgreSQL.do_pg_dumpcCs"||d|ddS)Nzdu -sh r )rrrrrrrsetupNszPostgreSQL.setupN)r)__name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZpackagesZpassword_warn_textrstrintZ option_listrrrrrrrs4 rcseZdZfddZZS)RedHatPostgreSQLc szt|d}|g}|D]V}td|D]}||q,td|D]}||qFdD]}|||d|qZqdS)Nr z*.logz*.conf)Z PG_VERSIONzpostmaster.optsdata)superrrr add_copy_specZ path_join)rr dirsZ_dirrfile __class__rrrUs    zRedHatPostgreSQL.setupr r!r"r __classcell__rrr+rr%Ssr%cseZdZfddZZS)DebianPostgreSQLcst|gddS)N)z/var/log/postgresql/*.logz/etc/postgresql/*/main/*.confz%/var/lib/postgresql/*/main/PG_VERSIONz*/var/lib/postgresql/*/main/postmaster.opts)r'rr(rr+rrrks zDebianPostgreSQL.setupr-rrr+rr/isr/) rZsos.report.pluginsrrrrrZ sos.utilitiesrrr%r/rrrrs  =