PostgreSQL之鎖監控指令碼
1.pg鎖監控指令碼
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process,
blocked_activity.application_name AS blocked_application,
blocking_activity.application_name AS blocking_application
FROM pg_catalog.pg_locks blocked_locks
JOIN pg_catalog.pg_stat_activity blocked_activity ON blocked_activity.pid = blocked_locks.pid
JOIN pg_catalog.pg_locks blocking_locks
ON blocking_locks.locktype = blocked_locks.locktype
AND blocking_locks.DATABASE IS NOT DISTINCT FROM blocked_locks.DATABASE
AND blocking_locks.relation IS NOT DISTINCT FROM blocked_locks.relation
AND blocking_locks.page IS NOT DISTINCT FROM blocked_locks.page
AND blocking_locks.tuple IS NOT DISTINCT FROM blocked_locks.tuple
AND blocking_locks.virtualxid IS NOT DISTINCT FROM blocked_locks.virtualxid
AND blocking_locks.transactionid IS NOT DISTINCT FROM blocked_locks.transactionid
AND blocking_locks.classid IS NOT DISTINCT FROM blocked_locks.classid
AND blocking_locks.objid IS NOT DISTINCT FROM blocked_locks.objid
AND blocking_locks.objsubid IS NOT DISTINCT FROM blocked_locks.objsubid
AND blocking_locks.pid != blocked_locks.pid
JOIN pg_catalog.pg_stat_activity blocking_activity ON blocking_activity.pid = blocking_locks.pid
WHERE NOT blocked_locks.GRANTED;
指令碼顯示結果:
blocked_pid | blocked_user | blocking_pid | blocking_user | blocked_statement | current_statement_in_blocking_process | blocked_application | blocking_application
-------------+--------------+--------------+---------------+----------------------+---------------------------------------+---------------------+----------------------
63809 | tuser | 90127 | tuser2 | update t1 set id3=1; | update t1 set id3=4; | psql | psql
71865 | pg13 | 63809 | tuser | update t1 set id2=1; | update t1 set id3=1; | psql | psql
(2 rows)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69990629/viewspace-2895861/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【shell】磁碟監控指令碼指令碼
- 監控系統告警指令碼集合指令碼
- Shell 系統資訊監控指令碼指令碼
- centos 監控web站點是否500 指令碼CentOSWeb指令碼
- shell指令碼:監控MySQL服務是否正常指令碼MySql
- 網路卡流量監控指令碼,python實現指令碼Python
- Shell指令碼監控MySQL主從狀態指令碼MySql
- 監控磁碟使用率的shell指令碼指令碼
- 關於前端指令碼異常監控的思考前端指令碼
- shell指令碼監控啟動停止weblogic服務指令碼Web
- 寫了個監控 ElasticSearch 程式異常的指令碼!Elasticsearch指令碼
- 在 Linux 上用 Bash 指令碼監控 messages 日誌Linux指令碼
- 使用Shell指令碼程式監控網站URL是否正常指令碼網站
- zabbix-mongodb監控指令碼(高效能、低佔用)MongoDB指令碼
- 透過shell指令碼監控日誌切換頻率指令碼
- 基於Ping和Telnet/NC的監控指令碼案例分析指令碼
- 11.prometheus監控之黑盒(blackbox)監控Prometheus
- 【MySQL】MHA原始碼之監控檢查(一)MySql原始碼
- 用於自動監控磁碟使用情況的 Shell 指令碼指令碼
- 分享實用監控指令碼:使用Shell檢查程式是否存在指令碼
- 利用 Shell 指令碼來監控 Linux 系統的記憶體指令碼Linux記憶體
- MySQL 5.6大查詢和大事務監控指令碼(Python 2)MySql指令碼Python
- Flume監控之Ganglia
- Kubernetes監控之InfluxDBUX
- PowerShell 指令碼來監控 CPU、記憶體和磁碟使用情況:指令碼記憶體
- 如何用bash shell 指令碼監控 Linux記憶體、磁碟和 CPU?指令碼Linux記憶體
- sqlserver監控指令碼_發現某個等待就發出郵件SQLServer指令碼
- 用 Bash 指令碼監控 Linux 上的記憶體使用情況指令碼Linux記憶體
- Prometheus監控之Blackbox ExporterPrometheusExport
- ORACLE監控之OSW部署Oracle
- PostgreSQL:鎖SQL
- windows 不鎖屏vb指令碼Windows指令碼
- MySQLwwwhj8828com18088045700鎖分析和監控MySql
- Kubernetes監控實踐(2):可行監控方案之Prometheus和SensuPrometheus
- Java監控神器之psi-probe監控Tomcat和應用JavaTomcat
- 用 Linux Shell 指令碼來監控磁碟使用情況併傳送郵件Linux指令碼
- Linux下針對伺服器網路卡流量和磁碟的監控指令碼Linux伺服器指令碼
- PostgreSQL實時健康監控大屏-低頻指標SQL指標