Splitting and comparing file names
- From: "Jake" <Jake.Newly@xxxxxxxxx>
- Date: 14 Dec 2006 08:46:50 -0800
Thanks to some help on another thread I have a perl script that will
generate a file in the following format:
hostname#val1#val2#val3.load
The existing script will run localling on a each of three servers and
post to a SAN location. (various reasons why we couldn't use rsh or
ssh from a central resource to gather this data...grrrr)
The idea now is to read in each of the file names, generate a mean
(meanval = (val1+val2+val3)/3) and then compare the mean between the
three systems to determine the server with the lowest average load for
the past 15 minutes. I'm at the point where I'm not sure exactly how
to manage the split and then be able to run equations against the
values. Here's what I have so far to pull in the file to an array.
Perhaps there is a more efficient method of gathering that information
as well...
#!/usr/bin/perl
use strict;
use warning;
my ($hostname, $val1, $val2, $val3, $filename, @filesfound);
chdir ("/store/admin/tools/load");
opendir (DIR, "/store/admin/tools/load") || die "Directory not
found or unable to be opened. $!\n";
@filesfound = sort (grep (/\.load$/, readdir(DIR)));
if ( ! @filesfound) {
die ("None of the load files were found. Please verify that
the writeLoad.pl script is running properly. $!\n");
closedir(DIR);
}
else {
foreach $filename(@filesfound) {
# This is where I'm having the major issue with my own
logic...
# I probably have myself going down a bad path :p
};
Any ideas would be great. Keep in mind that I'm not a developer and
I'm sitting down with perl books and the internet to try to figure this
out. :)
At the moment I'm trying to read through and find information for
manipulating array data and I must admit that I'm just not getting it
yet.
Jake
.
- Follow-Ups:
- Re: Splitting and comparing file names
- From: Paul Lalli
- Re: Splitting and comparing file names
- From: boyd
- Re: Splitting and comparing file names
- Prev by Date: Re: use Net::SMTP with Exchange server
- Next by Date: Re: Splitting and comparing file names
- Previous by thread: Yet another parsing question
- Next by thread: Re: Splitting and comparing file names
- Index(es):
Relevant Pages
|