Thursday, July 28, 2016

Monitor Postgres Guide line For postgresql adminstration:

+ To track service of postgres :
    - ps -ef | grep postgres
+ top :
    - top -c -u postgres

+ iostat : Check device status
    - iostat 2 5

+ netstat : information about current network connection
    - netstat -an | grep LISTEN
    - netstat -an | grep LISTEN | grep tcp
    - netstat -an | grep LISTEN | grep PGSQL

+ pg_stat_activilty  : to track number of connections, query activity,...

+ pg_stat_replication : to monitor postgres clustering

+ pg_stat_archvier : to monitor archive files , log files,....

+ pg_stat_bgwriter: checking perform : like check_piont time. ...

+ pg_stat_database : to check status for databases,....

+ pg_stat_all_tables : to check status for tables,....

+ pg_stat_all_indexes : to track indexes,...

+ pg_stat_system_indexes : to check status for indexes,...

+ pg_stat_user_indexes : to track user indexes,....

+ pg_stat_database_conflicts : to check status for conflic like tables,....

**** Useful Queries ****
+ Show all current connections:
    select * from pg_stat_activity;
+ Show all waiting queries:
    select * from pg_stat_activity where waiting='t';
+ Show top 3 longest running queries:
    select datname,usename,now() - query_start as query_runtime from pg_stat_activity order by 3 desc limit 3;

+ du -hcs data/* : Disk space usage

+ Huge Pages
    # grep ^Huge /proc/meminfo


No comments:

Post a Comment