pg_activityPostgreSQL 服務(wù)器活動(dòng)監(jiān)控
pg_activity 是一個(gè)用于 PostgreSQL 服務(wù)器活動(dòng)監(jiān)視的命令行工具。
使用
pg_activity可以在本地或遠(yuǎn)程工作。在本地工作的情況下,為了獲得足夠的權(quán)限來顯示系統(tǒng)信息,運(yùn)行 pg_activity 的系統(tǒng)用戶必須是運(yùn)行 postgresql 服務(wù)器的同一用戶(默認(rèn)是 postgres),或者擁有更多權(quán)限的用戶,比如root。否則,pg_activity 就會(huì)回退到退化模式而不顯示系統(tǒng)信息。同樣的,用來連接數(shù)據(jù)庫(kù)的 PostgreSQL 用戶必須是超級(jí)用戶。
sudo -u postgres pg_activity -U postgres
注意事項(xiàng)
pg_activity 報(bào)告的 SQL 查詢文本的長(zhǎng)度依賴于 PostgreSQL 參數(shù) track_activity_query_size,默認(rèn)值是 1024 (以字節(jié)表示)。如果你的 SQL 查詢文本看起來很短,你應(yīng)該增加 track_activity_query_size。
選項(xiàng)
pg_activity [options]
Options:
--version Show program's version number and exit
-U USERNAME, --username=USERNAME
Database user name (default: "postgres").
-p PORT, --port=PORT Database server port (default: "5432").
-h HOSTNAME, --host=HOSTNAME
Database server host or socket directory (default:
"localhost").
-d DBNAME, --dbname=DBNAME
Database name to connect to (default: "postgres").
--blocksize=BLOCKSIZE Filesystem blocksize (default: 4096).
--rds Enable support for AWS RDS.
--output=FILEPATH Store running queries as CSV.
--help Show this help message and exit.
--no-db-size Skip total size of DB.
--min-duration Don't display queries with smaller than specified
duration (in seconds).
--verbose-mode=VERBOSE_MODE
Queries display mode. Values: 1-TRUNCATED,
2-FULL(default), 3-INDENTED
--duration-mode=DURATION_MODE
Duration mode. Values: 1-QUERY(default),
2-TRANSACTION, 3-BACKEND
Display options, you can exclude some columns by using them :
--no-database Disable DATABASE.
--no-user Disable USER.
--no-client Disable CLIENT.
--no-cpu Disable CPU%.
--no-mem Disable MEM%.
--no-read Disable READ/s.
--no-write Disable WRITE/s.
--no-time Disable TIME+.
--no-wait Disable W.
--no-app-name Disable App.評(píng)論
圖片
表情
