[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [hobbit] DESCR Info in Alerts
- To: hobbit (at) hswn.dk
- Subject: Re: [hobbit] DESCR Info in Alerts
- From: "Geoff Hallford" <geoff.hallford (at) gmail.com>
- Date: Thu, 1 Mar 2007 08:51:35 -0500
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=EdmTWAvpeijg4CTINJKXNYMpIrQKNwEJwMxx43lwxSYInGZe5tInlp/Xh5t8lgVns3/ItsTJ77drprSApGa4G781slOaNnf4ASCUgH7ltLJi5ZZSBK9a8SHv9W4kfRCydGlWk3DyFJFWKyD7/91gIElQf+8pj96ojyGNf5qggkc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=ZoTu8imeiA3ZX991VVpWbV707Os+lYvING46x14eqkmngaOtuunvEJkcpqQp6+RYW7kDNuMHsSeqvgW8Hd4bHF6gAzPRtp0F/9rlWRZZFrs5xFZsrwdUvtEfPE1eQO3MNRMX2SPgSGAXkvEFvuMITuQQWcsSuGaZzhGgMARhbyk=
- References: <78ca5ea20701240558t62956b93sdddec089ef67f83@mail.gmail.com> <20070124220956.GB14736@hswn.dk> <78ca5ea20701241804t36e60b44x46061837cfab04ee@mail.gmail.com>
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