PostgreSQL pg_top pgcenter - 实时top类工具

本文涉及的产品
云原生数据库 PolarDB PostgreSQL 版,标准版 2核4GB 50GB
云原生数据库 PolarDB MySQL 版,通用型 2核8GB 50GB
简介: 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  
AI 代码解读

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  
AI 代码解读

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.  
AI 代码解读

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  
AI 代码解读

-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  
AI 代码解读

-z, --show-username=NAME display only processes owned by given

                        username  
AI 代码解读

-?, --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数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
打赏
0
0
0
0
1
分享
相关文章
MySQL 自动同步开源工具
本文介绍了几种开源工具用于实现 MySQL 数据库的自动同步。
Canal作为一款高效、可靠的数据同步工具,凭借其基于MySQL binlog的增量同步机制,在数据同步领域展现了强大的应用价值
【9月更文挑战第1天】Canal作为一款高效、可靠的数据同步工具,凭借其基于MySQL binlog的增量同步机制,在数据同步领域展现了强大的应用价值
1407 4
MySQL 窗口函数详解:分析性查询的强大工具
MySQL 窗口函数从 8.0 版本开始支持,提供了一种灵活的方式处理 SQL 查询中的数据。无需分组即可对行集进行分析,常用于计算排名、累计和、移动平均值等。基本语法包括 `function_name([arguments]) OVER ([PARTITION BY columns] [ORDER BY columns] [frame_clause])`,常见函数有 `ROW_NUMBER()`, `RANK()`, `DENSE_RANK()`, `SUM()`, `AVG()` 等。窗口框架定义了计算聚合值时应包含的行。适用于复杂数据操作和分析报告。
317 11
MySQL高级篇——性能分析工具
MySQL的慢查询日志,用来记录在MySQL中响应时间超过阀值的语句,具体指运行时间超过long-query_time值的SQL,则会被记录到慢查询日志中。long_query_time的默认值为 10,意思是运行10秒以上(不含10秒)的语句,认为是超出了我们的最大忍耐时间值。它的主要作用是,帮助我们发现那些执行时间特别长的 SOL 查询,并且有针对性地进行优化,从而提高系统的整体效率。当我们的数据库服务器发生阻塞、运行变慢的时候,检查一下慢查询日志,找到那些慢查询,对解决问题很有帮助。
MySQL高级篇——性能分析工具
Hadoop-21 Sqoop 数据迁移工具 简介与环境配置 云服务器 ETL工具 MySQL与Hive数据互相迁移 导入导出
Hadoop-21 Sqoop 数据迁移工具 简介与环境配置 云服务器 ETL工具 MySQL与Hive数据互相迁移 导入导出
252 3
Navicat工具设置MySQL权限的操作指南
通过上述步骤,您可以使用Navicat有效地为MySQL数据库设置和管理用户权限,确保数据库的安全性和高效管理。这个过程简化了数据库权限管理,使其既直观又易于操作。
950 4
推荐一款高颜值的MySQL管理工具:Sequel Pro
推荐一款高颜值的MySQL管理工具:Sequel Pro
234 9

热门文章

最新文章

推荐镜像

更多
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问