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

1.1     ! andrew      1: #!/usr/bin/perl
        !             2: # $RedRiver$
        !             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:
        !            55:        #print $host, ": ", $server, "-", $id, ": ",
        !            56:        #       (scalar localtime($hosts->{$host}->{'Checked'})), "\n";
        !            57:
        !            58:        print <<EOL;
        !            59: define host {
        !            60:        use        $template
        !            61:        host_name  ${server}-${id}
        !            62:        alias      $host
        !            63:        address    $name
        !            64: }
        !            65: EOL
        !            66:
        !            67: }

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