[hobbit] Check for hosts without alerts

T.J. Yang tj_yang at hotmail.com
Tue Jun 3 03:15:06 CEST 2008


collected into hobbit howto wiki.

http://en.wikibooks.org/wiki/System_Monitoring_with_Hobbit/Other_Docs/HOWTO#How_can_I_check_if_host_is_not_configured_for_alerting_.3F



tj
--------------------------------------------------
From: "Josh Luthman" <josh at imaginenetworksllc.com>
Sent: Monday, June 02, 2008 4:28 PM
To: <hobbit at hswn.dk>
Subject: Re: [hobbit] Check for hosts without alerts

> 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
>
> To unsubscribe from the hobbit list, send an e-mail to
> hobbit-unsubscribe at hswn.dk
>
>
> 



More information about the Xymon mailing list