first commit

This commit is contained in:
iProbe 2022-10-18 16:59:37 +08:00
commit ba848e218d
1001 changed files with 152333 additions and 0 deletions

View 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"