1
1
scripts/mobots/df.sh

52 lines
1.3 KiB
Bash
Raw Normal View History

2010-06-30 23:58:23 +02:00
#########################################
## disk_free jabber monitoring bot ##
## Author: david@socialnerds.org ##
## v0.1 ##
#########################################
2010-06-29 23:31:23 +02:00
2010-06-30 23:58:23 +02:00
## configuration section (does a simple check if the configfile exists)
2010-06-29 23:31:23 +02:00
configfilepath=$(pwd)
2010-07-01 18:08:47 +02:00
logfile="df.log"
logfilepath="/var/log/mobots"
if [ "$(whoami)" = "root" ]; then
## check if logfile/path exists
if [ -f $logfilepath/$logfile ]; then
echo "Starting up df mbot script" >> $logfilepath/$logfile
else
mkdir -p $logfilepath
touch $logfilepath/$logfile
echo "Starting up df mbot script" >> $logfilepath/$logfile
fi
else
echo "Starting up df mbot script w/o logfile."
fi
2010-06-29 23:31:23 +02:00
if [ -f $configfilepath/df.conf ]; then
source $configfilepath/df.conf
else
echo "Exiting because there is no config file."
exit 1
fi
## check disks
2010-06-30 23:58:23 +02:00
set -- $disks
i="1"
2010-06-29 23:31:23 +02:00
2010-06-30 23:58:23 +02:00
for var in "$@"
do
data=$(df -Ph | grep $var | sed -e 's/%//g' | awk '{print $5}')
datathreshold=$(echo $thresholds | awk '{print $'$i'}')
2010-06-29 23:31:23 +02:00
2010-06-30 23:58:23 +02:00
if [ $data -gt $datathreshold ]; then
echo "$hostname -- $var is running out of space: $data%" | sendxmpp -r dfmobot -u $user -j $server -p $pass $watchdogs
fi
2010-06-29 23:31:23 +02:00
2010-06-30 23:58:23 +02:00
let i++
done
2010-06-29 23:31:23 +02:00
## exiting
exit 0