2 |
|
|
3 |
# based on work of Eric Wong <eric@taedium.net> |
# based on work of Eric Wong <eric@taedium.net> |
4 |
# available at http://www.taedium.net/rrd-iptraf/ [iptraf.txt] |
# available at http://www.taedium.net/rrd-iptraf/ [iptraf.txt] |
5 |
|
# |
6 |
|
# Dobrica Pavlinusic <dpavlin@rot13.org> |
7 |
|
# http://www.rot13.org/~dpavlin/sysadm.html |
8 |
|
# |
9 |
|
# Usage: parse_iptraf.pl [name of iptraf logfile] |
10 |
|
|
11 |
use strict; |
use strict; |
12 |
use warnings; |
use warnings; |
62 |
close(LOG); |
close(LOG); |
63 |
|
|
64 |
foreach my $port (@PORTS) { |
foreach my $port (@PORTS) { |
65 |
print @{$hash{$port}}[0] || 0,"\n",@{$hash{$port}}[1] || 0,"\n"; |
print @{$hash{$port}}[0] || "U","\n",@{$hash{$port}}[1] || "U","\n"; |
66 |
delete $hash{$port}; |
delete $hash{$port}; |
67 |
} |
} |
68 |
|
|
72 |
$sum_in+=@{$hash{$port}}[0]; |
$sum_in+=@{$hash{$port}}[0]; |
73 |
$sum_out+=@{$hash{$port}}[1]; |
$sum_out+=@{$hash{$port}}[1]; |
74 |
} |
} |
75 |
|
|
76 |
|
$sum_in = "U" if ($sum_in == 0); |
77 |
|
$sum_out = "U" if ($sum_out == 0); |
78 |
print "$sum_in\n$sum_out\n"; |
print "$sum_in\n$sum_out\n"; |