Alert suggestion: RSS

brianmas at highstream.net brianmas at highstream.net
Tue Mar 8 03:03:04 CET 2005


Quoting "Ginther, Demian M" <demian.m.ginther at boeing.com>:

looks like 3 of us have been hacking and came up with 3 different kind of
solutions! viva tmtowtdi!

my hack:

miscommands.cfg

define command{
    command_name    notify-by-rss
    command_line /usr/local/nagios/libexec/notify-by-rss.sh "$NOTIFICATIONTYPE$"
"$SERVICEDESC$" "$HOSTALIAS$" "$HOSTADDRESS$" "$SERVICESTATE$" "$DATETIME$"
"$OUTPUT$"
    }

the script:

#!/bin/sh

RSSFILE="/var/www/html/rss.xml"
DESC="alerts for
NAGURL="http://whatever"

NOTIFICATIONTYPE=$1
SERVICEDESC=$2
HOSTALIAS=$3
HOSTADDRESS=$4
SERVICESTATE=$5
DATETIME=$6
OUTPUT=$7-
echo "<?xml version='1.0' encoding='utf-8' ?>" >$RSSFILE
echo "<rss version='2.0'>" >>$RSSFILE
echo "<channel>" >>$RSSFILE
echo "<title>nagios alert</title>" >>$RSSFILE
echo "<link>$NAGURL</link>" >>$RSSFILE
echo "<description>$DESC</description>" >>$RSSFILE
echo "<lastBuildDate>$DATETIME</lastBuildDate>" >>$RSSFILE
echo "<generator>nagios notify script</generator>" >>$RSSFILE
echo "<item>" >>$RSSFILE
echo "<guid isPermaLink='true'>$NAGURL</guid>" >>$RSSFILE
echo "<pubDate>$DATETIME</pubDate>" >>$RSSFILE
echo "<title>$NOTIFICATIONTYPE alert on $HOSTALIAS for service
$SERVICEDESC</title>" >>$RSSFILE
echo "<description>" >>$RSSFILE
echo -e "\nNotification Type: $NOTIFICATIONTYPE\nService: $SERVICEDESC\nHost:
$HOSTALIAS\nAddress: $HOSTADDRESS\nState: $SERVICESTATE\nDate/Time:
$DATETIME\nAdditional Info:\n$OUTPUT" >>$RSSFILE
echo "</description>" >>$RSSFILE
echo "</item>" >>$RSSFILE
echo "</channel></rss>" >>$RSSFILE
exit 0

Obviously it'll only report the latest alert, not the best solution. Had to
niggle with group ownerships (added nagios to apache group, chmod g+w the write
directory)

blah someone write a complete clean solution :)

brian


> I started hacking around with this today... I modified the
> misccommands.cfg file to have two new methods, notify-by-RSS and
> host-notify-by-RSS which call a perl script which uses XML:RSS to write
> to a .rdf file.
>
> Works pretty well, if anyone's interested, let me know and I can put it
> up somewhere.
>
> Demian
>
> -----Original Message-----
> From: Jeff McCombs [mailto:jeffm at nicusa.com]
> Sent: Monday, March 07, 2005 3:58 PM
> To: nagios-users at lists.sourceforge.net
> Subject: Re: [Nagios-users] Alert suggestion: RSS
>
> Peeps,
>
> OK, so I've been hacking on this just to see, thinking that an RSS feed
> might be pretty useful..
>
> And what I've come up with isn't pretty, to say the least. It's slow..
> But
> for those of you who want to hack on this, maybe improve it, go for
> it...
>
> This little _PHP_ app parses the nagios.log file, and reports on all
> services that are _not_ in a status of UP or OK. I'm sure there's a perl
> module out there that can do it, but for some reason, I can't write perl
> to
> save my life. :)
>
> Tack on ?oktoo=true to the URL, and it'll report on all services (not
> recommended, we have over 800 services, which means we have over 800 RSS
> items, and that's a horrible thing to do to your reader!)
>
> Edit the config.php file and set the following:
>
>     $nagios['status_file']
>         This needs to be the full path to the status.log file Nagios
> spits
> out (e.g. /usr/local/nagios/var/status.log)
>
>     $nagios['myurl']
>         This is the full http:// address to the nagios web interface.
>         e.g. http://nagios.mydomain.com/nagios/
>
>     $nagios['statcgi']
>         This is the full http:// address to the nagios status.cgi script
>         e.g. http://nagios.mydomain.com/nagios/cgi-bin/status.cgi
>
>     $nagios['extinfo]
>         This is the full http:// address to the nagios extinfo.cgi
> script
>         e.g. http://nagios.mydomain.com/nagios/cgi-bin/extinfo.cgi
>
> Just drop this into the Nagios cgi-bin/ directory. Note this is a giant,
> ugly HACK that I put together, no warranties express or implied, blah
> blah
> blah, may break systems, cause floods and other major disasters, blah
> blah..
> No support, you know the drill.
>
>     Hack it up as needed. It ought to give someone a start at least...
> Oh,
> and I wrote this to work with 1.2, not 2.x, since I don't have a 2.x
> status
> file to work with. Sorry, no support for DB's, though it could be done
> (and
> would probably be faster).
>
>     -Jeff
>
>
>
>
> > From: <brianmas at highstream.net>
> > Date: Mon,  7 Mar 2005 14:32:31 -0500
> > To: <nagios-users at lists.sourceforge.net>
> > Subject: Re: [Nagios-users] Alert suggestion: RSS
> >
> > Quoting Marcel Smeets <mpgsmeets at gmail.com>:
> >
> >> Mmm, the second time someone tells it is simple to make a
> notification
> >> script for this. Well how??
> >
> > I already have something working, sorta, after just working on it a
> little bit
> > here and there today. I'll let the world know when I have something I
> think is
> > decent enough to use beyond my own machines.
> >
> > b
> >
> >>
> >>
> >> On Mon, 7 Mar 2005 15:57:37 +0000, Mike Simkins
> <mike.simkins at gmail.com>
> >> wrote:
> >>> I have seen something like this for files, should be a simple job to
> >>> write one, I would personally find it useful..
> >>>
> >>> On Mon,  7 Mar 2005 10:07:49 -0500, brianmas at highstream.net
> >>> <brianmas at highstream.net> wrote:
> >>>> Quoting Andreas Ericsson <ae at op5.se>:
> >>>>
> >>>>> brianmas at highstream.net wrote:
> >>>>>> I looked around and I didn't see it mentioned anywhere but RSS as
> a
> >>>>> reporting
> >>>>>> mechanism might be sorta useful. When I am on my laptop at home I
> >> often
> >>>>> don't
> >>>>>> have a browser window with nagios open or a mail client open but
> I'll
> >> have
> >>>>> an
> >>>>>> RSS client going. Maybe I am the only one and it'll never get
> used
> >> though
> >>>>> ...
> >>>>>> just an idea. I'd "write a patch" if I thought I could, btw.
> >>>>>>
> >>>>>
> >>>>> You don't have to write a patch. Just a notification script. It
> should
> >>>>> be fairly simple, really.
> >>>>
> >>>> oh really? I honestly didn't look into notification stuff, the
> plugin API
> >> is
> >>>> simple as hell though, I'll have a go at this when I have some free
> time
> >> this
> >>>> week.
> >>>>
> >>>> thanks for the info.
> >>>> brian
> >>>>
> >>>>
> >>>> -------------------------------------------------------
> >>>> SF email is sponsored by - The IT Product Guide
> >>>> Read honest & candid reviews on hundreds of IT Products from real
> users.
> >>>> Discover which products truly live up to the hype. Start reading
> now.
> >>>> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> >>>> _______________________________________________
> >>>> Nagios-users mailing list
> >>>> Nagios-users at lists.sourceforge.net
> >>>> https://lists.sourceforge.net/lists/listinfo/nagios-users
> >>>> ::: Please include Nagios version, plugin version (-v) and OS when
> >> reporting any issue.
> >>>> ::: Messages without supporting info will risk being sent to
> /dev/null
> >>>>
> >>>
> >>> -------------------------------------------------------
> >>> SF email is sponsored by - The IT Product Guide
> >>> Read honest & candid reviews on hundreds of IT Products from real
> users.
> >>> Discover which products truly live up to the hype. Start reading
> now.
> >>> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> >>> _______________________________________________
> >>> Nagios-users mailing list
> >>> Nagios-users at lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/nagios-users
> >>> ::: Please include Nagios version, plugin version (-v) and OS when
> >> reporting any issue.
> >>> ::: Messages without supporting info will risk being sent to
> /dev/null
> >>>
> >>
> >>
> >> -------------------------------------------------------
> >> SF email is sponsored by - The IT Product Guide
> >> Read honest & candid reviews on hundreds of IT Products from real
> users.
> >> Discover which products truly live up to the hype. Start reading now.
> >> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> >> _______________________________________________
> >> Nagios-users mailing list
> >> Nagios-users at lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/nagios-users
> >> ::: Please include Nagios version, plugin version (-v) and OS when
> reporting
> >> any issue.
> >> ::: Messages without supporting info will risk being sent to
> /dev/null
> >>
> >
> >
> >
> >
> >
> >
> > -------------------------------------------------------
> > SF email is sponsored by - The IT Product Guide
> > Read honest & candid reviews on hundreds of IT Products from real
> users.
> > Discover which products truly live up to the hype. Start reading now.
> > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> > _______________________________________________
> > Nagios-users mailing list
> > Nagios-users at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/nagios-users
> > ::: Please include Nagios version, plugin version (-v) and OS when
> reporting
> > any issue.
> > ::: Messages without supporting info will risk being sent to /dev/null
> >
>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_ide95&alloc_id396&op=cick
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> ::: Please include Nagios version, plugin version (-v) and OS when reporting
> any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
>






-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list