[hobbit] Check for hosts without alerts

Josh Luthman josh at imaginenetworksllc.com
Mon Jun 2 23:28:15 CEST 2008


Beautiful!   Thank you for sharing this.



On 6/2/08, Stewart L <stewartl42 at gmail.com> wrote:
> 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.
>


-- 
Josh Luthman
Office: 937-552-2340
Direct: 937-552-2343
1100 Wayne St
Suite 1337
Troy, OH 45373

Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer



More information about the Xymon mailing list