File: [local] / nagios / check_rrd / bin / make_wireless_client_config (download)
Revision 1.3, Sat Jan 13 00:04:51 2007 UTC (17 years, 8 months ago) by andrew
Branch: MAIN
Changes since 1.2: +2 -2 lines
check if the files are different before updating. To that end, sort the order that we output them so that there is a better chance they are.
|
#!/usr/bin/perl
# $RedRiver: make_wireless_client_config,v 1.2 2007/01/12 21:55:08 andrew Exp $
########################################################################
# make_wireless_client_config *** Generate the Nagios config file we
# need for wireless clients.
#
# 2006.09.08 #*#*# andrew fresh <andrew@mad-techies.org>
########################################################################
use strict;
use warnings;
use Storable qw(lock_store lock_retrieve);
my $Only_Generate_Newer_Than = 1 * 24 * 60 * 60; # 1 day
my $TurboCell_Template = 'generic-host-wireless-karlnet-client';
my $Trango_Template = 'generic-host-wireless-trango-client';
my $file = shift || die "first argument needs to be name of file to process";
die "file '$file' does not exist" unless -e $file;
my $hosts = lock_retrieve($file) || die "Couldn't open '$file': $!";
#use Data::Dumper;
#print Dumper $hosts;
my $now = time;
my $when = $now - $Only_Generate_Newer_Than;
foreach my $host (sort keys %{ $hosts }) {
next if $when > $hosts->{$host}->{'Checked'};
next if $host =~ /^rr\w{6}\d{4}$/i;
my $server;
my $id;
my $name;
my $template;
if ($hosts->{$host}->{'Host'}->{'Type'} =~ /Trango_Client$/) {
$server = $hosts->{$host}->{'Info'}->{'Wireless_Host_Name'}->{'id_0'};
$id = 'id_' . $hosts->{$host}->{'Host'}->{'ID'};
$name = $hosts->{$host}->{'Host'}->{'name'};
$template = $Trango_Template;
} elsif ($hosts->{$host}->{'Host'}->{'Type'} =~ /TurboCell$/) {
$server = $hosts->{$host}->{'Host'}->{'comment'};
$id = $host;
$name = $hosts->{$host}->{'Host'}->{'name'};
$template = $TurboCell_Template;
} else {
next;
}
next unless $server && $id;
my $server_uc = uc($server);
#print $host, ": ", $server, "-", $id, ": ",
# (scalar localtime($hosts->{$host}->{'Checked'})), "\n";
print <<EOL;
define host {
use $template
host_name ${server}-${id}
alias $host
address $name
parents $server_uc
}
EOL
}