forked from Percona-QA/package-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_running.sh
More file actions
executable file
·35 lines (30 loc) · 785 Bytes
/
check_running.sh
File metadata and controls
executable file
·35 lines (30 loc) · 785 Bytes
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
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "This script requires product parameter: mysql, mongodb, proxysql and status like running|stopped!"
echo "Usage: ./check_running.sh <prod> <status>"
exit 1
fi
product=$1
status=$2
log="/tmp/${product}_check_running.log"
echo -n > ${log}
if [ ${product} = "mysql" ]; then
process="bin/mysqld"
elif [ ${product} = "mongodb" ]; then
process="bin/mongod"
elif [ ${product} = "proxysql" ]; then
process="bin/proxysql"
else
echo "Unknown product!"
exit 1
fi
ps aux >> ${log}
psoutput=$(ps aux | grep -v "grep" | grep -v "check_running.sh" | grep -c "${process}")
echo ${psoutput}
if [ ${psoutput} -eq 0 -a ${status} = "stopped" ]; then
exit 0
elif [ ${psoutput} -gt 0 -a ${status} = "running" ]; then
exit 0
else
exit 1
fi