1
1
scripts/mobots/df.sh
2010-07-01 18:08:47 +02:00

52 lines
1.3 KiB
Bash
Executable File

#########################################
## disk_free jabber monitoring bot ##
## Author: david@socialnerds.org ##
## v0.1 ##
#########################################
## configuration section (does a simple check if the configfile exists)
configfilepath=$(pwd)
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
if [ -f $configfilepath/df.conf ]; then
source $configfilepath/df.conf
else
echo "Exiting because there is no config file."
exit 1
fi
## check disks
set -- $disks
i="1"
for var in "$@"
do
data=$(df -Ph | grep $var | sed -e 's/%//g' | awk '{print $5}')
datathreshold=$(echo $thresholds | awk '{print $'$i'}')
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
let i++
done
## exiting
exit 0