Created
May 16, 2016 14:06
-
-
Save wagnerpinheiro/2225b4e626cf5159c6ab185d23936225 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for ((;;)) do psql kangaroo postgresql -1 -t -c "SELECT now() as at_date, client_addr, substring(regexp_replace(trim(current_query), E'\r|\n', '', 'g'),0,100) as query, count(*) as qtd, case when count(*) > 50 then 'CRITICAL' else '' END as level FROM pg_locks pl LEFT JOIN pg_stat_activity psa ON pl.pid = psa.procpid where client_port > 0 group by client_addr, substring(regexp_replace(trim(current_query), E'\r|\n', '', 'g'),0,100)" >> /tmp/log_lock.log; sleep 1m; done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment