#!/usr/bin/perl # $RedRiver: make_wireless_client_config,v 1.2 2007/01/12 21:55:08 andrew Exp $ ######################################################################## # make_wireless_client_config *** Generate the Nagios config file we # need for wireless clients. # # 2006.09.08 #*#*# andrew fresh ######################################################################## use strict; use warnings; use Storable qw(lock_store lock_retrieve); my $Only_Generate_Newer_Than = 1 * 24 * 60 * 60; # 1 day my $TurboCell_Template = 'generic-host-wireless-karlnet-client'; my $Trango_Template = 'generic-host-wireless-trango-client'; my $file = shift || die "first argument needs to be name of file to process"; die "file '$file' does not exist" unless -e $file; 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 (sort keys %{ $hosts }) { next if $when > $hosts->{$host}->{'Checked'}; next if $host =~ /^rr\w{6}\d{4}$/i; my $server; my $id; my $name; my $template; 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; } next unless $server && $id; my $server_uc = uc($server); #print $host, ": ", $server, "-", $id, ": ", # (scalar localtime($hosts->{$host}->{'Checked'})), "\n"; print <