ServerBot/bot.sh

45 lines
929 B
Bash
Raw Normal View History

2019-05-02 20:41:03 +02:00
#!/bin/bash
# the main bot script
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-05-10 02:23:32 +02:00
used=$(df --output=pcent $hdd | tail -1 | grep -Po "(\\d+)" --color=never)
if [ "$used" -gt "$hddlimit" ]; then
2019-05-02 20:41:03 +02:00
echo "warn!"
send "warnung%20server%20used%20$used%25%20of%20the%20storage!"
fi
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-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!"
send "warnung%20CPU%20Usage%20is%20high%20$cpu"
fi
2019-05-10 20:01:51 +02:00
#mem usage
. mem.sh
mem=$(memUsage)
if [ "$mem" -gt "$memlimit" ]; then
echo "mem limit!"
send "warnung%20Memory%20Usage%20is%20high%20$mem%25"
fi
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