added config, added cpu load warning
This commit is contained in:
parent
358017389e
commit
84dc50a90e
14
bot.sh
14
bot.sh
|
@ -1,19 +1,27 @@
|
|||
#!/bin/bash
|
||||
# the main bot script
|
||||
|
||||
. config.sh
|
||||
. func.sh
|
||||
|
||||
#hdd usage
|
||||
used=$(df --output=pcent /dev/sda3 | tail -1 | grep -Po "(\\d+)" --color=never)
|
||||
if [ "$used" -gt 50 ]; then
|
||||
used=$(df --output=pcent $hdd | tail -1 | grep -Po "(\\d+)" --color=never)
|
||||
if [ "$used" -gt "$hddlimit" ]; then
|
||||
echo "warn!"
|
||||
send "warnung%20server%20used%20$used%25%20of%20the%20storage!"
|
||||
fi
|
||||
|
||||
#services
|
||||
. services.sh
|
||||
notrunning=$(checkServices "nginx,mysql")
|
||||
notrunning=$(checkServices "$services")
|
||||
if [ "$notrunning" != "" ]; then
|
||||
echo "Serive warn!"
|
||||
send "warnung%20the%20following%20services%20are%20not%20running%20$notrunning"
|
||||
fi
|
||||
|
||||
. cpu.sh
|
||||
cpu=$(cpuUsage)
|
||||
if [ "$cpu" -gt "$cpulimit" ]; then
|
||||
echo "cpu limit!"
|
||||
send "warnung%20CPU%20Usage%20is%20high%20$cpu"
|
||||
fi
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
#services that should be running
|
||||
services="nginx,mysql"
|
||||
|
||||
#cpu usage limit (not divided by core count)
|
||||
cpulimit="150"
|
||||
|
||||
#telegram api-token
|
||||
token="123456:ABCDEFGH"
|
||||
#telegram user to notify
|
||||
userid="123456"
|
||||
|
||||
#harddrive usage percentage
|
||||
hddlimit="50"
|
||||
|
||||
#harddrive
|
||||
hdd="/dev/sda1"
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
function cpuUsage {
|
||||
ps -A -o pcpu | tail -n+2 | paste -sd+ | bc | awk '{print int($1)}'
|
||||
}
|
Loading…
Reference in New Issue