[mrtg] Re: getlog.pl to monitor two instances

Eric Brander Eric_Mailing_List at rednarb.com
Fri Jun 18 21:57:57 MEST 2004


Daniel C wrote:
> Is it possible to monitor two performance counters
> with Getlog.pl?  For example, this is what I would
> like to be able to graph on one single graph
> 
> Target[TCPReset]: `perl getlog.pl
> d:\Perflogs\ISA01.csv "\\local\TCPv4\Connections
> Reset"`&`perl getlog.pl d:\Perflogs\ISA01.csv
> "\\local\TCPv4\Connections
> Failures"`
> 
> As of the moment, when I run the config file with this
> target, MRTG is only logging the Connections Failures
> and not both.  
> 
> Any help is greatly appreciated.  Thanks
> 
> 

I hacked my getlog.pl and made a getlog_two.pl. I'm no perl scripter so 
this may not be the ideal way to do this but it works great.

# getlog_two.pl
#
# Author: Paul Simmonson
#
# Modified by Eric Brander to get 2 targets from one CSV.
#
# Input: filename of Windows 2000 Performance monitor log file (must be 
CSV format)
# Name of log item to extract
# eg. perl getlog_two.pl c:\perflogs\K6.csv "\\K6\LogicalDisk(C:)\% Disk 
Time" "\\K6\LogicalDisk(D:)\% 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]) {
     $dataI=@lastline[$index];
     $dataI=~ tr/"//d;
     $dataI = int($dataI+0.5);
} else {
     $dataI = "Not Found";
}


#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]) {
     $dataO=@lastline[$index];
     $dataO=~ tr/"//d;
     $dataO = int($dataO+0.5);
} else {
     $dataO = "Not Found";
}


print "$dataI\n";
print "$dataO\n";
print "0\n";
print "0\n";

### End of script

Enjoy.

Eric Brander

--
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