-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslhdailyrestart
173 lines (121 loc) · 4.97 KB
/
slhdailyrestart
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
#SCRIPT BY KANISHKA
#NOTE-chnage permission 777 log.txt
{
echo "Sri lankan shedule restart started at $(date)" > /rezsystem/rezadmin/slh_daily_restart_log/log.txt
#change user to rezuser
su - rezuser<< 'EOF'
echo $(whoami)
if [ `pgrep java_n -c` -gt "0" ]
then
cd /rezsystem/rezadmin
./jbstopnode_1 >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt 2>&1
sleep 6
./jbstopnode_4 >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt 2>&1
sleep 6
else
echo "WARNING!!! Nodes are not running"
exit
fi
EOF
echo $(whoami)
#ssh to the SLH database server
if [ `pgrep java_n -c` -le "0" ]
then
echo "Jboss nodes sucessfully killed"
ssh -T [email protected] << 'EOF'
echo "SLH shedule DB restart start at $(date)"
echo $(whoami)
#NOTE-change permission 777 abc.txt
cd /rezsystem/rezadmin
./pgstop_cps >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt 2>&1
sleep 6
./pgstop_slh >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt 2>&1
sleep 6
if [ `pgrep postmaster |wc -l` -le "0" ]
then
echo "All postgress Nodes sucessfully killed"
cd /rezsystem/rezadmin
echo "DB restart process started!!!..."
./pgstart_cps >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt 2>&1
sleep 6
./pgstart_slh >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt 2>&1
sleep 6
if [ `pgrep postmaster |wc -l` -gt "0" ]
then
echo "database restart process is sucessfully completed"
else
echo "WARNING!!! database restart process failed"
echo "WARNING!!! SLH database restart process failed - Manulay restart" | mail -s "WARNING!!! database restart process failed" [email protected]
fi
else
echo "database is still running!!! so java nodes are starting...."
echo "SLH database is still running!!! so java nodes are starting.." | mail -s "WARNING!!! database is still running!!!" [email protected]
fi
EOF
else
echo "WARNING!!! java nodes are still running !!! HINT- Java nodes could be started by another user"
exit
fi
echo $(whoami)
#restart memcached service
SERVICE=memcached.service
systemctl is-active memcached.service > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$SERVICE restarting..."
systemctl stop "$SERVICE"
STATUS=`systemctl is-active $SERVICE`
if [ "$STATUS" == "inactive" ]
then
echo "$SERVICE is successfully stoped!! "
systemctl start "$SERVICE"
else
echo "$SERVICE is still running!!!"
fi
systemctl is-active "$SERVICE" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$SERVICE service restart process is sucessfully completed"
else
echo "$SERVICE service restart process failed "
fi
else
echo "WARNING!! $SERVICE is not running "
fi
#restart java nodes -> rezuser
sleep 6 ;
su - rezuser<< 'EOF'
echo $(whoami)
if [ `pgrep java_n -c` -le "0" ]
then
echo "Jboss Nodes are starting...."
cd /rezsystem/rezadmin
./jbstartnode_1 >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt
sleep 6
./jbstartnode_4 >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt
sleep 6
if [ `pgrep java_n -c` -eq "2" ]
then
echo $(whoami)
echo "==============================================================================="
echo "srilankanholidays shedule restart is sucessfully completed at $(date) "
echo "==============================================================================="
echo "srilankanholidays shedule restart is sucessfully completed at $(date)" | mail -s "COMPLETED!!! srilankanholidays shedule restart is sucessfully completed" [email protected]
echo "" | mail -s "Daily Scheduled Restart at 02:30AM - SrilankanCPS and SLH" -c [email protected] [email protected] < /rezsystem/rezadmin/slh_daily_restart_log/mail.txt
else
echo "==============================================================================="
echo "srilankanholidays shedule restart FAIELD -> check jboss nodes |MANUALY RESTART|"
echo "==============================================================================="
echo "srilankanholidays shedule restart FAIELD at $(date) check jboss nodes |MANUALY RESTART|" | mail -s "WARNING!!! srilankanholidays shedule restart FAILED" [email protected]
fi
else
echo "WARNING!!! joss nodes still running"
fi
EOF
} >>/rezsystem/rezadmin/slh_daily_restart_log/log.txt 2>&1
#log file backup
cd /rezsystem/rezadmin/slh_daily_restart_log
tar -czf $( date '+%y-%m-%d' ).tar.gz log.txt
#echo "" > /rezsystem/rezadmin/slh_daily_restart_log/log.txt
exit