PostgreSQL pg_top pgcenter - 实时top类工具

本文涉及的产品
RDS SQL Server Serverless,2-4RCU 50GB 3个月
推荐场景:
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云原生数据库 PolarDB 分布式版,标准版 2核8GB
简介: 标签PostgreSQL , pg_top , pgcenter背景PostgreSQL 的统计信息、实时会话信息、操作系统状态信息等汇总,统计,展示。https://www.postgresql.

标签

PostgreSQL , pg_top , pgcenter


背景

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

相关产品

  • 云原生数据库 PolarDB
  • 云数据库 RDS PostgreSQL 版