forked from daily-scripts/shell-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor_postgre.sh
More file actions
24 lines (23 loc) · 847 Bytes
/
monitor_postgre.sh
File metadata and controls
24 lines (23 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# mail xuel@51idc.com
data=`date +%Y-%M-%d" "%H:%m`
netstat -lntup|grep 5432 && ps -ef|grep postmaster
if [ $? -eq 0 ];then
for IP in 172.17.10.188 172.17.10.189
do
/usr/bin/psql -h 172.17.10.190 -p 5432 -U repl -d postgres --command "select * from pg_stat_replication"|grep $IP
if [ "$?" != "0" ];then
echo
"postgresql master-slave status is error! please login check!"|mail -r
"xuel@51idc.com" -s "postgresql master-slave status is error"
xuel@51idc.com \
&& echo "$data postgresql postgresql master-slave status is error!">>/var/log/postgresql-error.log
fi
done
else
echo
"postgresql master-slave status is error! please login check!"|mail -r
"xuel@51idc.com" -s "postgresql master-slave status is error"
xuel@51idc.com \
&& echo "$data postgresql postgresql master-slave status is error!">>/var/log/postgresql-error.log
fi