Annotation of nagios/check_rrd/bin/host2rrd, Revision 1.4
1.1 andrew 1: #!/usr/bin/perl -T
1.4 ! andrew 2: # $RedRiver: host2rrd,v 1.3 2007/03/20 22:40:20 andrew Exp $
1.1 andrew 3: ########################################################################
4: # hostalias2filename *** figures out the filename for a wireless
5: # customer to pass to a script.
6: #
7: # 2007.01.10 #*#*# andrew fresh <andrew@mad-techies.org>
8: ########################################################################
9: use strict;
10: use warnings;
11:
12: use Data::Dumper;
13:
14: %ENV = ();
15:
16: use Getopt::Long;
17:
18: my $basedir = '/var/www/wstationinfo';
19: my $Host;
1.3 andrew 20: my $Host_Suffix = '';
1.1 andrew 21: my $RRD;
1.4 ! andrew 22: my $Host_To_Lower;
1.1 andrew 23:
24: #Option checking
25: my $status = GetOptions(
1.3 andrew 26: "host|H=s" => \$Host,
27: "suffix|S=s" => \$Host_Suffix,
28: "rrd|r=s" => \$RRD,
29: "path|p=s" => \$basedir,
1.4 ! andrew 30: "tolower|l" => \$Host_To_Lower,
1.1 andrew 31: );
32:
1.3 andrew 33:
1.2 andrew 34: die "No host passes!" unless $Host;
1.1 andrew 35: die "No RRD passed!" unless $RRD;
1.4 ! andrew 36:
! 37: if ($Host_To_Lower) {
! 38: $Host = lc $Host;
! 39: }
1.1 andrew 40:
1.3 andrew 41:
1.1 andrew 42: my ($server, $client) = split /-/, $Host, 2;
43:
1.3 andrew 44: my $filename = $basedir . '/' . $Host . $Host_Suffix . $RRD . '.rrd';
45:
46: if ($client) {
47: $filename = $basedir . '/' . $server . '/' . $Host . $Host_Suffix .
48: '-' . $RRD . '.rrd';
49: }
1.1 andrew 50:
51: print $filename, "\n";
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>