David's devmon watch-dog is much better than mine but I thought I'd share anyways....
I think if I wrote one today, it would be a little different. This was done a few years back and I kinda chuckled at my own work...I made a var for date....lol
Anyways, here you go...
#!/bin/bash
# Need Date var for log entry
DATE=`date`
# Grab xymon.ns/xymon web page and check if devom is dead (purple)
# Make var to check on purple
DMSTATUS=`lynx -accept_all_cookies -dump -nolist -auth=ns:canne 'xymon/Xymon' | grep dm | tail -1 |grep -o "dm:green\|dm:purple" | cut -c 4-`
echo Status=$DMSTATUS
if [ $DMSTATUS = purple ] ; then
echo "devmon is dead, killing, restarting and logging event"
echo "$DATE DM-Watchdog - devmon is dead ($DMSTATUS), killing and restarting" >> /var/log/devmon.log
# Kill it twice (sometimes 1 don't work ???)
/home/xymon/devmon/killdevmon
sleep 1
/home/xymon/devmon/killdevmon
# Start DEVMON
/home/xymon/devmon/devmon
# Send Email
/usr/local/bin/sendEmail -f user-5d5d55da9ccc@xymon.invalid -t user-7cb0f5662626@xymon.invalid -u Devmon Restart -m "Devmon Died and was restarted on $DATE"
else
#echo "All Good"
echo "$DATE DM-Watchdog - Devmon is All Good ($DMSTATUS)" >> /var/log/devmon.log
fi
Ken Connell
Intermediate Network Engineer
Computer & Communication Services
Ryerson University
XXX Victoria St
RM AB50
Toronto, Ont
M5B 2K3
XXX-XXX-XXXX x6709
----- Original Message -----
From: David Baldwin <user-cbbf693f2c89@xymon.invalid>
Date: Monday, May 30, 2011 11:53 pm
Subject: Re: [Xymon] Configuring Devmon for the first time
To: "user-7cb0f5662626@xymon.invalid" <user-7cb0f5662626@xymon.invalid>
Cc: Josh Luthman <user-4c45a83f15cb@xymon.invalid>, "xymon at xymon.com" <xymon at xymon.com>
On 31/05/11 11:24 AM, user-7cb0f5662626@xymon.invalid wrote:
I've had issues with devmon not updating the bb-display and everything going purple. > I've had this issue since day one (which is over two years now). >
I created a "devmon watchdog" script that's runs every 5 min using lynx (txt base html browser) which checks if the status of devmon (shows as dm test) on bb-monitor. If its purple then I kill the devmon process and start it up again....band-aid solution, but it does the trick. >
I no script expert, but can share the bash script if you want/need.
Here's mine (replace xymonserver with your hostname):
#!/bin/sh
COL=`bb xymonserver "hobbitdboard xymonserver.dm fields=color"`
if [ "x$COL" == "xpurple" ] ; then
(date "+%x %X restarting purple devmon"
/etc/init.d/devmon restart) | tee /var/log/devmon-restart.log | mail
-s "Restarting devmon" xymonadmin
fi
-- David Baldwin - IT Unit
Australian Sports Commission www.ausport.gov.au
Tel 02 62147830 Fax 02 62141830 PO Box 176 Belconnen ACT 2616
user-cbbf693f2c89@xymon.invalid Leverrier Street Bruce ACT 2617
Keep up to date with what's happening in Australian sport visit http://www.ausport.gov.au
This message is intended for the addressee named and may contain confidential and privileged information. If you are not the intended recipient please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you receive this message in error, please delete it and notify the sender.