added mobot project and the df bot
This commit is contained in:
parent
890383cdbe
commit
2c05ce1c82
|
@ -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..
|
|
@ -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
|
|
@ -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"
|
43
mobots/df.sh
43
mobots/df.sh
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue