to dhcpd.conf
[code]
on commit {
set ClientIP = binary-to-ascii(10, 8, ".", leased-address);
set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
set SwMac = "";
set SwPort = "";
set VLAN = "";
set LTime = binary-to-ascii (10,32,"",encode-int (lease-time,32));
set ClientName = option host-name;
if exists agent.circuit-id
{
set SwMac = binary-to-ascii(16, 8, ":", option agent.remote-id);
set SwPort = binary-to-ascii(10, 8, ":", suffix(option agent.circuit-id, 1));
set VLAN = binary-to-ascii(10, 16,"",substring(option agent.circuit-id, 2, 2));
}
execute("/usr/local/bin/perl", "/usr/local/etc/dhcp/log.pl","commit", ClientIP, ClientMac, SwMac, SwPort,VLAN, LTime, ClientName);
}
to log.pl
#!/usr/local/bin/perl
use DBI;
$Config="/usr/local/nodeny/sat.cfg";
(-e $Config ) or "error sat.cfg";
eval{require $Config};
$DSN="DBI:mysql:database=$Db_name;host=$Db_server;mysql_connect_timeout=$Db_mysql_connect_timeout";
$dbh=DBI->connect($DSN,$Db_user,$Db_pw,{PrintError=>1});
@ms=split/\:/,$ARGV[3];
$ms[2]="0".$ms[2] if (length($ms[2]) != 2);
$ms[3]="0".$ms[3] if (length($ms[3]) != 2);
$ms[4]="0".$ms[4] if (length($ms[4]) != 2);
$ms[5]="0".$ms[5] if (length($ms[5]) != 2);
$ms[6]="0".$ms[6] if (length($ms[6]) != 2);
$ms[7]="0".$ms[7] if (length($ms[7]) != 2);
$ms=$ms[2].":".$ms[3].":".$ms[4].":".$ms[5].":".$ms[6].":".$ms[7];
if (length($ms) == 17)
{
$sth=$dbh->prepare("INSERT INTO user_dhcp set ip='$ARGV[1]' ,mac='$ARGV[2]',swmac='$ms',swport='$ARGV[4]',vlan='$ARGV[5]',liase='$ARGV[6]',nname='$ARGV[7]',clname='$ARGV[8]',time=UNIX_TIMESTAMP()");
$sth->execute;
}
1;
ну где-то так....[/code]