19 lines
912 B
Bash
19 lines
912 B
Bash
# Общее количество подключений
|
||
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 |