Re: скрипты и фильтры для ip accounting
Отправлено: Сергей on October 29, 1999 at 12:00:41:
В ответ на: Re: скрипты и фильтры для ip accounting posted by Vladko on October 28, 1999 at 14:47:48:
> Можно взглянуть на эту программульку? #!/usr/bin/perl use strict; use DBI(); #our networks my $own; my $any; $own = "195.222.18[3,4].[0-9]{1,3}"; $any = "[0-9,'.']+"; `rsh ciscohost cle ip acco`; `rsh ciscohost sh ip acco check >/dir/ciscotraf`; $_=''; # Connect to the database. my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost", "dbuser", "",{'RaiseError' => 1}); open traf, "/dir/ciscotraf"; while (){ #incoming if ($_=~/\b($own)\s*\b($any)\s*\b(\d+)\s*\b(\d+)/){ $dbh->do("INSERT INTO traffic VALUES ( CurDate(), CurTime(), " . "'$1','$2',null,$4" . ")"); } #outgoing if ($_=~/\b($any)\s*\b($own)\s*\b(\d+)\s*\b(\d+)/){ $dbh->do("INSERT INTO traffic VALUES ( CurDate(), CurTime(), " . "'$2','$1',$4,null" . ")"); } } # Disconnect from the database. $dbh->disconnect();
Отклики:
Написать ответ
|