[BACK]Return to host2rrd CVS log [TXT][DIR] Up to [local] / nagios / check_rrd / bin

File: [local] / nagios / check_rrd / bin / host2rrd (download)

Revision 1.4, Tue Mar 20 22:56:29 2007 UTC (17 years, 2 months ago) by andrew
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +7 -1 lines

add the ability to lowercase the host

#!/usr/bin/perl -T
# $RedRiver: host2rrd,v 1.3 2007/03/20 22:40:20 andrew Exp $
########################################################################
# hostalias2filename *** figures out the filename for a wireless 
#                        customer to pass to a script.
# 
# 2007.01.10 #*#*# andrew fresh <andrew@mad-techies.org>
########################################################################
use strict;
use warnings;

use Data::Dumper;

%ENV = ();

use Getopt::Long;

my $basedir = '/var/www/wstationinfo';
my $Host;
my $Host_Suffix = '';
my $RRD;
my $Host_To_Lower;

#Option checking
my $status = GetOptions(
    "host|H=s"   => \$Host,
    "suffix|S=s" => \$Host_Suffix,
    "rrd|r=s"    => \$RRD,
    "path|p=s"   => \$basedir,
    "tolower|l"  => \$Host_To_Lower,
);


die "No host passes!" unless $Host;
die "No RRD passed!"  unless $RRD;

if ($Host_To_Lower) {
    $Host = lc $Host;
}


my ($server, $client) = split /-/, $Host, 2;

my $filename = $basedir . '/' . $Host . $Host_Suffix . $RRD . '.rrd';

if ($client) {
    $filename = $basedir . '/' . $server . '/' . $Host . $Host_Suffix . 
        '-' . $RRD . '.rrd';
}

print $filename, "\n";