first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
25
数据库/postgresql/monitor.sh
Normal file
25
数据库/postgresql/monitor.sh
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Edit 2020/04/16
|
||||
|
||||
# sql script
|
||||
# https://blog.csdn.net/Hehuyi_In/article/details/95893869
|
||||
# example:
|
||||
# sql="select count(*) from pg_stat_activity where state='idle in transaction';"
|
||||
# message="处于空闲状态的会话"
|
||||
sql=""
|
||||
message=""
|
||||
|
||||
user=postgres
|
||||
source /home/$user/.bash_profile
|
||||
|
||||
|
||||
if [ $UID -ne `id -u $user` ];then
|
||||
echo -e "\033[31;1mNot Manager of PostgreSQL! \033[0m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get value
|
||||
valuse=`psql postgres -c "$sql" | sed -n '3p' | sed 's/ //g'`
|
||||
|
||||
echo "$message=$valuse"
|
Loading…
Add table
Add a link
Reference in a new issue