标簽
PostgreSQL , pg_top , pgcenter
https://github.com/digoal/blog/blob/master/201810/20181003_01.md#%E8%83%8C%E6%99%AF 背景
PostgreSQL 的統計資訊、實時會話資訊、作業系統狀态資訊等彙總,統計,展示。
https://www.postgresql.org/docs/devel/static/monitoring-stats.htmlhttps://github.com/digoal/blog/blob/master/201810/20181003_01.md#1-pgcenter 1 pgcenter
https://github.com/lesovsky/pgcenterCommand-line admin tool for observing and troubleshooting Postgres.
wget https://github.com/lesovsky/pgcenter/releases/download/v0.5.0/pgcenter.linux-amd64.tar.gz
pgCenter is a command line admin tool for PostgreSQL.
Usage:
pgcenter [flags]
pgcenter [command] [command-flags] [args]
Available commands:
config configures Postgres to work with pgcenter
record record stats to file
report make report based on previously saved statistics
top top-like stats viewer
Flags:
-?, --help show this help and exit
--version show version information and exit
Use "pgcenter [command] --help" for more information about a command.
Report bugs to https://github.com/lesovsky/pgcenter/issues
./pgcenter -p 1921 top
https://github.com/digoal/blog/blob/master/201810/20181003_01.md#2-pg_top 2 pg_top
https://git.postgresql.org/gitweb/?p=pg_top.git;a=shortlog;h=refs/heads/masterpg_top
Version 3.7.0
Mark Wong
and a cast of ... a few
pg_top is 'top' for PostgreSQL. It is derived from Unix Top. Similar to top,
pg_top allows you to monitor PostgreSQL processes. It also allows you to:
* View currently running SQL statement of a process.
* View query plan of a currently running SELECT statement.
* View locks held by a process.
* View user table statistics.
* View user index statistics.
CAVEAT: version 3 of pg_top has internal commands that kill and renice
processes. Although I have taken steps to insure that pg_top makes
appropriate checks with these commands, I cannot guarantee that these
internal commands are totally secure. IF YOU INSTALL pg_top SET-USER-ID
TO ROOT, YOU DO SO AT YOUR OWN RISK! I realize that some operating
systems will require pg_top to run setuid root, and I will do everything
I can to make sure that pg_top is a secure setuid program.
To compile and install "pg_top", read the file "INSTALL" and follow the
directions and advice contained therein.
If you make any kind of change to "pg_top" that you feel would be
beneficial to others who use this program, or if you find and fix a bug,
please send the change to the pg_top mailing list.
In order to monitor a remote database, the pg_proctab extension needs to be
created on the database to be monitored. Any operating system that pg_proctab
supports can be monitored remotely on any operating system. See details for
pg_protab here:
http://pgxn.org/dist/pg_proctab/
Be sure to read the FAQ enclosed with the distrubution. It contains
answers to the most commonly asked questions about the configuration,
installation, and operation of pg_top.
AVAILABILITY
Project home page:
http://ptop.projects.postgresql.org/
If you have git, you can download the source code:
git clone git://git.postgresql.org/git/pg_top.git
GRATITUDE
Selena Deckelmann & Gabrielle Roth, and the beer & free wi-fi at County Cork
pub in Portland, OR, USA.
LICENSE
pg_top is distributed free of charge under the same terms as the BSD
license. For an official statement, please refer to the file "LICENSE"
which should be included with the source distribution.
AUTHOR
Mark Wong
yum install -y cmake3
su - postgres
https://git.postgresql.org/gitweb/?p=pg_top.git;a=shortlog;h=refs/heads/master
tar -zxvf pg_top-72088ce.tar.gz
cd pg_top-72088ce
alias cmake=cmake3
cmake -DDESTDIR=/var/lib/pgsql/pg_top
make install
pg_top monitors a PostgreSQL database cluster.
Usage:
pg_top [OPTION]... [NUMBER]
Options:
-b, --batch use batch mode
-c, --show-command display command name of each process
-C, --color-mode turn off color mode
-i, --interactive use interactive mode
-I, --hide-idle hide idle processes
-n, --non-interactive use non-interactive mode
-o, --order-field=FIELD select sort order
-q, --quick-mode modify schedule priority
usable only by root
-r, --remote-mode activate remote mode
-s, --set-delay=SECOND set delay between screen updates
-T, --show-tags show color tags
-u, --show-uid show UID instead of username
-V, --version output version information, then exit
-x, --set-display=COUNT set maximum number of displays
exit once this number is reached
-z, --show-username=NAME display only processes owned by given
username
-?, --help show this help, then exit
Connection options:
-d, --dbname=DBNAME database to connect to
-h, --host=HOSTNAME database server host or socket directory
-p, --port=PORT database server port
-U, --username=USERNAME user name to connect as
-W, --password force password prompt
https://github.com/digoal/blog/blob/master/201810/20181003_01.md#%E5%8F%82%E8%80%83 參考
man pg_top/share/man/man1/pg_top.1