[hobbit] DESCR Info in Alerts
Geoff Hallford
geoff.hallford at gmail.com
Thu Mar 1 14:51:35 CET 2007
Hi Henrik,
Since the DESCR tab doesn't get sent automatically (that I know of) to a
custom alert script, what is the easiest way to accomplish obtaining it. The
script is written in Bourne Shell (standard /bin/sh). This is what my
current script looks like (very simple for now):
#!/bin/sh
# Start Section for Time Formatting
#-----------------------------------------------------
mkstring () {
TIME_VALUE=$1
UNIT=$2
if [ $TIME_VALUE -eq 0 ]; then
OUT=""
elif [ $TIME_VALUE -eq 1 ]; then
OUT="1 $UNIT, "
else
OUT="$TIME_VALUE ${UNIT}S, "
fi
echo "$OUT"
}
seconds2text () {
# Convert seconds to week/day/hour/minute
TEMP0=`expr $1 / 60`
SECOND=`expr $1 - $TEMP0 \* 60`
TEMP1=`expr $TEMP0 / 60`
MINUTE=`expr $TEMP0 - $TEMP1 \* 60`
TEMP2=`expr $TEMP1 / 24`
HOUR=`expr $TEMP1 - $TEMP2 \* 24`
TEMP3=`expr $TEMP2 / 7`
DAY=`expr $TEMP2 - $TEMP3 \* 7`
WEEK=$TEMP3
# Build the output string
STRING="`mkstring $WEEK WEEK`"
STRING="$STRING`mkstring $DAY DAY`"
STRING="$STRING`mkstring $HOUR HOUR`"
STRING="$STRING`mkstring $MINUTE MIN`"
STRING="$STRING`mkstring $SECOND SEC`"
# Remove the trailing comma
DOWNSECS=`echo $STRING | sed 's/,$//'`
}
# If the seconds don't equal zero (ie event just started) then format the
duration
if [ $DOWNSECS -ne 0 ]; then
seconds2text $DOWNSECS
else
DOWNSECS="0 SECONDS"
fi
# Check if the status is recovered
if [ $RECOVERED -eq 1 ]; then
echo -e "STATUS: RECOVERED\nDATE: `date`\nSYSTEM TYPE:
PRODUCTION\nSYSTEM NAME: $BBHOSTNAME\nDURATION:
$DOWNSECS\n\n--\n\n$BBALPHAMSG\n\n" | /usr/bin/mail -s "PROD RECOVERED:
$BBHOSTSVC"
$RCPT
# Check if the status is still down
else
echo -e "STATUS: DOWN\nDATE: `date`\nSYSTEM TYPE: PRODUCTION\nSYSTEM
NAME: $BBHOSTNAME\nALERT COLOR: $BBCOLORLEVEL\nDURATION:
$DOWNSECS\n\n--\n\n$BBALPHAMSG\n\n" | /usr/bin/mail -s "PROD DOWN:
$BBHOSTSVC"
$RCPT
fi
On 1/24/07, Geoff Hallford <geoff.hallford at gmail.com> wrote:
>
> Thank you. Will do.
>
> On 1/24/07, Henrik Stoerner <henrik at hswn.dk> wrote:
> >
> > On Wed, Jan 24, 2007 at 08:58:02AM -0500, Geoff Hallford wrote:
> >
> > > I was wondering if there is anyway to change the default email alert
> > > contents to include the DESCR tag information for a host (without
> > creating a
> > > custom alert script)? We have many support people who don't know what
> > all of
> > > the hosts are for or if it goes down, what that means and I want to
> > make it
> > > easier for them to know what is affected.
> >
> > You'll either have to create a custom alert script, or tweak the
> > hobbitd/do_alert.c C code. If you choose the latter, then the
> > message_subject() and message_text() routines are the ones you're after;
> >
> > you can get the DESCR tag with code like this:
> >
> > namelist_t *hinfo;
> > char *descr;
> >
> > hinfo = hostinfo(alert->hostname);
> > descr = bbh_item(hinfo, BBH_DESCRIPTION);
> >
> > Note that this will return a NULL pointer if there is no DESCR tag for
> > this host.
> >
> >
> >
> > Regards,
> > Henrik
> >
> >
> > To unsubscribe from the hobbit list, send an e-mail to
> > hobbit-unsubscribe at hswn.dk
> >
> >
> >
>
>
> --
> 'If my answers frighten you then you should cease asking scary questions.'
> --Sam Jackson
--
'If my answers frighten you then you should cease asking scary questions.'
--Sam Jackson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20070301/9ec3bc30/attachment.html>
More information about the Xymon
mailing list