*** LAN traffic log, generated Thu Jul 14 17:49:44 2005 Ethernet address: 009096c7cf98 (ADSL Modem) Incoming total 297089 packets, 45056408 bytes; 293887 IP packe +ts Outgoing total 401212 packets, 252051283 bytes; 398003 IP pack +ets Average rates: 0.47 kbytes/s incoming, 2.63 kbytes/s outgoing Last 5-second rates: 0.00 kbytes/s incoming, 0.00 kbytes/s out +going Ethernet address: 0020ed7924c2 (Debian Router ext) Incoming total 401212 packets, 252051283 bytes; 398003 IP pack +ets Outgoing total 297096 packets, 45056702 bytes; 293887 IP packe +ts Average rates: 2.63 kbytes/s incoming, 0.47 kbytes/s outgoing Last 5-second rates: 0.00 kbytes/s incoming, 0.00 kbytes/s out +going
I am then wanted to organise and sort the data from the log file appropriately. This is where i require some help. How can i create a hash thats primary key is the MAC Address which points to its corresponding name (eg Debian Router), and other details such as Incoming total packets , Outgoing etc. MAC ADDRESS ---> NAME --> Debian Router Incoming --> 21311 Outgoing --> 12112 Average Rate --> 4.0 I understand their is a bit of work in this script, but some heads up on how to structure this array for creating and writing. Or should i directly begin inserting data in the database rather than reading it into an associate array?my $LOGFILE = "iptraf.log"; open(LOGFILE, $LOGFILE) or die("Could not open log file."); foreach my $line (<LOGFILE>) { #chomp($line); }
In reply to How to Process Log file by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |