-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsdbmonitor
More file actions
executable file
·141 lines (118 loc) · 4.44 KB
/
sdbmonitor
File metadata and controls
executable file
·141 lines (118 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
usage () {
echo "Usage: $(basename $0) [OPTIONS]
--hosts host addresses(hostname:svcname), separated by ',',
for example 'sdb1:11810,sdb2:11810,sdb3:11810',
default:'localhost:11810'
-u username, default:''
-w password, default:''
--cm-service sdbcm's service, default:'11790'
-h, --help print help info"
exit -1;
}
main()
{
localFileName=`basename $0`
filepath=$( cd "$(dirname $0)"; pwd; )
# get the sequoiadb install path
. /etc/default/sequoiadb
SDB=${INSTALL_DIR}/bin/sdb
machineInfo=machineInfo
if [ ! -d ${filepath}/tmp ] ; then
mkdir -p ${filepath}/tmp;
fi
if [ ! -f ${filepath}/tmp/oldInfo.txt ] ; then
touch ${filepath}/tmp/oldInfo.txt;
fi
# cat ${filepath}/script/sdbsnapshot.js > ${filepath}/tmp/temp.js ; cat ${filepath}/conf/alarm.js >> ${filepath}/tmp/temp.js; cat ${filepath}/script/main.js >> ${filepath}/tmp/temp.js;
cat ${filepath}/script/function.js > ${filepath}/tmp/temp.js ;
cat ${filepath}/script/nodeInfo.js >> ${filepath}/tmp/temp.js ;
cat ${filepath}/script/groupInfo.js >> ${filepath}/tmp/temp.js ;
cat ${filepath}/script/printClass.js >> ${filepath}/tmp/temp.js ;
cat ${filepath}/script/node_rw_info.js >> ${filepath}/tmp/temp.js ;
cat ${filepath}/script/splitInfo.js >> ${filepath}/tmp/temp.js ;
cat ${filepath}/script/csstatus.js >> ${filepath}/tmp/temp.js ;
cat ${filepath}/script/session.js >> ${filepath}/tmp/temp.js ;
cat ${filepath}/script/context.js >> ${filepath}/tmp/temp.js ;
cat ${filepath}/conf/alarm.js >> ${filepath}/tmp/temp.js;
cat ${filepath}/script/main.js >> ${filepath}/tmp/temp.js;
# test connect sequoiadb
outputInfo=$(${SDB} -f "${filepath}/tmp/temp.js" -e "var doWhat='test_connect_to_sdb'; var coordHosts='${hosts}'; var sdbuser = '${username}'; var sdbpassword = '${password}';")
if [ a"${outputInfo}" != a"" ] ; then
echo "${outputInfo}"
exit -1;
fi
# get sequoiadb's replicaGroup hostname
outputInfo=$(${SDB} -f "${filepath}/tmp/temp.js" -e "var doWhat='getReplicaGroup'; var coordHosts='${hosts}'; var sdbuser = '${username}'; var sdbpassword = '${password}';")
echo ${outputInfo} > ${filepath}/tmp/hosts.conf
newInfo="";
for line in $(${SDB} -f "${filepath}/tmp/temp.js" -e "var doWhat=\"get_read_write_info\" ; var localHostName='$(hostname)'; var coordHosts='${hosts}'; var sdbuser = '${username}'; var sdbpassword = '${password}';")
do
newInfo=${newInfo}"#"${line}
done
oldInfo=""
if [ -e "${filepath}/tmp/oldInfo.txt" ] ; then
oldInfo=$( cat ${filepath}/tmp/oldInfo.txt )
fi
if [ a"" == a"${oldInfo}" ] ; then
oldInfo=${newInfo};
fi
echo ${oldInfo} | grep "exception" > /dev/null
if [ a"0" == a"$?" ] ; then
oldInfo=${newInfo};
fi
hosts_str=$(cat ${filepath}/tmp/hosts.conf);
machineTimeStamp=$(${SDB} -f "${filepath}/tmp/temp.js" -e "var doWhat='getRemoteTimeStamp'; var coordHosts='${hosts}'; var sdbuser = '${username}'; var sdbpassword = '${password}'; var hosts_str='${hosts_str}'; var cm_service=${cm_service}")
#echo ${machineTimeStamp}
${SDB} -f "${filepath}/tmp/temp.js" \
-e "var doWhat='doMain'; var oldInfo='${oldInfo}'; var newInfo='${newInfo}'; var sdbcmlogInfo='${crashNode}'; var machineTimeStamp='${machineTimeStamp}'; var localHostName='$(hostname)'; var coordHosts='${hosts}'; var sdbuser = '${username}'; var sdbpassword = '${password}';"
echo "${newInfo}" > ${filepath}/tmp/oldInfo.txt
###########################
}
ARGS=$(getopt -o "hu:p:w:" -l "help,hosts:,user:,password:,cm-service:" -n "$(basename $0)" -- "$@")
eval set -- "${ARGS}"
while (($# > 1)) ; do
case ${1} in
-h|--help)
shift;
usage;
;;
--hosts)
shift;
hosts=${1};
shift;
;;
-u|--username)
shift;
username=${1};
shift;
;;
-w|--password)
shift;
password=${1};
shift;
;;
--cm-service)
shift;
cm_service=${1}
shift;
;;
?)
shift;
usage;
;;
--)
shift;
break;
;;
esac
done
hosts=${hosts:-"localhost:11810"}
username=${username:-""}
password=${password:-""}
cm_service=${cm_service:-"11790"}
#echo "**${hosts}**"
#echo "**${username}**"
#echo "**${password}**"
#echo "**${cm_service}**"
main