Annotation of nagios/check_rrd/bin/make_wireless_client_config, Revision 1.6
1.1 andrew 1: #!/usr/bin/perl
1.6 ! andrew 2: # $RedRiver: make_wireless_client_config,v 1.5 2007/01/22 17:55:04 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:
1.4 andrew 29: my %nagios_hosts;
30: foreach my $AP (sort keys %{ $hosts }) {
31: next if $when > $hosts->{$AP}->{'Checked'};
32: next unless $AP =~ /^rr\w{6}\d{4}$/i;
33:
34: my @clients;
35: push @clients, keys %{ $hosts->{$AP}->{'Info'}->{'suRemarks'} };
36: push @clients, keys %{ $hosts->{$AP}->{'Info'}->{'Wireless_Host_Name'} };
37:
38: #print Dumper $AP, \@clients;
39:
1.6 ! andrew 40: foreach my $id (sort @clients) {
1.4 andrew 41: my $host;
42: my $name;
43: my $template;
44: my $nagios_host;
45:
46: if ($hosts->{$AP}->{'Host'}->{'Type'} =~ /Trango$/) {
47: $host = $hosts->{$AP}->{'Info'}->{'suRemarks'}->{$id};
48: $name = $hosts->{$host}->{'Host'}->{'name'};
1.6 ! andrew 49: $nagios_host = $AP . '-' . $id;
1.4 andrew 50: $template = $Trango_Template;
51: } elsif ($hosts->{$AP}->{'Host'}->{'Type'} =~ /TurboCell$/) {
52: $host = $hosts->{$AP}->{'Info'}->{'Wireless_Host_Name'}->{$id};
53: $name = $hosts->{$host}->{'Host'}->{'name'};
1.6 ! andrew 54: $nagios_host = $AP . '-' . $host;
1.4 andrew 55: $template = $TurboCell_Template;
56: } else {
57: next;
58: }
59:
1.6 ! andrew 60: next if ! $host;
! 61: next if $host =~ /^rr\w{6}\d{4}$/i;
! 62:
! 63: next if ! $name;
! 64: #next if ! $name =~ / \A \d{1,3}\. \d{1,3}\. \d{1,3}\. \d{1,3} \z /xms
1.4 andrew 65:
66: next if exists $nagios_hosts{$nagios_host};
67: $nagios_hosts{$nagios_host}++;
1.1 andrew 68:
1.4 andrew 69: my $AP_uc = uc($AP);
1.2 andrew 70:
1.4 andrew 71: #print $host, ": ", $AP, "-", $id, ": ",
72: # (scalar localtime($hosts->{$host}->{'Checked'})), "\n";
1.1 andrew 73:
1.4 andrew 74: print <<EOL;
1.1 andrew 75: define host {
76: use $template
1.4 andrew 77: host_name $nagios_host;
1.1 andrew 78: alias $host
79: address $name
1.4 andrew 80: parents $AP_uc
1.1 andrew 81: }
82: EOL
1.4 andrew 83:
84: }
1.1 andrew 85:
86: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>