>>Свой обработчик ipcad показываешь?
>
>
>Могу тока оно довольно специализированное....
и лишнего много, ну вообщем на скрипт который ТОЛЬКО снимает с ipcad'а и раскидывает по моим табличкам в mysql (там-же ещё агрегация всего барахла нужна ну и т.д.):
#!/usr/bin/perl
use DBI;
use Time::localtime;
use Net::IP::Match;
$database = 'db_name';
$dbuser = 'db_user';
$dbpassword = 'db_passw';
$net_prefix = '192.168';
$dbh = DBI->connect("DBI:mysql:${database}", $dbuser, $dbpassword)
or die $DBI::errstr;
$tm = localtime;
$Date = sprintf("%4d-%02d-%02d %02d:%02d:%02d",$tm->year+1900,($tm->mon)+1,$tm->mday,$tm->hour,$tm->min,$tm->sec);
$cur_time = sprintf("%02d:%02d:%02d",$tm->hour,$tm->min,$tm->sec);
$cur_date = sprintf("%04d-%02d",$tm->year+1900,($tm->mon)+1);
$cur_date_full = sprintf("%04d-%02d-%02d",$tm->year+1900,($tm->mon)+1,$tm->mday);
my (%hAll_in,%hWWW_in,%hAll_out,%hPOP_in,%hSMTP_out,@ips, %hips);
$sql = "SELECT `ip` FROM `ips` WHERE `user_id`!='0';";
my $sth = $dbh->prepare( $sql ) or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
my ($ip);
$rv = $sth->bind_columns(\($ip));
while ($sth->fetch) {
if ($ip eq ''){next;};
$hAll_in{$ip} = 0;
$hWWW_in{$ip} = 0;
$hAll_out{$ip} = 0;
$hPOP_in{$ip} = 0;
$hSMTP_out{$ip} = 0;
@ips = (@ips, $ip);
$hips{$ip} = 0;
};
$sql = "SELECT `ppp_ip` FROM `ips` WHERE `user_id`!='0';";
my $sth = $dbh->prepare( $sql ) or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
my ($ppp_ip);
$rv = $sth->bind_columns(\($ppp_ip));
while ($sth->fetch) {
if ($ppp_ip eq ''){next;};
$hAll_in{$ppp_ip} = 0;
$hWWW_in{$ppp_ip} = 0;
$hAll_out{$ppp_ip} = 0;
$hPOP_in{$ppp_ip} = 0;
$hSMTP_out{$ppp_ip} = 0;
@ips = (@ips, $ppp_ip);
$hips{$ppp_ip} = 0;
};
$Routers{'10.0.0.1'} = 1;
`/usr/bin/rsh -l traffic 10.0.0.1 clear ip accounting checkpoint`;
foreach $ip (keys %Routers) {
`/usr/bin/rsh -l traffic $ip clear ip accounting`;
@Stat = split(/\n/,`/usr/bin/rsh -l traffic $ip sh ip accounting checkpoint`);
`/usr/bin/rsh -l traffic $ip clear ip accounting checkpoint`;
$sql = "LOCK TABLES `traffic_temp_day` WRITE;";
my $sth = $dbh->prepare( $sql );
$sth->execute;
foreach $s (@Stat) {
if ($s !~ /^\s\d{1,3}\./) { next; }
$s =~ s/^\s+//;
$s =~ s/\s+/ /g;
my @Row = split (/ /, $s);
my @Dst = split (/\./, $Row[1]);
next if ($Row[3] eq 48);
$ip = "$Dst[0].$Dst[1].$Dst[2].$Dst[3]";
if ((exists($hips{$ip})) || (exists($hips{$Row[0]}))){
$sql = "INSERT INTO `traffic_temp_day` (`Day`,`FromIP`,`X12`,`X3`,`X4`,`Bytes`) VALUES (\'$Date\', '$Row[0]', '$Dst[0].$Dst[1]', '$Dst[2]', '$Dst[3]', '$Row[3]');";
my $sth = $dbh->prepare( $sql );
$sth->execute;
};
};
$sql = "UNLOCK TABLES;";
my $sth = $dbh->prepare( $sql );
$sth->execute;
};
`/usr/bin/rsh -l traffic 10.0.0.1 clear ip accounting checkpoint`;
$sql = "SELECT `Day`,`X12`,`X3`,`X4`,SUM(`Bytes`),`FromIP` FROM `traffic_temp_day` WHERE ((`Day` LIKE \'$cur_date_full%\') AND (`X12`=\'$net_prefix\' OR `X12`='192.168' OR `X12`='194.67')) GROUP BY `X3`,`X4`,`FromIP`";
my $sth = $dbh->prepare( $sql ) or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
my ($Day,$X12,$X3,$X4,$Bytes,$FromIP);
$rv = $sth->bind_columns(\($Day,$X12,$X3,$X4,$Bytes,$FromIP));
while ($sth->fetch) {
$ip = $X12.'.'.$X3.'.'.$X4;
if (&check_ip($FromIP) eq 1){next;};
$hAll_in{$ip} = $hAll_in{$ip} + $Bytes;
};
$sql = "SELECT `Day`,`FromIP`,SUM(`Bytes`),`X12`,`X3`,`X4` FROM `traffic_temp_day` WHERE ((`Day` LIKE \'$cur_date_full%\') AND (`FromIP` LIKE \'$net_prefix.%\' OR `FromIP` LIKE '192.168.0.%' OR `FromIP` LIKE '194.67.181.%')) GROUP BY `X12`,`X3`,`X4`,`FromIP`";
my $sth = $dbh->prepare( $sql ) or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
my ($Day,$FromIP,$Bytes,$X12,$X3,$X4);
$rv = $sth->bind_columns(\($Day,$FromIP,$Bytes,$X12,$X3,$X4));
while ($sth->fetch) {
$ToIP = $X12.'.'.$X3.'.'.$X4;
if (&check_ip($ToIP) eq 1){
next;
}else{
$hAll_out{$FromIP} = $hAll_out{$FromIP} + $Bytes;
};
};
$sql = "DELETE FROM `days_stat` WHERE `Day`=\'$cur_date_full\'";
my $sth = $dbh->prepare( $sql ) or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
foreach $key ( keys %hAll_in){
if (exists($hips{$key})){
$sql = "INSERT INTO `days_stat` (`IP`,`Day`,`All_in`,`WWW_in`,`POP_in`,`All_out`,`SMTP_out`) VALUES (\'$key\',\'$cur_date_full\',\'$hAll_in{$key}\',\'$hWWW_in{$key}\',\'$hPOP_in{$key}\',\'$hAll_out{$key}\',\'$hSMTP_out{$key}\');";
my $sth = $dbh->prepare( $sql ) or die $DBI::errstr;
$sth->execute or die $DBI::errstr;
};
};
$rc = $dbh->disconnect;
`/usr/bin/rsh -l traffic 10.0.0.1 clear ip accounting checkpoint`;
$tm = localtime;
$cur_time = sprintf("%02d:%02d:%02d",$tm->hour,$tm->min,$tm->sec);
exit;
sub check_ip{
my ($FromIP) = @_;
my ($drop) = 0;
######OUR_NETS########
if (__MATCH_IP($FromIP, qw{10.0.0.0/8})) {$drop = 1;goto ret_val;};
if (__MATCH_IP($FromIP, qw{10.0.0.0/16})) {$drop = 1;goto ret_val;};
if (__MATCH_IP($FromIP, qw{10.0.0.0/24})) {$drop = 1;goto ret_val;};
if (__MATCH_IP($FromIP, qw{192.168.0.0/24})) {$drop = 1;goto ret_val;};
######B_CAST########
if ($FromIP eq '10.0.0.255'){$drop = 1;goto ret_val;};
if ($FromIP eq '192.168.0.255'){$drop = 1;goto ret_val;};
######OUR_HOSTS########
if ($FromIP eq '10.0.0.1'){$drop = 1;goto ret_val;};
if ($FromIP eq '10.0.0.2'){$drop = 1;goto ret_val;};
if ($FromIP eq '192.168.0.1'){$drop = 1;goto ret_val;};
##########################
ret_val:
return ($drop);
};