hotsanic |
Subversion Repositories: |
Rev 6 | Rev 7 | |
---|---|---|
Line 39... | Line 39... | |
|
| |
foreach my $nn (sort(keys(%acct_int))) { |
foreach my $nn (sort(keys(%acct_int))) { | |
$otherin=$acct_int{$nn}[1]-$acct_int_old{$nn}[1]; |
$otherin=$acct_int{$nn}[1]-$acct_int_old{$nn}[1]; | |
$tcpin=$acct_int{$nn}[3]-$acct_int_old{$nn}[3]; |
$tcpin=$acct_int{$nn}[3]-$acct_int_old{$nn}[3]; | |
$udpin=$acct_int{$nn}[5]-$acct_int_old{$nn}[5]; |
$udpin=$acct_int{$nn}[5]-$acct_int_old{$nn}[5]; | |
$icmpin=$acct_int{$nn}[7]-$acct_int_old{$nn}[7]; |
||
$otherout=$acct_int{$nn}[2]-$acct_int_old{$nn}[2]; |
$otherout=$acct_int{$nn}[2]-$acct_int_old{$nn}[2]; | |
$tcpout=$acct_int{$nn}[4]-$acct_int_old{$nn}[4]; |
$tcpout=$acct_int{$nn}[4]-$acct_int_old{$nn}[4]; | |
$udpout=$acct_int{$nn}[6]-$acct_int_old{$nn}[6]; |
$udpout=$acct_int{$nn}[6]-$acct_int_old{$nn}[6]; | |
$icmpout=$acct_int{$nn}[8]-$acct_int_old{$nn}[8]; |
||
updatedb($args{MODNAME},$time,"int$nn",$tcpin,$udpin,$otherin,$tcpout,$udpout,$otherout); |
updatedb($args{MODNAME},$time,"int$nn",$tcpin,$udpin,$otherin,$tcpout,$udpout,$otherout); | |
} |
} | |
|
| |
foreach my $nn (sort(keys(%acct_ext))) { |
foreach my $nn (sort(keys(%acct_ext))) { | |
$otherin=$acct_ext{$nn}[1]-$acct_ext_old{$nn}[1]; |
$otherin=$acct_ext{$nn}[1]-$acct_ext_old{$nn}[1]; | |
$tcpin=$acct_ext{$nn}[3]-$acct_ext_old{$nn}[3]; |
$tcpin=$acct_ext{$nn}[3]-$acct_ext_old{$nn}[3]; | |
$udpin=$acct_ext{$nn}[5]-$acct_ext_old{$nn}[5]; |
$udpin=$acct_ext{$nn}[5]-$acct_ext_old{$nn}[5]; | |
$icmpin=$acct_ext{$nn}[7]-$acct_ext_old{$nn}[7]; |
||
$otherout=$acct_ext{$nn}[2]-$acct_ext_old{$nn}[2]; |
$otherout=$acct_ext{$nn}[2]-$acct_ext_old{$nn}[2]; | |
$tcpout=$acct_ext{$nn}[4]-$acct_ext_old{$nn}[4]; |
$tcpout=$acct_ext{$nn}[4]-$acct_ext_old{$nn}[4]; | |
$udpout=$acct_ext{$nn}[6]-$acct_ext_old{$nn}[6]; |
$udpout=$acct_ext{$nn}[6]-$acct_ext_old{$nn}[6]; | |
$icmpout=$acct_ext{$nn}[8]-$acct_ext_old{$nn}[8]; |
||
updatedb($args{MODNAME},$time,"ext$nn",$tcpin,$udpin,$otherin,$tcpout,$udpout,$otherout); |
updatedb($args{MODNAME},$time,"ext$nn",$tcpin,$udpin,$otherin,$tcpout,$udpout,$otherout); | |
} |
} | |
} |
} | |
|
| |
sub readfile { |
sub readfile { | |
Line 75... | Line 71... | |
if ($dst eq "") { ($proto,$opt,$in,$out,$src,$dst)=($target,$proto,$opt,$in,$out,$src); } |
if ($dst eq "") { ($proto,$opt,$in,$out,$src,$dst)=($target,$proto,$opt,$in,$out,$src); } | |
if ($src eq "0.0.0.0/0") { $ip=$dst;$dir=1; } elsif ($dst eq "0.0.0.0/0") { $ip=$src;$dir=0; } |
if ($src eq "0.0.0.0/0") { $ip=$dst;$dir=1; } elsif ($dst eq "0.0.0.0/0") { $ip=$src;$dir=0; } | |
if ($proto eq "all") { $prt=1 }; |
if ($proto eq "all") { $prt=1 }; | |
if ($proto eq "tcp") { $prt=3 }; |
if ($proto eq "tcp") { $prt=3 }; | |
if ($proto eq "udp") { $prt=5 }; |
if ($proto eq "udp") { $prt=5 }; | |
if ($proto eq "icmp") { $prt=7 }; |
||
if ($ip ne "") {$hash{"$ip"}[$prt+$dir]=$bytes;} |
if ($ip ne "") {$hash{"$ip"}[$prt+$dir]=$bytes;} | |
} |
} | |
} |
} | |
close (FILE); |
close (FILE); | |
return %hash; |
return %hash; | |
} |
} | |
|
| |
sub updatedb { |
sub updatedb { | |
my ($MODNAME,$time,$name,$tcpin,$udpin,$icmpin,$tcpout,$udpout,$icmpout)=@_; |
my ($MODNAME,$time,$name,$tcpin,$udpin,$otherin,$tcpout,$udpout,$otherout)=@_; | |
$name =~ s/\//_/g; |
$name =~ s/\//_/g; | |
if ( !-e "rrd/$name.rrd") { system "./makerrd $name U"; } |
if ( !-e "rrd/$name.rrd") { system "./makerrd $name U"; } | |
RRDs::update "rrd/$name.rrd",$time.":".$tcpin.":".$udpin.":".$icmpin.":".$tcpout.":".$udpout.":".$icmpout; |
RRDs::update "rrd/$name.rrd",$time.":".$tcpin.":".$udpin.":".$otherin.":".$tcpout.":".$udpout.":".$otherout; | |
if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$name.rrd': $ERROR\n"; } |
if ($ERROR = RRDs::error) { print time," ",$MODNAME,": unable to update `$name.rrd': $ERROR\n"; } | |
} |
} | |
|
| |
|
| |
1; |
1; |