Add posgresql_diagnostic/system.sh
This commit is contained in:
parent
7051547e25
commit
91f8a13bee
19
posgresql_diagnostic/system.sh
Normal file
19
posgresql_diagnostic/system.sh
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Общее количество подключений
|
||||||
|
psql -U postgres -c "SELECT count(*) FROM pg_stat_activity;"
|
||||||
|
|
||||||
|
# Использование лимита подключений
|
||||||
|
psql -U postgres -c "SELECT count(*), max_connections FROM pg_stat_activity, (SELECT setting::int as max_connections FROM pg_settings WHERE name='max_connections') mc GROUP BY max_connections;"
|
||||||
|
|
||||||
|
# Проверка системных ресурсов
|
||||||
|
top -p $(pgrep -d',' -f "postgres:")
|
||||||
|
free -h
|
||||||
|
iostat -x 1
|
||||||
|
|
||||||
|
# Следим за новыми подключениями с определенного IP
|
||||||
|
tail -f postgresql-Tue.log | grep "10.7.90.30"
|
||||||
|
|
||||||
|
# Или более детальный мониторинг
|
||||||
|
tail -f postgresql-Tue.log | awk '/10.7.90.30/ {print strftime("%Y-%m-%d %H:%M:%S"), $0}'
|
||||||
|
|
||||||
|
# Считаем частоту подключений
|
||||||
|
grep "10.7.90.30" postgresql-Tue.log | grep "connection received" | wc -l
|
||||||
Loading…
x
Reference in New Issue
Block a user