[BACK]Return to make_wireless_client_config CVS log [TXT][DIR] Up to [local] / nagios / check_rrd / bin

Annotation of nagios/check_rrd/bin/make_wireless_client_config, Revision 1.5

1.1       andrew      1: #!/usr/bin/perl
1.5     ! andrew      2: # $RedRiver: make_wireless_client_config,v 1.4 2007/01/22 16:40:52 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:
                     40:        foreach my $id (@clients) {
                     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'};
                     49:                        $nagios_host = "${AP}-${id}";
                     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'};
                     54:                        $nagios_host = "${AP}-${host}";
                     55:                        $template = $TurboCell_Template;
                     56:                } else {
                     57:                        next;
                     58:                }
                     59:
                     60:                next unless $host;
1.5     ! andrew     61:                next if $host =~ /^rr\w{6}\d{4}$/i;
1.4       andrew     62:
                     63:                next if exists $nagios_hosts{$nagios_host};
                     64:                $nagios_hosts{$nagios_host}++;
1.1       andrew     65:
1.4       andrew     66:                my $AP_uc = uc($AP);
1.2       andrew     67:
1.4       andrew     68:                #print $host, ": ", $AP, "-", $id, ": ",
                     69:                #       (scalar localtime($hosts->{$host}->{'Checked'})), "\n";
1.1       andrew     70:
1.4       andrew     71:                print <<EOL;
1.1       andrew     72: define host {
                     73:        use        $template
1.4       andrew     74:        host_name  $nagios_host;
1.1       andrew     75:        alias      $host
                     76:        address    $name
1.4       andrew     77:        parents    $AP_uc
1.1       andrew     78: }
                     79: EOL
1.4       andrew     80:
                     81:        }
1.1       andrew     82:
                     83: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>