forked from ashraf-s9s/mysqlchk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaxscalechk.mysql
54 lines (50 loc) · 1.32 KB
/
maxscalechk.mysql
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
#!/bin/bash
#
# This script checks if a mysql server is healthy running on localhost. It will
# return:
# "HTTP/1.x 200 OK\r" (if maxscale is running smoothly)
# - OR -
# "HTTP/1.x 500 Internal Server Error\r" (else)
#
# The purpose of this script is make haproxy capable of monitoring maxscale properly
#
###
# |||
# +------ooOO-(O O)-OOoo------+
# | (_) |
# | Sylvain Arbaudie |
# | arbaudie.it@gmail.com |
# +---------------------------+
###
# original code & doc by Sylvain Arbaudie
# github repo : https://github.com/SylvainA77/mysqlchk-galera
###
MXS_USERNAME='@MXS_USER@'
MXS_PASSWORD='@MXS_PASSWORD@'
return_ok()
{
echo -e "HTTP/1.1 200 OK\r\n"
echo -e "Content-Type: text/html\r\n"
echo -e "Content-Length: 43\r\n"
echo -e "\r\n"
echo -e "<html><body>Maxscale is running. $NODES_UP servers up.</body></html>\r\n"
echo -e "\r\n"
exit 0
}
return_fail()
{
echo -e "HTTP/1.1 503 Service Unavailable\r\n"
echo -e "Content-Type: text/html\r\n"
echo -e "Content-Length: 42\r\n"
echo -e "\r\n"
echo -e "<html><body>Maxscale is *down*.</body></html>\r\n"
echo -e "\r\n"
exit 1
}
NODES_UP=`maxctrl --user=$MXS_USERNAME --password=$MXS_PASSWORD --tsv list servers | wc -l `
ret=$?
if [[ "$ret" == 0 ]]; then
return_ok
else
return_fail
fi