[mrtg] Re: Regexp statement for parsing the logfile?..

brandon.baker brandon.baker at inforonics.com
Fri Dec 12 21:19:10 MET 2003


Richard,

I don't use regexp.  But here is how I parse the log file in perl.


open(LOG,"$mrtgdir_dir\\$logfile") or next;  #opens each logfile
       	for $linedata (<LOG>) {
    	 	 my ($rawtime,$rawin,$rawout,$rawmaxin,$rawmaxout) = split(/
/,$linedata);   #Get's values out of each line of logfile
}


Brandon





Brandon Baker
Manager, Security & Network Services
Inforonics, Inc
Voice: (978) 698-7458
Email: brandon.baker at inforonics.com


-----Original Message-----
From: Richard Whittaker [mailto:RWHITTAKER at nwtel.ca]
Sent: Friday, December 12, 2003 2:05 PM
To: mrtg at list.ee.ethz.ch
Subject: [mrtg] Regexp statement for parsing the logfile?..


Greetings:

I'm trying to parse the .log files from MRTG in a PERL script using regexp,
and I'm having some difficulty.. I'd like to parse the file, and put the
datestamp, first, and second values into variables for further processing..

This is the regexp statement I'm using, and I'm not getting the results I
expected.. 

if ($_=~/(.*)\s{1,}(.*)\s{1,}(.*)\s{1,}(.*)\s{1,}(.*)/)

For instance:

shaggy:~ # cat /usr/local/apache/htdocs/nettrace/prddbs/dbquery-tbsprd.log |
./test.pl | more
 
1071255300 48 8 2933 495
 
2003121212105500   8    2933
1071255000 2927 494 2933 495
 
2003121212105000   494    2933
1071254700 2712 492 4131 495
 
2003121212104500   492    4131
1071254400 4109 494 4131 495
 
2003121212104000   494    4131
1071254100 3072 491 3075 500
 
2003121212103500   491    3075
1071253800 2929 500 2944 501
 
2003121212103000   500    2944
1071253500 1871 501 2070 533
 
2003121212102500   501    2070
1071253200 2071 537 2158 860
 
2003121212102000   537    2158
1071252900 2148 852 2158 860
 
2003121212101500   852    2158
1071252600 1715 489 3059 490
 
2003121212101000   489    3059
1071252300 3097 488 4697 490


Regards,
Richard.


Richard Whittaker, CISSP
System Manager
NorthwesTel Inc.
Whitehorse, YK
(867) 393-7756


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

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