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

1.1       andrew      1: #!/usr/bin/perl
1.7     ! andrew      2: # $RedRiver: make_wireless_client_config,v 1.6 2007/10/03 15:16:42 andrew Exp $
1.1       andrew      3: ########################################################################
1.7     ! andrew      4: # make_wireless_client_config *** Generate the Nagios config file we
1.1       andrew      5: #                                 need for wireless clients.
1.7     ! andrew      6: #
1.1       andrew      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:
1.7     ! andrew     14: my $Only_Generate_Newer_Than = 90 * 24 * 60 * 60;    # 90 days
1.1       andrew     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: my $now  = time;
                     24: my $when = $now - $Only_Generate_Newer_Than;
                     25:
1.4       andrew     26: my %nagios_hosts;
1.7     ! andrew     27: foreach my $alias ( sort keys %{$hosts} ) {
        !            28:     next if $alias =~ /[^[:print:]]/xms;
        !            29:
        !            30:     my $host = $hosts->{$alias};
        !            31:     next if $when > $host->{'Checked'};
1.1       andrew     32:
1.7     ! andrew     33:     $alias =~ s/^\s+|\s+$//gxms;
        !            34:     my $name = $host->{'Host'}->{name};
        !            35:     next if !$name;
        !            36:     next if !$name =~ / \A \d{1,3}\. \d{1,3}\. \d{1,3}\. \d{1,3} \z /xms;
        !            37:
        !            38:     my ($id, $AP, $template);
        !            39:     if ( $host->{'Host'}->{'Type'} =~ /Trango_Client$/ ) {
        !            40:         $id       = 'id_' . $host->{'Host'}->{ID};
        !            41:         $AP       = $host->{'Info'}->{'Wireless_Host_Name'}->{id_0};
        !            42:         $template = $Trango_Template;
        !            43:     }
        !            44:     elsif ( $host->{'Host'}->{'Type'} =~ /TurboCell$/ ) {
        !            45:         $id       = $alias;
        !            46:         $AP       = $host->{'Info'}->{'Wireless_Host_Name'}->{id_1};
        !            47:         $template = $TurboCell_Template;
        !            48:     }
        !            49:     else {
        !            50:         next;
        !            51:     }
        !            52:
        !            53:     next if !$AP;
        !            54:     next if $AP !~ /^rr\w{6}\d{4}/ixms;
        !            55:
        !            56:     my $nagios_host = $AP . '-' . $id;
        !            57:     next if exists $nagios_hosts{$nagios_host};
        !            58:     $nagios_hosts{$nagios_host}++;
1.2       andrew     59:
1.7     ! andrew     60:     my $AP_uc = uc($AP);
1.1       andrew     61:
1.7     ! andrew     62:     #print $host, ": ", $AP, "-", $id, ": ",
        !            63:     #  (scalar localtime($hosts->{$host}->{'Checked'})), "\n";
        !            64:
        !            65:     print <<EOL;
1.1       andrew     66: define host {
                     67:        use        $template
1.7     ! andrew     68:        host_name  $nagios_host
        !            69:        alias      $alias
1.1       andrew     70:        address    $name
1.4       andrew     71:        parents    $AP_uc
1.1       andrew     72: }
                     73: EOL
                     74:
                     75: }

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