Annotation of nagios/check_rrd/bin/make_wireless_client_config, Revision 1.2
1.1 andrew 1: #!/usr/bin/perl
1.2 ! andrew 2: # $RedRiver: make_wireless_client_config,v 1.1 2007/01/12 15:58:34 andrew Exp $
1.1 andrew 3: ########################################################################
4: # make_wireless_client_config *** Generate the Nagios config file we
5: # need for wireless clients.
6: #
7: # 2006.09.08 #*#*# andrew fresh <andrew@mad-techies.org>
8: ########################################################################
9: use strict;
10: use warnings;
11:
12: use Storable qw(lock_store lock_retrieve);
13:
14: my $Only_Generate_Newer_Than = 1 * 24 * 60 * 60; # 1 day
15: my $TurboCell_Template = 'generic-host-wireless-karlnet-client';
16: my $Trango_Template = 'generic-host-wireless-trango-client';
17:
18: my $file = shift || die "first argument needs to be name of file to process";
19: die "file '$file' does not exist" unless -e $file;
20:
21: my $hosts = lock_retrieve($file) || die "Couldn't open '$file': $!";
22:
23: #use Data::Dumper;
24: #print Dumper $hosts;
25:
26: my $now = time;
27: my $when = $now - $Only_Generate_Newer_Than;
28:
29: foreach my $host (keys %{ $hosts }) {
30: next if $when > $hosts->{$host}->{'Checked'};
31: next if $host =~ /^rr\w{6}\d{4}$/i;
32:
33: my $server;
34: my $id;
35: my $name;
36: my $template;
37:
38: if ($hosts->{$host}->{'Host'}->{'Type'} =~ /Trango_Client$/) {
39: $server = $hosts->{$host}->{'Info'}->{'Wireless_Host_Name'}->{'id_0'};
40: $id = 'id_' . $hosts->{$host}->{'Host'}->{'ID'};
41: $name = $hosts->{$host}->{'Host'}->{'name'};
42: $template = $Trango_Template;
43: } elsif ($hosts->{$host}->{'Host'}->{'Type'} =~ /TurboCell$/) {
44: $server = $hosts->{$host}->{'Host'}->{'comment'};
45: $id = $host;
46: $name = $hosts->{$host}->{'Host'}->{'name'};
47: $template = $TurboCell_Template;
48: } else {
49: next;
50: }
51:
52: next unless $server && $id;
53:
54:
1.2 ! andrew 55: my $server_uc = uc($server);
! 56:
1.1 andrew 57: #print $host, ": ", $server, "-", $id, ": ",
58: # (scalar localtime($hosts->{$host}->{'Checked'})), "\n";
59:
60: print <<EOL;
61: define host {
62: use $template
63: host_name ${server}-${id}
64: alias $host
65: address $name
1.2 ! andrew 66: parents $server_uc
1.1 andrew 67: }
68: EOL
69:
70: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>