[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Check for hosts without alerts
- To: "Hobbit Mailing List" <hobbit (at) hswn.dk>
- Subject: Re: Check for hosts without alerts
- From: "Stewart L" <stewartl42 (at) gmail.com>
- Date: Mon, 2 Jun 2008 10:32:42 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=IcaKZETMm4uTAF4P0PDU8dB1Ea4Qju1Uhd+LwKqFELw=; b=jPgyo6M8qPRumwIiaTbaLNPwkMHD477kSQkhFDEpvnLShDn8gDztPC54qHEVZk+fioiLPHnH3Mku0kOaUEiEGvoSvRXmb2gC2+aqd4Yyew4IfcNUEPhXP1E2WCT6udSUvyheyVmP8sfU3fzzYKa98MkR0Pt5P4iH5x41TWzucIo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=AbZyw8lqVsH54EANl/H6AIcNzFUL0J+OFpCvURDzaxIiS66PyUsdP3L+wNvGk3iQ53bFBJXDeAqw57e/yH7aXeGC3Q09ttlvEvz0RfG+s8xfRz/fD0v1Y2IfnPUkDlZTtk297w0F1T+WA9V/yMt7vMXtOBLotHb1PwegTfJa55c=
- References: <1d23acab0806020553v429d7b7dl1097a820bd2d844f (at) mail.gmail.com>
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.