Syslog - Nagios?

Martijn Lievaart m at rtij.nl
Thu Mar 2 16:00:22 CET 2006


Mike Koponick zei:
> I would like to send Syslog information from a remote Nagios sensor to
> the Central Server via NSCA, since it's already in place.
>
>
>
> I'm trying to see if there is a feasible way to parse out the
> information I need, using something like SWATCH and send it to the
> Central Server, who should be able to send it to a MySQL server.
>
>
>
> I was thinking that I might be able to write the parsed out information
> to the Nagios command file, but I don't think that would work. My
> thinking is that if it was written to the Nagios command file that I
> would be able to send it the parsed out information via the Nagios
> process, but I might be WAY off base.
>
>
>
> Has anyone ever done anything like this before?

I found swatch to be unreliable. Don't remember why, but I cooked up the
following perl script. It sends mail and is hardwired for a certain event,
but it should get you started. BTW you need gnu tail for this.

#!/usr/bin/perl -w
use warnings;
use strict;

$| = 1;

my $p;
open $p, "tail --follow=name /var/log/nagios/nagios.log |" or die "Cannot
open pipe: $!";

while (<$p>) {
    /Warning:.*The service could not be found/ and do {
        use Mail::Sendmail;

        my %mail = ( To      => '<munged>',
                     From    => 'nagioswatcher@<munged>',
                     Subject => 'WARNING: unknown service result',
                     Message => $_
                     );

        sendmail(%mail) or die $Mail::Sendmail::error;
    };
}

Cheers,
M4





-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
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