Check for hosts without alerts
list Stewart L
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.
list Stewart L
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 <user-a046134cfd06@xymon.invalid> 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.
list Josh Luthman
Beautiful! Thank you for sharing this.
▸
On 6/2/08, Stewart L <user-a046134cfd06@xymon.invalid> 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 <user-a046134cfd06@xymon.invalid> 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: XXX-XXX-XXXX
Direct: XXX-XXX-XXXX
XXXX Wayne St
Suite XXXX
Troy, OH XXXXX
Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer
list T.J. Yang
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" <user-4c45a83f15cb@xymon.invalid>
Sent: Monday, June 02, 2008 4:28 PM
To: <user-ae9b8668bcde@xymon.invalid>
Subject: Re: [hobbit] Check for hosts without alerts
Beautiful! Thank you for sharing this. On 6/2/08, Stewart L <user-a046134cfd06@xymon.invalid> 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 <user-a046134cfd06@xymon.invalid> 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: XXX-XXX-XXXX Direct: XXX-XXX-XXXX XXXX Wayne St Suite XXXX Troy, OH XXXXX Those who don't understand UNIX are condemned to reinvent it, poorly. --- Henry Spencer