/[cricket]/parse_iptraf.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /parse_iptraf.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Mon May 20 16:03:16 2002 UTC (17 years, 1 month ago) by dpavlin
Branch: MAIN
Changes since 1.1: +1 -2 lines
File MIME type: text/plain
real log location

1 #!/usr/bin/perl
2
3 # based on work of Eric Wong <eric@taedium.net>
4 # available at http://www.taedium.net/rrd-iptraf/ [iptraf.txt]
5
6 use strict;
7 use warnings;
8
9 use Time::Local;
10
11 my @PORTS = qw (
12 TCP/22 TCP/25 TCP/20 TCP/21 UDP/53
13 TCP/80 TCP/110 TCP/113 TCP/119 UDP/137 UDP/138
14 TCP/210 TCP/443 UDP/514 );
15
16 my $log = '/var/log/iptraf/tcp_udp_services-eth1.log';
17
18 open(LOG,$log) || die "Can't open logfile '$log': $!";
19
20 my %hash;
21
22 while (<LOG>) {
23 chomp;
24 last if ( m/^Running/ );
25 next if ( m/^\s*$/ );
26
27 ## read data for tcp packets
28 if (my ($port) = $_ =~ m/^(\w+\/\d+)/) {
29 my ($packs, $bytes, $pack_in, $byte_in, $pack_out, $byte_out) =
30 $_ =~ m/\s(\d+)\s/g;
31
32 $hash{$port} = [$byte_in, $byte_out];
33 }
34 }
35
36 close(LOG);
37
38 foreach my $port (@PORTS) {
39 print @{$hash{$port}}[0] || 0,"\n",@{$hash{$port}}[1] || 0,"\n";
40 }

  ViewVC Help
Powered by ViewVC 1.1.26