1
1
Fork 0

added mobot project and the df bot

This commit is contained in:
David 2010-06-30 23:58:23 +02:00
parent 890383cdbe
commit 2c05ce1c82
4 changed files with 49 additions and 46 deletions

16
mobots/README.please Normal file
View File

@ -0,0 +1,16 @@
this is my little mobot project.
the concept is not to spend hundreds of hours to implement some massive monitoring tool like nagios or something like this. instead i want to use some simple message/notification scripts which exactly tell me what i need to know.
the first thing i got here is the df bot. it sends me a short jabber message when one or more disks on the serving machine are reaching a preconfigured threshold (example: 90% disk usage).
feel free to use or improve this handy tool!
=== Installation ===
# tested with ubuntu 10.04
..nothing here yet..

View File

@ -1,21 +0,0 @@
## df mobot configfile
## options
log="1"
logfile="/var/log/mobots/df.log"
jabber="1"
local_only="1"
user="nobody"
group="nobody"
### which disks you wanna check?
# if you do not define anything here
# i will get you informed about every
# disk reaching the 90% mark.
disk0="/dev/sda5"
disk1="/dev/sda1"
disk2="/dev/sda9"
disk3=""
disk4=""
# you can go on like this

15
mobots/df.conf.sample Normal file
View File

@ -0,0 +1,15 @@
## df monitoring jabber bot configfile
## here i suggest you put the name of the machine you running this script on
hostname="somemachine.example.com"
## jabber config
watchdogs="max@muster.com moriz@jabber.anotherdomain.com"
user="jabber-username"
pass="jabber-password"
server="jabber-server"
## define disks you wanna check? (whitespace seperated)
disks="hda1 hda2 hdd1"
## here the disks thresholds
thresholds="80 90 95"

View File

@ -1,8 +1,12 @@
## disk_free jabber bot ##
##########################
#########################################
## disk_free jabber monitoring bot ##
## Author: david@socialnerds.org ##
## v0.1 ##
#########################################
## configuration section
## configuration section (does a simple check if the configfile exists)
configfilepath=$(pwd)
configfilepath=/home/david/Documents/sn/scripts/mobots
if [ -f $configfilepath/df.conf ]; then
source $configfilepath/df.conf
else
@ -10,33 +14,22 @@ else
exit 1
fi
## default config
if [ -z $logfile ]; then
# using default path
logfile="/var/log/mobots/df.log"
else
echo "using logfile defined in the config file"
fi
## ckeck environment
## get local disks
## check disks
data=$(df -Pl | grep $disk0)
echo $data
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'}')
## actions (jabber, logfile)
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
## testing output
echo $logfile
## exiting
exit 0