-
Notifications
You must be signed in to change notification settings - Fork 3
/
checkMemcached.sh
executable file
·69 lines (56 loc) · 1.72 KB
/
checkMemcached.sh
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
#!/bin/bash
#
#------------------------------
#
# Import settings
#
# Git branch
. ./settings.sh
# WriteLog() function
. ./timestampLogger.sh
#
#------------------------------
#
# Constants
#
#BUILD_HOME=~/build/CE/platform/build
LONG_DATE=$(date "+%Y-%m-%d_%H-%M-%S")
MEMCACHED_CHECK_LOG_FILE=${OBT_LOG_DIR}/CheckMemcached-${LONG_DATE}.log
tryCount=2
#
#------------------------------
#
# Check the state of Memcached
#
WriteLog "Start Memcached Server check..." "${MEMCACHED_CHECK_LOG_FILE}"
# Check if Memcached installed
if type "memcached" &> /dev/null
then
while [[ $tryCount -ne 0 ]]
do
WriteLog "Try count: ${tryCount}" "${MEMCACHED_CHECK_LOG_FILE}"
memcachedState=$( ps ax | grep ' [m]emcached -d -u root' )
if [[ -z $memcachedState ]]
then
WriteLog "Stoped! Start it! " "${MEMCACHED_CHECK_LOG_FILE}"
memcached -d -u root > /dev/null 2>&1
sleep 20
tryCount=$(( $tryCount-1 ))
continue
else
WriteLog "It is OK! " "${MEMCACHED_CHECK_LOG_FILE}"
break
fi
done
if [[ $tryCount -eq 0 ]]
then
WriteLog "Memcached won't start! Give up and send Email to Agyi! " "${MEMCACHED_CHECK_LOG_FILE}"
# send email to Agyi
echo "Memcached won't start! " | mailx -s "Problem with Memcached" -u $USER ${ADMIN_EMAIL_ADDRESS}
fi
else
WriteLog "Memcached not installed in this sysytem! Give up and send Email to Agyi! " "${MEMCACHED_CHECK_LOG_FILE}"
# send email to Agyi
echo "Memcached not installed in this sysytem! " | mailx -s "Problem with Memcached" -u $USER ${ADMIN_EMAIL_ADDRESS}
fi
WriteLog "End of Memcached Server check." "${MEMCACHED_CHECK_LOG_FILE}"