1
1
Fork 0

renamed mobots to mbots

This commit is contained in:
David Starzengruber 2011-07-07 15:35:24 +02:00
parent e244122f8f
commit fbf0973891
5 changed files with 0 additions and 252 deletions

View File

@ -1,41 +0,0 @@
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 have here is the df bot. it sends me a short jabber message
when one or more disks on the serving machine reaching a preconfigured threshold
(example: 90% disk usage).
another tool i find really useful is the pingbot (ping.sh)
it works pretty much the same as the dfbot.
feel free to use or improve this handy tools!
=== install notes ===
1. copy the scrip somewhere on your machine
you get the df.sh on gitorious.org
http://gitorious.org/sn/scripts/trees/master/mobots/df.sh
2. create the configfile
use the df.conf.sample to create a config and put this file anywhere on the same machine
http://gitorious.org/sn/scripts/trees/master/mobots/df.conf.sample
3. create a cronjob for it
add a line like this to your /etc/crontab
*/2 * * * * root /bin/bash --login /path/to/the/script/df.sh /path/to/configfile/df.conf >> /path/to/logfile/df.log
or (if you use the default configpath /etc/mobots)
*/5 * * * * root /bin/bash --login /path/to/script/df.sh >> /var/log/mobots/df.log
the logdirectory must exist
after this you have to restart your cron with something like
service cron restart
of course there are several ways to create a cronjob but this is probably the easiest way
any questions? mail me! (david@socialnerds.org)

View File

@ -1,16 +0,0 @@
## 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"
#port="5222" # uncomment if you want to use a specific port
## define disks you wanna check? (whitespace seperated)
disks="hda1 hda2 hdd1"
## here the disks thresholds
thresholds="80 90 95"

View File

@ -1,85 +0,0 @@
#!/bin/bash
###################################################
## ##
## disk_free jabber monitoring bot ##
## Author: david@socialnerds.org ##
## v0.2 ##
## ##
###################################################
## timestamp for logfile
timestamp=$(date '+%d %B %Y %H:%M')
echo "info: starting df bot $timestamp"
## check if sendxmpp is installed
if [ $(aptitude search sendxmpp | awk '{print $1}') = "i" ]; then
echo "info: sendxmpp found"
else
if [ $(whoami) = "root" ]; then
apt-get install sendxmpp
else
echo "error: permission denied"
echo "info: install sendxmpp or run this scrip as superuser"
exit 1
fi
fi
## set and load configfile
if [ -z $1 ]; then
configfile="/etc/mobots/df.conf"
if [ -f $configfile ]; then
source $configfile
else
echo "error: no config file $configfile"
exit 1
fi
else
configfile=$1
if [ -f $configfile ]; then
source $configfile
else
echo "error: no config file $configfile"
exit 1
fi
fi
## check sendxmpp config
if [ -f ~/.sendxmpprc ]; then
echo "info: jabber config found in ~/.sendxmpprc"
else
if [ -z $port ]; then
port="5222"
else
echo "info: using port $port"
fi
echo "$user@$server:$port $pass" > ~/.sendxmpprc
chmod 600 ~/.sendxmpprc
echo "info: created sendxmpp config in ~/.sendxmpprc"
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 "info: $var reached threshold with $data%, sending notification to $watchdogs"
echo "$hostname: $var is running out of space: $data%" | sendxmpp -r dfbot $watchdogs
fi
let i++
done
## exiting
echo "info: done"
exit 0

View File

@ -1,12 +0,0 @@
# a whitespace seperated list of ip addresses or fqdnames
dest="192.168.1.13 somemachine.example.com"
# jabber configuration
user="jid"
server="jabber-server"
#port="" ## if you want to use a special port (default: 5222)
pass="jabber-password"
res="pingbot"
watchdogs="someuser@jabber.example.com anotheruser@example.com" ## whitespace seperated list of JIDs

View File

@ -1,98 +0,0 @@
#!/bin/bash
## ## ## ## ## ## ## ## ##
## ##
## jabber ping bot ##
## ##
## v0.1 ##
## ##
## author: david@socialnerds.org ##
## ##
## ## ## ## ## ## ## ## ##
## timestamp for logfile
timestamp=$(date '+%d %B %Y %H:%M')
echo "info: starting jabber ping bot $timestamp"
## check if sendxmpp is installed
if [ $(aptitude search sendxmpp | awk '{print $1}') = "i" ]; then
echo "info: sendxmpp found"
else
if [ $(whoami) = "root" ]; then
apt-get install sendxmpp
else
echo "error: permission denied"
echo "info: install sendxmpp or run this scrip as superuser"
exit 1
fi
fi
## set and load configfile
if [ -z $1 ]; then
configfile="/etc/mobots/ping.conf"
if [ -f $configfile ]; then
source $configfile
else
echo "error: no config file $configfile"
exit 1
fi
else
configfile=$1
if [ -f $configfile ]; then
source $configfile
else
echo "error: no config file $configfile"
exit 1
fi
fi
## check sendxmpp config
if [ -f ~/.sendxmpprc ]; then
echo "info: jabber config found in ~/.sendxmpprc"
else
if [ -z $port ]; then
port="5222"
else
echo "info: using port $port"
fi
echo "$user@$server:$port $pass" > ~/.sendxmpprc
chmod 600 ~/.sendxmpprc
echo "info: created sendxmpp config in ~/.sendxmpprc"
fi
## run the actual ping
set -- $dest
for var in "$@"
do
#result=$(ping -c 05 $var | grep transmitted | awk '{print $4}')
ping -c 03 $var >/dev/null 2>&1
errorcode=$?
if [ $errorcode = "0" ]; then
echo "info: $var is responding"
else
if [ $errorcode = "1" ]; then
echo "alert: $var is not responding"
## sending jabber message
echo "alert: $var is not responding
ping errorcode: $errorcode" | sendxmpp -r $res $watchdogs
else
if [ $errorcode = "2" ]; then
echo "alert: $var cannot be resolved"
## sending jabber message
echo "alert: $var cannot be resolved
ping errorcode: $errorcode" | sendxmpp -r $res $watchdogs
fi
fi
fi
done
## the end
exit 0