PostgreSQL pg_top pgcenter - 实时top类工具

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介: postgresql pg_top

背景
PostgreSQL 的统计信息、实时会话信息、操作系统状态信息等汇总,统计,展示。

https://www.postgresql.org/docs/devel/static/monitoring-stats.html

1 pgcenter
https://github.com/lesovsky/pgcenter

Command-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
2 pg_top
https://git.postgresql.org/gitweb/?p=pg_top.git;a=shortlog;h=refs/heads/master

                                                              pg_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

  1. Although I have taken steps to insure that pg_top makes
  2. 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

  1. For an official statement, please refer to the file "LICENSE"
  2. 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://git.postgresql.org/gitweb/?p=pg_top.git;a=shortlog;h=refs/heads/master

https://github.com/lesovsky/pgcenter

man pg_top/share/man/man1/pg_top.1

https://www.postgresql.org/docs/devel/static/monitoring-stats.html
转自阿里云德哥

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
30天前
|
关系型数据库 MySQL
elasticsearch对比mysql以及使用工具同步mysql数据全量增量
elasticsearch对比mysql以及使用工具同步mysql数据全量增量
21 0
|
1月前
|
关系型数据库 Java 数据库连接
PostgreSQL从小白到高手教程 - 第47讲:JMETER工具使用
PostgreSQL从小白到高手教程 - 第47讲:JMETER工具使用
108 3
|
2月前
|
关系型数据库 MySQL 数据库
rds迁移数据迁移工具选择
rds迁移数据迁移工具选择
69 3
|
4月前
|
SQL 关系型数据库 MySQL
MySQL——MySQL的图形化界面工具安装与使用
MySQL——MySQL的图形化界面工具安装与使用
150 0
|
1月前
|
关系型数据库 MySQL 数据库
rds安装数据库客户端工具
安装阿里云RDS的数据库客户端涉及在本地安装对应类型(如MySQL、PostgreSQL)的客户端工具。对于MySQL,可选择MySQL Command-Line Client或图形化工具如Navicat,安装后输入RDS实例的连接参数进行连接。对于PostgreSQL,可以使用`psql`命令行工具或图形化客户端如PgAdmin。首先从阿里云控制台获取连接信息,然后按照官方文档安装客户端,最后配置客户端连接以确保遵循安全指引。
86 1
|
4月前
|
SQL 关系型数据库 MySQL
postgresql|数据库|MySQL数据库向postgresql数据库迁移的工具pgloader的部署和初步使用
postgresql|数据库|MySQL数据库向postgresql数据库迁移的工具pgloader的部署和初步使用
118 0
|
3月前
|
关系型数据库 测试技术 数据库
`pg_rewind` 是 PostgreSQL 数据库的一个工具,用于将一个数据库集群回退到指定的时间点
pg_rewind 是 PostgreSQL 数据库的一个工具,用于将一个数据库集群回退到指定的时间点。这对于恢复数据或解决某些问题非常有用。 简单来说,如果你有一个 PostgreSQL 数据库集群并且你知道在某个时间点它是健康的,但之后出现了问题,你可以使用 pg_rewind 来将数据库回退到那个时间点,从而恢复到已知的、健康的、一致的状态。 使用 pg_rewind 的基本步骤如下: 确定基准时间:首先,你需要确定一个基准时间点,知道在该时间点上数据库是健康的。 备份当前数据库:在执行 pg_rewind 之前,确保你已经备份了当前的数据库。 执行 pg_rewind:使用
|
3月前
|
存储 安全 关系型数据库
4个MySQL优化工具AWR,帮你准确定位数据库瓶颈!
4个MySQL优化工具AWR,帮你准确定位数据库瓶颈!
43 0
|
3月前
|
数据可视化 关系型数据库 MySQL
使用Navicat工具创建MySQL数据库连接
使用Navicat工具创建MySQL数据库连接
|
4月前
|
关系型数据库 数据库 PostgreSQL
postgresql|数据库迁移|ora2pg工具的web界面介绍
postgresql|数据库迁移|ora2pg工具的web界面介绍
45 0