Check for hosts without alerts

Stewart L stewartl42 at gmail.com
Mon Jun 2 16:32:42 CEST 2008


worked one out myself... Let me know if there is an easier way...

#!/usr/bin/perl

##########################################################################################
#
# no-alerts.pl - This script uses bbhostgrep to get a list of sevrers, then
fetches their
#       info test.  It then parses this looking for 'No Alerts Defined' It
then outputs
#       hostname of the machines that are missing alert config.
#
#       Created by Stewart Larsen
#
##########################################################################################


use strict;
use LWP::Simple;

# Set debug to 1 to see the hosts and URL as you loop through.
my $debug = 0;

#Token in bb-hosts to indicate we need to run firewall tests on this device
my $test_name = '*';

#server to poll for information
my $BBDISP = "192.168.1.1";


# Paths - Fetch all hosts and trim for just the host name.  Then sort and
unique the list
my $BBHOSTGREP="/usr/lib/hobbit/server/bin/bbhostgrep '*'| /bin/cut -d' '
-f2 | /bin/sort  | /usr/bin/uniq";

open (INPUT, "-|",$BBHOSTGREP ) or die "Cannot open input: $!\n";
while(<INPUT>)
{
        chomp (my $host = $_);
        my $fetch_URL = 'http://
'.$BBDISP.'/hobbit-cgi/bb-hostsvc.sh?HOST='.$host.'&SERVICE=info';
        print "$host: $fetch_URL\n" if $debug;

        my $content = get $fetch_URL;
        if (!defined $content)
        {
                warn "Couldn't get $fetch_URL";
                next;
        }

        if($content =~ m/No Alerts Defined/i)
        {
                print "$host has no alerts defined\n";
        }
}
close INPUT;




On Mon, Jun 2, 2008 at 8:53 AM, Stewart L <stewartl42 at gmail.com> wrote:

> Is there an easy way to check for hosts without alerts defined?   I have
> about 4000 hosts being monitored and some do not have alerts defined.   I
> would hate to have to check the info test for each of those manually.
>
>
> --
> Stewart
>
> You only lose what you cling to.




-- 
Stewart

You only lose what you cling to.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20080602/dae2b84f/attachment.html>


More information about the Xymon mailing list