加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql的实时监控工具pgcenter介绍

发布时间:2020-12-13 17:01:48 所属栏目:百科 来源:网络整理
导读:最近同事问有没有一款工具可以实时查看postgresql数据库当前的每秒增删改查,翻了一圈,有一款叫pgcenter的工具可以满足需求,而且某些方面更加详细和强大。这款工具目前已经开源,使用也很方便,简介之。 一、环境及下载 OS:Centos 6.6DB:PostgreSQl 9.6g

最近同事问有没有一款工具可以实时查看postgresql数据库当前的每秒增删改查,翻了一圈,有一款叫pgcenter的工具可以满足需求,而且某些方面更加详细和强大。这款工具目前已经开源,使用也很方便,简介之。

一、环境及下载

OS:Centos 6.6
DB:PostgreSQl 9.6
git clone https://github.com/lesovsky/pgcenter

二、安装

需要在/usr/bin下创建可执行文件,需要sudo权限

[root@temp postgres]# upzip pgcenter-master.zip
[root@temp postgres]# cd pgcenter-master
[root@temp postgres]# make
[root@temp postgres]# make install
[root@temp pgcenter-master]# which pgcenter
/usr/bin/pgcenter
[root@temp pgcenter-master]# source /home/postgres/.bash_profile
[root@temp pgcenter-master]# pgcenter -V
pgcenter 0.3.0

三、使用

简单做个压测,看看效果

[postgres@temp ~]$ more test.conf
set id random(1,2000000)
begin;
insert into tbl_kenyon(id,ctime) values(:id,now());
SELECT id FROM tbl_kenyon WHERE id = :id;
end;
[postgres@temp ~]$ pgbench -M simple -r -c 8 -f /home/postgres/test.conf -j 1 -n -T 120 db_kenyon

--开启监控,具体效果图见下
[root@temp ~]# pgcenter db_kenyon postgres

效果图如下,增删改查数每秒会刷新一次:

还有其他的一些监控指标,比如监控表的大小,索引的大小,IO、vacuum、当前进程,等,具体用法见下:

Help for interactive commands - pgcenter version 0.3.0

general actions:
  a,d,i,f,r	  mode: 'a' activity,'d' databases,'i' indexes,'f' functions,'r' replication,s,t,T,v         's' tables sizes,'t' tables,'T' tables IO,'v' vacuum progress,x,X             'x' pg_stat_statements switch,'X' pg_stat_statements menu.
  Left,Right,/,F  'Left,Right' change column sort,'/' change sort desc/asc,'F' set filter.
  C,E,R           config: 'C' show config,'E' edit configs,'R' reload config.
  p                       'p' start psql session.
  l               'l' open log file with pager.
  N,Ctrl+D,W	  'N' add new connection,Ctrl+D close current connection,'W' write connections info.
  1..8            switch between consoles.
subscreen actions:
  B,I,L           'B' iostat,'I' nicstat,'L' logtail.
activity actions:
  -,_             '-' cancel backend by pid,'_' terminate backend by pid.
  >,.             '>' set new mask,'.' show current mask.
  Del,Shift+Del   'Del' cancel backend group using mask,'Shift+Del' terminate backend group using mask.
  A               change activity age threshold.
  G               get report about query using hash.

other actions:,Q             ',' show system tables on/off,'Q' reset postgresql statistics counters.
  z,Z             'z' set refresh interval,'Z' change color scheme.
  space           pause program execution.
  h,F1            show help screen.
  q               quit.

Type 'Esc' to continue.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读