Package: pg_monitor
# pg_monitorMonitors postgres and produces output usable by monitoring systems such as NagiosChecks for a PostgreSQL serverInstallation :pip install pg_monitorRequirement :python >= 2.7Platform :Windows, LinuxBug report :Please send your bug reports to rugging24@gmail.comoptional arguments:-h, --help            show this help message and exit--port PORT           Port of the database to be accessed. Default: 5432--user USER           Username allowed to access the database. Default:postgres--password PASSWORD   Password of the supplied user. Default:--dbname DBNAME       The name of the database to be accessed. Default:postgres--host HOST           Host of the database. Default: localhost--check               {backends,connections,wals,vacuum,autovacuum,analyze,autoanalyze,table_bloat,index_bloat,blocking,nonblocking,table_size,index_size,database_size,checkpoints,duplicate_indexes,replica_lag}Options to be passed as checks :** backends -->> Checks for the number of clients/connections currentlyconnected to the specified database** connections -->> Tests the databases if they currently acceptconnections or not** wals -->> keeps tab on the number/size of wal files present in the pg_xlogdirectory** vacuum -->> Inspects the tables and produces a report of those that has notbeen vauumed for a given period of time** autovacuum -->> Same as vacuum except that this is triggered by the database'sinternal processes** analyze -->> reports tables that have not been analyzed after a given periodof time** autoanalyze -->> Same as analyze but triggered by the database's internalprocesses.** table_bloat -->> Inspect all tables and reports the bloat percentagewhich is usually a function of vacuum and/or autovacuuming not running regularly** index_bloat -->> Same as table bloat, except for indexes. This could beremedied by reindexing** blocking -->> This checks for locks transactional/relational that are blockingother processes from running.** nonblocking -->> This checks for locks that are running more than the specifiedtype. This normally do not block, but could become a blocking lock if ir runslonger than necessary. In some cases, it is the long running locks that becomethe blocking types** table_size -->> Monitors table sizes** index_size -->> Monitors index sizes** database_size -->> Monitors database sizes** checkpoints -->> Monitors checkpoint frequency** duplicate_indexes -->> Monitors indexes and report duplicates** replica_lag -->> Monitors all replicas connected to a given master--find FIND [FIND ...] Finding partterns in locks--warning WARNING     Values to be considered as warning signs--critical CRITICAL   Values for the critical checksSPECIAL NOTES :Backends 		Default: warning --> 80% , critical --> 85% , of the number of connectionsAccepts both numbers and percentages, and could be combined with an ore.g 20 or 10% is allowedVacuum/analyze		Default: warning --> 1 month.  No default critical value.Accepts : integers with the following unitsday(s), week(s), month(s), year(s)Autoanalyze/autovacuum  Same as for vacuum and analyzeRelation sizes		(tables,indexes and databases). Warning and/or critical value must be providedAccepts integers with the following unitsKB,MB,GB,TB,PBBloat 			Default : warning --> 1GB. No default critical value providedAccepts integers with the following unitsKB,MB,GB,TB,PBLocks			Default : warning --> 1min . No default critical value providedAccepts integers with the smallest units being minute(s)** accept others higher than that, but they don't make anytechnical sence and might not be useful for the purpose oflock monitoring.Replica_lag		Default : warning --> 5. Critical --> 10 . (16MB worth of WAL files)Accepts only integers. Units not allowedWALS 			No defaults. Warning and/or critical value must be providedOnly integer acceptedSAMPLE USAGE :Help 			pg_monitor --helpChecking the number of backendspg_monitor --check=backends --user=monitor --password=secrete --dbname=mydbName --host=hostname*** Depending on your postgres hba settings, password may not be necessary.pg_monitor --check=backends --user=monitor --password=secrete --dbname=mydbName --host=hostname --warning='90 or 85%' --critical='95%'Checking for replica lagpg_monitor --check=replica_lag --user=monitor --password=secrete --dbname=mydbName --host=master,replica1,replica2,replicaN --port=master,replica1,replica2,replicaN