[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.4

1.1       andrew      1: #!/usr/bin/perl
1.4     ! andrew      2: # $RedRiver: make_wireless_client_config,v 1.3 2007/01/13 00:04:51 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;
        !            61:
        !            62:                next if exists $nagios_hosts{$nagios_host};
        !            63:                $nagios_hosts{$nagios_host}++;
1.1       andrew     64:
1.4     ! andrew     65:                my $AP_uc = uc($AP);
1.2       andrew     66:
1.4     ! andrew     67:                #print $host, ": ", $AP, "-", $id, ": ",
        !            68:                #       (scalar localtime($hosts->{$host}->{'Checked'})), "\n";
1.1       andrew     69:
1.4     ! andrew     70:                print <<EOL;
1.1       andrew     71: define host {
                     72:        use        $template
1.4     ! andrew     73:        host_name  $nagios_host;
1.1       andrew     74:        alias      $host
                     75:        address    $name
1.4     ! andrew     76:        parents    $AP_uc
1.1       andrew     77: }
                     78: EOL
1.4     ! andrew     79:
        !            80:        }
1.1       andrew     81:
                     82: }

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