Iptables/Traffic/Tabelizer
Od HLDS.pl
(Różnice między wersjami)
Aktualna wersja na dzień 20:50, 28 wrz 2009
#!/usr/bin/perl # # Tabelizer - tabelize IPTABLES Output system ('mv /Traffic.tbl /Traffic.tbl.bak'); open (OUTFILE,">/Traffic.tbl") || die "Output file not writeable: $!\n"; open (INFILE,"</Traffic.dat") || die "Input file not readable: $!\n"; print OUTFILE "Time\tDay\tDay\tMonth\tYear\tupstream\tdownstream\tweb\tmail\n"; while (<INFILE>) { # read from stdin if (/(^\w{3})\s+(\w{3})\s+(\d{1,2})\s(\d{2}[:]\d{2}[:]\d{2})\sCEST\s(\d{4})/) { $Day=$1; $Month=$2; $Nday=$3; $Time=$4; $Year=$5; print OUTFILE "\n$Time\t$Day\t$Nday\t$Month\t$Year\t"; next; } elsif (/\s+(\d+)\s+(\d+)\s/) { $Packets=$1; $Bytes=$2; print OUTFILE "$Bytes\t"; next; } else {next} } print OUTFILE "\n"; close (OUTFILE); close (INFILE); system ('mv /Traffic.dat /Traffic.dat.bak');