[mrtg] Re: GetLog Modification

Jerry Heidtke jheidtke at fmlh.edu
Tue Feb 4 22:42:56 MET 2003


This should work. It uses a third command line parameter, just like the
second, which names the log item to return.

Jerry

# getlog2.pl
#
# Author: Paul Simmonson
#
# Input: filename of Windows 2000 Performance monitor log file (must be CSV
format)
# Name of log item to extract
# eg. perl getlog-fixed.pl c:\perflogs\K6.csv "\\K6\LogicalDisk(C:)\% Disk
Time"
# Output: mrtg data format
#
$STUFF=@ARGV[0];
open STUFF or die "Cannot open $STUFF for read :$!";
@entries = <STUFF>;
@details=split /,/, @entries[0]; #get the first line of the log file
@lastline=split /,/, @entries[$#entries]; #get last line of log file

#find the entry that matches $ARGV[1]
$index=-1;
for $entry (@details) {
   $index++;
   $entry=~ tr/"//d;
   chomp ($entry);
   $last=$entry;
   last if $entry eq $ARGV[1];
}

if ($last eq $ARGV[1]) {
   $data1=@lastline[$index];
   $data1=~ tr/"//d;
   $data1 = int($data1+0.5);
} else {
   $data1 = 0;
}

#find the entry that matches $ARGV[2]
$index=-1;
for $entry (@details) {
   $index++;
   $entry=~ tr/"//d;
   chomp ($entry);
   $last=$entry;
   last if $entry eq $ARGV[2];
}

if ($last eq $ARGV[2]) {
   $data2=@lastline[$index];
   $data2=~ tr/"//d;
   $data2 = int($data2+0.5);
} else {
   $data2 = 0;
}
print "$data1\n";
print "$data2\n";
print "0\n";
print "0\n"; 

-----Original Message-----
From: Brander, Eric [mailto:Eric.Brander at ACS-INC.com] 
Sent: Tuesday, February 04, 2003 2:43 PM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] GetLog Modification



I'm using Paul Simmonson's GetLog.pl Perl script to parse information from a
Winblows Performance Monitor CSV file.  I'd like to modify that perl, or a
copy of that perl file actually, to be able to parse two items from a csv
instead of just one. Unfortunately, I just don't have the time to do learn
Perl right now. Has anyone made this modification already and are willing to
share? Here is the original for reference:

#start script
# getlog.pl
#
# Author: Paul Simmonson
#
# Input: filename of Windows 2000 Performance monitor log file (must be CSV
format)
# Name of log item to extract
# eg. perl getlog-fixed.pl c:\perflogs\K6.csv "\\K6\LogicalDisk(C:)\% Disk
Time"
# Output: mrtg data format
#
$STUFF=@ARGV[0];
open STUFF or die "Cannot open $STUFF for read :$!";
@entries = <STUFF>;
@details=split /,/, @entries[0]; #get the first line of the log file
@lastline=split /,/, @entries[$#entries]; #get last line of log file

#find the entry that matches $ARGV[1]
$index=-1;
for $entry (@details) {
    $index++;
    $entry=~ tr/"//d;
    chomp ($entry);
    $last=$entry;
    last if $entry eq $ARGV[1];
}

if ($last eq $ARGV[1]) {
    $data=@lastline[$index];
    $data=~ tr/"//d;
    $data = int($data+0.5);
} else {
    $data = 0;
}
print "0\n";
print "$data\n";
print "0\n";
print "0\n";

#end script

TIA!

Eric Brander
ACS
Texas CHIP Account
Sr. Communications Engineer - Information Systems Department
512.336.3331
Eric dot Brander at acs-inc dot com

--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi


Confidentiality Notice: This e-mail message, including any attachments, is 
for the sole use of the intended recipient(s) and may contain confidential 
and privileged information.  Any unauthorized review, use, disclosure or 
distribution is prohibited.  If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list