-
Notifications
You must be signed in to change notification settings - Fork 2
/
mariadb-manager-monitor
executable file
·150 lines (120 loc) · 5.38 KB
/
mariadb-manager-monitor
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
#!/bin/sh
#
# Part of MariaDB Manager package.
#
# This file is distributed as part of the MariaDB Manager package.
# It is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright 2013-2014 (c) SkySQL Corporation Ab
#
# Author : Stefano Simonelli, Massimo Siani
# Version : 2.22
# Date : November 2013
# Description : LSB script for MariaDB Manager Monitor
# Note : Script location must be: /etc/init.d - with execute permission
# Returns : 0 = OK - 1 = Warning
#
# chkconfig: 2345 80 20
# description: Starts the MariaDB-Manager Monitor
#
### BEGIN INIT INFO
# Provides: mariadb-manager-monitor
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start mariadb-manager-monitor at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
## variables
vMonitorDir=/usr/local/skysql/monitor
vMonitorJar=ClusterMonitor.jar
vShareDir=/usr/local/skysql/share
vShareFile1=skysql-java-shared.jar
vJavaClasspath="${vMonitorDir}/${vMonitorJar}:${vShareDir}/*"
vJavaSettings="-Duser.language=en -Duser.country=GB"
## set to -v for verbosity, empty or comment otherwise
#verbose="-v"
fGetMonitorPid() {
vMonitorPid=`ps -efwwww | grep ClusterMonitor.jar | grep -v grep | awk '{print $2}'`
}
case "$1" in
###################################################################################################################
'start')
fGetMonitorPid
if [ "${vMonitorPid}" != "" ]; then
echo "`date` - Warning: MariaDB Manager Monitor is already running on `hostname`, process $vMonitorPid"
vRetVal=1
else
### Starting the Monitor ##################################################################################
echo "`date` - Start: MariaDB Manager Monitor is starting "
PATH=${PATH}:/usr/sbin
java -cp ${vJavaClasspath} ${vJavaSettings} com.skysql.monitor.ClusterMonitor $verbose all &
### Check if the process is started ###############################################################
sleep 1
fGetMonitorPid
if [ "${vMonitorPid}" != "" ]; then
vRetVal=0
else
echo "`date` - Warning: MariaDB Manager Monitor is NOT running on `hostname`"
vRetVal=1
fi
###########################################################################################################
fi
;;
###################################################################################################################
'stop')
fGetMonitorPid
if [ "${vMonitorPid}" != "" ]; then
echo "`date` - Stop: MariaDB Manager Monitor is stopping "
### Stop the Monitor ######################################################################################
kill -9 $vMonitorPid
###########################################################################################################
### Check if the process is already running ###############################################################
sleep 1
fGetMonitorPid
if [ "${vMonitorPid}" != "" ]; then
kill -9 $vMonitorPid
fi
###########################################################################################################
vRetVal=0
else
echo "`date` - Status: MariaDB Manager Monitor is NOT running on `hostname`"
vRetVal=0
fi
;;
###################################################################################################################
'reload'|'restart')
$0 stop
$0 start
vRetVal=$?
;;
###################################################################################################################
'status')
fGetMonitorPid
if [ "${vMonitorPid}" != "" ]; then
echo "`date` - Status: MariaDB Manager Monitor is running on `hostname`, process $vMonitorPid"
vRetVal=0
else
echo "`date` - Status: MariaDB Manager Monitor is NOT running on `hostname`"
vRetVal=0
fi
;;
###################################################################################################################
*)
echo "Usage: MariaDB Manager Monitor - $0 {start|stop|restart|reload|status}"
vRetVal=1
;;
esac
exit $vRetVal