2019-05-02 20:41:03 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# the main bot script
|
|
|
|
|
2019-05-24 16:15:25 +02:00
|
|
|
# change dir
|
|
|
|
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
|
|
|
echo "pwd: "
|
|
|
|
pwd
|
|
|
|
|
2019-05-10 02:23:32 +02:00
|
|
|
. config.sh
|
2019-05-10 01:30:30 +02:00
|
|
|
. func.sh
|
|
|
|
|
2019-05-02 20:41:03 +02:00
|
|
|
#hdd usage
|
2019-07-07 11:00:39 +02:00
|
|
|
. hdd.sh
|
|
|
|
used=$(hddUsage)
|
2019-05-10 02:23:32 +02:00
|
|
|
if [ "$used" -gt "$hddlimit" ]; then
|
2019-05-02 20:41:03 +02:00
|
|
|
echo "warn!"
|
2019-07-07 11:00:39 +02:00
|
|
|
hddTop=$(hddTop)
|
|
|
|
send "warnung server used $used% of the storage $hddTop"
|
2019-05-02 20:41:03 +02:00
|
|
|
fi
|
2019-07-07 11:04:21 +02:00
|
|
|
unset -f hddTop
|
|
|
|
unset -f hddUsage
|
2019-05-10 01:30:30 +02:00
|
|
|
|
|
|
|
#services
|
|
|
|
. services.sh
|
2019-05-10 02:23:32 +02:00
|
|
|
notrunning=$(checkServices "$services")
|
2019-05-10 01:30:30 +02:00
|
|
|
if [ "$notrunning" != "" ]; then
|
|
|
|
echo "Serive warn!"
|
|
|
|
send "warnung%20the%20following%20services%20are%20not%20running%20$notrunning"
|
|
|
|
fi
|
2019-07-07 11:04:21 +02:00
|
|
|
unset -f checkServices
|
2019-05-10 02:23:32 +02:00
|
|
|
|
2019-05-10 20:01:51 +02:00
|
|
|
#cpu usage
|
2019-05-10 02:23:32 +02:00
|
|
|
. cpu.sh
|
|
|
|
cpu=$(cpuUsage)
|
|
|
|
if [ "$cpu" -gt "$cpulimit" ]; then
|
|
|
|
echo "cpu limit!"
|
2019-07-07 11:00:39 +02:00
|
|
|
proc=$(cpuTop)
|
2019-07-07 09:41:39 +02:00
|
|
|
send "warnung%20CPU%20Usage%20is%20high%20$cpu%25%0A$proc"
|
2019-05-10 02:23:32 +02:00
|
|
|
fi
|
2019-07-07 11:04:21 +02:00
|
|
|
unset -f cpuUsage
|
|
|
|
unset -f cpuTop
|
2019-05-10 20:01:51 +02:00
|
|
|
|
|
|
|
#mem usage
|
|
|
|
. mem.sh
|
|
|
|
mem=$(memUsage)
|
|
|
|
if [ "$mem" -gt "$memlimit" ]; then
|
|
|
|
echo "mem limit!"
|
2019-07-07 11:00:39 +02:00
|
|
|
proc=$(memTop)
|
2019-07-07 09:41:39 +02:00
|
|
|
send "warnung%20Memory%20Usage%20is%20high%20$mem%25%0A$proc"
|
2019-05-10 20:01:51 +02:00
|
|
|
fi
|
2019-07-07 11:04:21 +02:00
|
|
|
unset -f memUsage
|
|
|
|
unset -f memTop
|
2019-05-10 20:01:51 +02:00
|
|
|
|
2019-05-19 03:57:33 +02:00
|
|
|
#CheckCerts
|
|
|
|
. cert.sh
|
|
|
|
checkCert "/etc/letsencrypt/live/mrbesen.de/cert.pem"
|
|
|
|
if [ "$?" -gt "0" ]; then
|
|
|
|
echo "cert expired!"
|
|
|
|
send "warnung%20cert%20expires%20soon"
|
|
|
|
fi
|
2019-07-07 11:04:21 +02:00
|
|
|
unset -f checkCert
|