forked from jeedom/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
health.sh
57 lines (51 loc) · 1.34 KB
/
health.sh
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
#!/bin/sh
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Check filesystem space..."
USERSPACE=$(df -h . | awk '/[0-9]/{print $(NF-1)}' | sed 's/\%//g')
if [ ${USERSPACE} -gt 95 ]; then
echo 'NOK'
else
echo "OK"
fi
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Check mysql..."
sudo service mysql status >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -n "NOK, try to restart..."
sudo service mysql start
sudo service mysql status >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "[$(date +%d-%m-%Y\ %H:%M:%S)] Can not start it"
exit 1
fi
else
echo "OK"
fi
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Check cron..."
sudo service cron status >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -n "NOK, try to restart..."
sudo service cron start
sudo service cron status >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "[$(date +%d-%m-%Y\ %H:%M:%S)] Can not start it"
exit 1
fi
else
echo "OK"
fi
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Check cron jeedom..."
if [ $(crontab -l | grep jeeCron | wc -l) -lt 1 ]; then
echo 'NOK'
else
echo "OK"
fi
DIR="$( cd "$( dirname "$0" )" && pwd )"
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Check right..."
sudo chown -R www-data:www-data ${DIR}/*
sudo chmod 775 -R ${DIR}/*
echo -n "[$(date +%d-%m-%Y\ %H:%M:%S)] Check access to market..."
sudo ping -c 2 market.jeedom.fr >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "NOK"
else
echo "OK"
fi