=================================================================== RCS file: /cvs/nagios/check_rrd/bin/make_wireless_client_config,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- nagios/check_rrd/bin/make_wireless_client_config 2007/01/13 00:04:51 1.3 +++ nagios/check_rrd/bin/make_wireless_client_config 2007/01/22 16:40:52 1.4 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $RedRiver: make_wireless_client_config,v 1.2 2007/01/12 21:55:08 andrew Exp $ +# $RedRiver: make_wireless_client_config,v 1.3 2007/01/13 00:04:51 andrew Exp $ ######################################################################## # make_wireless_client_config *** Generate the Nagios config file we # need for wireless clients. @@ -26,45 +26,57 @@ my $now = time; my $when = $now - $Only_Generate_Newer_Than; -foreach my $host (sort keys %{ $hosts }) { - next if $when > $hosts->{$host}->{'Checked'}; - next if $host =~ /^rr\w{6}\d{4}$/i; +my %nagios_hosts; +foreach my $AP (sort keys %{ $hosts }) { + next if $when > $hosts->{$AP}->{'Checked'}; + next unless $AP =~ /^rr\w{6}\d{4}$/i; - my $server; - my $id; - my $name; - my $template; + my @clients; + push @clients, keys %{ $hosts->{$AP}->{'Info'}->{'suRemarks'} }; + push @clients, keys %{ $hosts->{$AP}->{'Info'}->{'Wireless_Host_Name'} }; - 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; - } + #print Dumper $AP, \@clients; - next unless $server && $id; + foreach my $id (@clients) { + my $host; + my $name; + my $template; + my $nagios_host; + if ($hosts->{$AP}->{'Host'}->{'Type'} =~ /Trango$/) { + $host = $hosts->{$AP}->{'Info'}->{'suRemarks'}->{$id}; + $name = $hosts->{$host}->{'Host'}->{'name'}; + $nagios_host = "${AP}-${id}"; + $template = $Trango_Template; + } elsif ($hosts->{$AP}->{'Host'}->{'Type'} =~ /TurboCell$/) { + $host = $hosts->{$AP}->{'Info'}->{'Wireless_Host_Name'}->{$id}; + $name = $hosts->{$host}->{'Host'}->{'name'}; + $nagios_host = "${AP}-${host}"; + $template = $TurboCell_Template; + } else { + next; + } - my $server_uc = uc($server); + next unless $host; - #print $host, ": ", $server, "-", $id, ": ", - # (scalar localtime($hosts->{$host}->{'Checked'})), "\n"; + next if exists $nagios_hosts{$nagios_host}; + $nagios_hosts{$nagios_host}++; - print <{$host}->{'Checked'})), "\n"; + + print <