=================================================================== RCS file: /cvs/nagios/check_rrd/bin/make_wireless_client_config,v retrieving revision 1.1 retrieving revision 1.7 diff -u -r1.1 -r1.7 --- nagios/check_rrd/bin/make_wireless_client_config 2007/01/12 15:58:34 1.1 +++ nagios/check_rrd/bin/make_wireless_client_config 2009/12/24 18:19:51 1.7 @@ -1,9 +1,9 @@ #!/usr/bin/perl -# $RedRiver$ +# $RedRiver: make_wireless_client_config,v 1.6 2007/10/03 15:16:42 andrew Exp $ ######################################################################## -# make_wireless_client_config *** Generate the Nagios config file we +# make_wireless_client_config *** Generate the Nagios config file we # need for wireless clients. -# +# # 2006.09.08 #*#*# andrew fresh ######################################################################## use strict; @@ -11,7 +11,7 @@ use Storable qw(lock_store lock_retrieve); -my $Only_Generate_Newer_Than = 1 * 24 * 60 * 60; # 1 day +my $Only_Generate_Newer_Than = 90 * 24 * 60 * 60; # 90 days my $TurboCell_Template = 'generic-host-wireless-karlnet-client'; my $Trango_Template = 'generic-host-wireless-trango-client'; @@ -20,47 +20,55 @@ my $hosts = lock_retrieve($file) || die "Couldn't open '$file': $!"; -#use Data::Dumper; -#print Dumper $hosts; - my $now = time; my $when = $now - $Only_Generate_Newer_Than; -foreach my $host (keys %{ $hosts }) { - next if $when > $hosts->{$host}->{'Checked'}; - next if $host =~ /^rr\w{6}\d{4}$/i; +my %nagios_hosts; +foreach my $alias ( sort keys %{$hosts} ) { + next if $alias =~ /[^[:print:]]/xms; - my $server; - my $id; - my $name; - my $template; + my $host = $hosts->{$alias}; + next if $when > $host->{'Checked'}; - if ($hosts->{$host}->{'Host'}->{'Type'} =~ /Trango_Client$/) { - $server = $hosts->{$host}->{'Info'}->{'Wireless_Host_Name'}->{'id_0'}; - $id = 'id_' . $hosts->{$host}->{'Host'}->{'ID'}; - $name = $hosts->{$host}->{'Host'}->{'name'}; - $template = $Trango_Template; - } elsif ($hosts->{$host}->{'Host'}->{'Type'} =~ /TurboCell$/) { - $server = $hosts->{$host}->{'Host'}->{'comment'}; - $id = $host; - $name = $hosts->{$host}->{'Host'}->{'name'}; - $template = $TurboCell_Template; - } else { - next; - } + $alias =~ s/^\s+|\s+$//gxms; + my $name = $host->{'Host'}->{name}; + next if !$name; + next if !$name =~ / \A \d{1,3}\. \d{1,3}\. \d{1,3}\. \d{1,3} \z /xms; - next unless $server && $id; + my ($id, $AP, $template); + if ( $host->{'Host'}->{'Type'} =~ /Trango_Client$/ ) { + $id = 'id_' . $host->{'Host'}->{ID}; + $AP = $host->{'Info'}->{'Wireless_Host_Name'}->{id_0}; + $template = $Trango_Template; + } + elsif ( $host->{'Host'}->{'Type'} =~ /TurboCell$/ ) { + $id = $alias; + $AP = $host->{'Info'}->{'Wireless_Host_Name'}->{id_1}; + $template = $TurboCell_Template; + } + else { + next; + } + next if !$AP; + next if $AP !~ /^rr\w{6}\d{4}/ixms; - #print $host, ": ", $server, "-", $id, ": ", - # (scalar localtime($hosts->{$host}->{'Checked'})), "\n"; + my $nagios_host = $AP . '-' . $id; + next if exists $nagios_hosts{$nagios_host}; + $nagios_hosts{$nagios_host}++; - print <{$host}->{'Checked'})), "\n"; + + print <