=================================================================== RCS file: /cvs/nagios/check_rrd/bin/make_wireless_client_config,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- nagios/check_rrd/bin/make_wireless_client_config 2007/10/03 16:16:42 1.6 +++ nagios/check_rrd/bin/make_wireless_client_config 2009/12/24 18:19:51 1.7 @@ -1,9 +1,9 @@ #!/usr/bin/perl -# $RedRiver: make_wireless_client_config,v 1.5 2007/01/22 17:55:04 andrew Exp $ +# $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,67 +20,56 @@ 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; my %nagios_hosts; -foreach my $AP (sort keys %{ $hosts }) { - next if $when > $hosts->{$AP}->{'Checked'}; - next unless $AP =~ /^rr\w{6}\d{4}$/i; +foreach my $alias ( sort keys %{$hosts} ) { + next if $alias =~ /[^[:print:]]/xms; - my @clients; - push @clients, keys %{ $hosts->{$AP}->{'Info'}->{'suRemarks'} }; - push @clients, keys %{ $hosts->{$AP}->{'Info'}->{'Wireless_Host_Name'} }; + my $host = $hosts->{$alias}; + next if $when > $host->{'Checked'}; - #print Dumper $AP, \@clients; + $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; - foreach my $id (sort @clients) { - my $host; - my $name; - my $template; - my $nagios_host; + 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; + } - 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; - } + next if !$AP; + next if $AP !~ /^rr\w{6}\d{4}/ixms; - next if ! $host; - next if $host =~ /^rr\w{6}\d{4}$/i; + my $nagios_host = $AP . '-' . $id; + next if exists $nagios_hosts{$nagios_host}; + $nagios_hosts{$nagios_host}++; - next if ! $name; - #next if ! $name =~ / \A \d{1,3}\. \d{1,3}\. \d{1,3}\. \d{1,3} \z /xms + my $AP_uc = uc($AP); - next if exists $nagios_hosts{$nagios_host}; - $nagios_hosts{$nagios_host}++; + #print $host, ": ", $AP, "-", $id, ": ", + # (scalar localtime($hosts->{$host}->{'Checked'})), "\n"; - my $AP_uc = uc($AP); - - #print $host, ": ", $AP, "-", $id, ": ", - # (scalar localtime($hosts->{$host}->{'Checked'})), "\n"; - - print <