[mrtg] Re: Getlog.pl
Jerry Heidtke
jheidtke at fmlh.edu
Fri Aug 23 00:11:52 MEST 2002
You didn't include your target line from your config, so it's hard to
determine just what the problem is.
The csv file must be on the local system, not a remote system. You must use
fully qualified path names in the target. You must use back-ticks (`), and
not apostrophes ('). These are the commonest mistakes.
As a troublshooting method, try running the command within the backticks
from a command prompt. That way, you can see any error messages that the
script might generate.
I use lines such as:
Target[NETMGMTNT04-Network_Interface1]: `perl c:\mrtg\bin\getlog2.pl
c:\mrtghtml\NETMGMTNT04.csv \
"\\NETMGMTNT04\Network Interface(Compaq Ethernet_Fast Ethernet
Adapter_Module)\Bytes Received/sec" \
"\\NETMGMTNT04\Network Interface(Compaq Ethernet_Fast Ethernet
Adapter_Module)\Bytes Sent/sec"`
(Above all on one line, obviously.)
I use it with rrdtool, not rateup. This shouldn't make a difference, since
the script only returns integers.
I modified getlog.pl to read and return two values from the csv files. This
could probably be done more efficiently, but I never claimed to be a perl
wiz. Script is below.
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: Eric VDB [mailto:ericvdb500 at hotmail.com]
Sent: Thursday, August 22, 2002 4:52 PM
To: MRTG List
Subject: [mrtg] Getlog.pl
Hi all,
i used the following getlog.pl file to read a .csv file created by w2k
performance counter.
When i use it it returns : ERROR: Skipping webupdates because rateup did not
return anything sensible
Any idea...
# getlog.pl
#
# Author: Paul Simmonson
#
# Edited to work with dot (instead of period) as an decimal symbol: Matti
"maz" Kullberg
#
# 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=@entries[$#entries]; #get last line of log file
#find the entry that matches $ARGV[1]
$index=-1;
for $entry (@details) {
@lastline[$entry]=~ s/(\"\d+)\,(\d+\")/$1\.$2/g;
$index++;
$entry=~ tr/"//d;
chomp ($entry);
$last=$entry;
last if $entry eq $ARGV[1];
}
@lastline=split/,/, @lastline[$entry];
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";
Greetings Eric
--
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