Skip to content

Commit 7b4d592

Browse files
committed
[cmd] healthcheck additions and fixes
1 parent 87d40b6 commit 7b4d592

File tree

6 files changed

+61
-11
lines changed

6 files changed

+61
-11
lines changed

bin/commands/scripts/healthcheck/accessibility.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/bin/bash
22
status=""
3-
wget -q --spider 127.0.0.1:6001/ping
3+
wget -q -t 1 --timeout=10 127.0.0.1:6001/ping
44
if [ $? -ne 0 ]; then
55
status=${status}"\n Dashboard is not accessible";
66
fi
77

8-
wget -q --spider 127.0.0.1:3001/o/ping
8+
wget -q -t 1 --timeout=10 127.0.0.1:3001/o/ping
99
if [ $? -ne 0 ]; then
1010
status=${status}"\n Api is not accessible";
1111
fi
1212

13-
wget -q --spider 127.0.0.1/ping
13+
wget -q -t 1 --timeout=10 127.0.0.1/ping
1414
if [ $? -ne 0 ]; then
1515
status=${status}"\n Dashboard is not accessible through Nginx";
1616
fi
1717

18-
wget -q --spider 127.0.0.1/o/ping
18+
wget -q -t 1 --timeout=10 127.0.0.1/o/ping
1919
if [ $? -ne 0 ]; then
2020
status=${status}"\n Api is not accessible through Nginx";
2121
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
con=$(countly mongo)
3+
res=$(mongo countly ${con} --eval "print('CLYTest')")
4+
if ! [[ $res == *"CLYTest"* ]]; then
5+
echo -e "Can't connect to MongoDB";
6+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
nginxpath="/var/log/nginx/error.log"
4+
curdate=$(date "+%Y/%m/%d %H")
5+
errors=$(cat ${nginxpath} | grep "${curdate}" | wc -l);
6+
7+
if [ ${errors} -gt 0 ]; then
8+
echo -e "You have $errors error(s) in the last hour in your nginx error.log";
9+
fi
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
if [ -x "$(command -v ntpstat)" ]; then
4+
ntpstat;
5+
if [ $? -ne 0 ]; then
6+
echo -e "NTP does not seem to work properly";
7+
fi
8+
elif [ -x "$(command -v ntpq)" ]; then
9+
ntp_offset=$(ntpq -pn | awk 'BEGIN { offset=1000 } $1 ~ /\*/ { offset=$9 } END { print offset }');
10+
if [ ${ntp_offset} -gt 1000 ]; then
11+
echo -e "NTP does not seem to work properly";
12+
fi
13+
elif [ -x "$(command -v timedatectl)" ]; then
14+
res=$(timedatectl status | grep 'NTP synchronized' | tr -d ' ' | cut -d ':' -f 2);
15+
if ! [ $res = "yes" ]; then
16+
echo -e "NTP does not seem to work properly";
17+
fi
18+
else
19+
echo -e "NTP does not seem to be installed or configured correctly";
20+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
procowner="0"
4+
fileowner=$(stat -c '%U' `countly dir`)
5+
paths=$(ps -ux | grep countly)
6+
while read line; do
7+
if [[ $line = *"dashboard node"* ]]; then
8+
procowner=$(echo ${line} | tr -s ' ' | cut -d ' ' -f 1)
9+
break
10+
fi
11+
done <<< "$paths"
12+
if ! [ ${procowner} == ${fileowner} ]; then
13+
echo -e "Permission problems:"
14+
echo -e " Process owner: $procowner";
15+
echo -e " Directory owner: $fileowner";
16+
fi

bin/commands/scripts/healthcheck/process.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ workersthreshold=$(nproc)
3232
appproc=0
3333
apiproc=0
3434
workers=0
35-
paths=$(ps -ax | grep node)
35+
paths=$(ps -ax | grep countly)
3636
while read line; do
37-
path=$(echo ${line} | awk '{print $NF}')
38-
if [[ $path = *"frontend/express/app.js"* ]]; then
37+
if [[ $line = *"dashboard node"* ]]; then
3938
appproc=$((appproc+1))
4039
fi
41-
if [[ $path = *"api/api.js"* ]] && ! [[ $path = *"/bin/config/"* ]]; then
40+
if [[ $line = *"api master node"* ]]; then
4241
apiproc=$((apiproc+1))
4342
fi
44-
if [[ $path = *"api/api.js"* ]] && [[ $path = *"/bin/config/"* ]]; then
43+
if [[ $line = *"api worker node"* ]]; then
4544
workers=$((workers+1))
4645
fi
4746
done <<< "$paths"
@@ -57,9 +56,9 @@ elif [ ${apiproc} == 0 ]; then
5756
res=${res}"\n Process api.js is not found"
5857
fi
5958
if [ ${workers} -gt ${workersthreshold} ]; then
60-
res=${res}"\n Too many processes for api.js workers: "$apiproc
59+
res=${res}"\n Too many processes for api.js workers: "$workers" nproc: "$workersthreshold
6160
elif [ ${workers} -lt ${workersthreshold} ]; then
62-
res=${res}"\n Too little processes for api.js workers: "$apiproc" nproc: "$workersthreshold
61+
res=${res}"\n Too little processes for api.js workers: "$workers" nproc: "$workersthreshold
6362
fi
6463

6564
if ! [ -z "${res}" ]; then

0 commit comments

Comments
 (0)