一.linux 監控數據庫活動
$ ps auxww | grep ^postgrespostgres 3424 0.0 1.2 42708 26588 ? Ss Jan29 0:00 postgres: writer process
postgres 3425 0.0 0.0 42576 1284 ? Ss Jan29 0:00 postgres: wal writer process
postgres 3426 0.0 0.0 43364 1972 ? Ss Jan29 0:01 postgres: autovacuum launcher process
postgres 3427 0.0 0.0 14600 1568 ? Ss Jan29 0:01 postgres: stats collector process
postgres 3425 0.0 0.0 42576 1284 ? Ss Jan29 0:00 postgres: wal writer process
postgres 3426 0.0 0.0 43364 1972 ? Ss Jan29 0:01 postgres: autovacuum launcher process
postgres 3427 0.0 0.0 14600 1568 ? Ss Jan29 0:01 postgres: stats collector process
(調用 ps 的方法因不同的平臺而略有不同, 顯示出來的細節也有一些區別.這個例子來自一個最近的 Linux 系統.) 這里顯示出來的第一個進程時 postmaster,主服務進程. 給它顯示的命令參數和運行它的時候給它的是一樣的. 下面兩個進程實現統計收集器,我們將在下一節里詳細描述它. (如果你設置了系統不啟動統計收集器,那么它們不會出現.) 剩下的進程每個都是一個服務器進程,每個處理一個客戶的聯接. 每個這樣的進程都用下面的形式設置其命令行顯示∶
postgres: user database host activity
在該客戶端聯接的生命期中,用戶,數據庫,和聯接源主機項都保持不變,
膽識活躍性指示符會變化.活躍性可以是 idle (也就是說,
等待客戶端的命令),idle in transaction (在一個BEGIN
塊里等待用戶),或者一個命令類型名,比如 SELECT.
同樣,如果服務器目前正在等待一個其它服務器進程持有的鎖的時候,
會在信息后面附加 waiting.在上面的例子中,我們可以
推出∶進程 1003 正在等待 1016完成其事務,這樣才能施放一些鎖或者其它
什么東西.
http://man.ddvip.com/database/PostgreSQL80zhref/index.html