3 ܓi@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 d ddZ ddZ dS)! PostgreSQLzPostgreSQL RDBMS postgresqlservicespostgresql-commonz' (password visible in process listings)pghomez/var/lib/pgsqlzpsql server home directory)defaultdescusernameZpostgreszusername for pg_dump)r Zval_typerpasswordzpassword for pg_dumpdbnamez"database name to dump with pg_dumpdbhostz.database hostname/IP address (no unix sockets)dbporti8zdatabase server listening port pgdump.tarc Cs|jdr|jdsdtjkr|jdr8|jdtjd<|jdrxd|jdd|jdd|jd d |jd}nd |jdd |jd}|j||d d dn|jjd|jddS)z- Extract PostgreSQL database into a tar file rrZ PGPASSWORDrz pg_dump -U rz -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)selffilenamecmdr /usr/lib/python3.6/postgresql.py do_pg_dump0s   6 zPostgreSQL.do_pg_dumpcCs"|j|jd|jddS)Nzdu -sh r )rrr)rrrrsetupNszPostgreSQL.setupN)r )r r )r)__name__ __module__ __qualname__Z short_descZ plugin_nameZprofilesZpackagesZpassword_warn_textrstrintZ option_listrr rrrrrs&   rcseZdZfddZZS)RedHatPostgreSQLcstj|jd}|g}xj|D]b}xtd|D]}|j|q0Wxtd|D]}|j|qNWx dD]}|j|j|d|qfWq WdS)Nr z*.logz*.conf PG_VERSIONpostmaster.optsdata)r'r()superr rr add_copy_specZ path_join)rr dirsZ_dirrfile) __class__rrr Us    zRedHatPostgreSQL.setup)r!r"r#r __classcell__rr)r.rr&Ssr&cseZdZfddZZS)DebianPostgreSQLcs>tj|jdr |jdn |jd|jdddgdS)NZall_logsz/var/log/postgresql/z/var/log/postgresql/*.logz/etc/postgresql/*/main/*.confz%/var/lib/postgresql/*/main/PG_VERSIONz*/var/lib/postgresql/*/main/postmaster.opts)r*r rr+)r)r.rrr ks    zDebianPostgreSQL.setup)r!r"r#r r/rr)r.rr0isr0) rZsos.report.pluginsrrrrrZ sos.utilitiesrrr&r0rrrrs  =