On Fri, 2005-03-04 at 16:56 +0200, Mark Elkins wrote:
> On Wed, 2005-03-02 at 13:19 +0200, Mark Elkins wrote:
>
> > I want to collect the current allocate IP address and username into a
> > separate MySql table - if it (the user (=key)) exists - update the IP,
> > if the user does not exist, add user and IP.
> >
> > I (think that I) understand that I need to have a second instance of
> > 'sql'..
>
> Phew - it works.... (exactly as I documented :)
Might have spoken too soon.... I'm getting... (in radius.log)
Error: rlm_sql (sql_catch_ip): Couldn't insert SQL accounting START
record - Duplicate entry 'mcsa' for key 2
mcsa is a username - my table looks like....
CREATE TABLE dnstab (
dnsid int(10) unsigned NOT NULL auto_increment,
username varchar(64) NOT NULL default '',
realm varchar(64) NOT NULL default '',
ip varchar(16) NOT NULL default '',
dated timestamp(14) NOT NULL,
PRIMARY KEY (dnsid),
UNIQUE KEY username (username)
) TYPE=MyISAM;
Table dump includes....
INSERT INTO dnstab VALUES
(4,'mcsa','myddns.com','160.160.100.100',20050304175854);
My 'sql_catch_ip' (in 'sql.conf') has two SQL statements...
accounting_start_query = "INSERT into dnstab (username, realm, ip)
values('%{Stripped-User-Name}', '%{Realm}', '%{Framed-IP-Address}')"
accounting_start_query_alt = "UPDATE dnstab SET
ip='%{Framed-IP-Address}' WHERE username='%{Stripped-User-Name}' and
realm='%{Realm}'"
My understanding is that if there is an SQL error from
accounting_start_query - that accounting_start_query_alt would be
automatically tried - without any error report - or should I be using
the username as the key instead? (or probably the username and realm
concatenated....), again I could probably use one of those cute new
mysql commands that does "update" instead of "insert" if a key
exists..but what is FreeRadius meant to do?
--
. . ___. .__ Posix Systems - Sth Africa. e.164 VOIP ready
/| /| / /__ [EMAIL PROTECTED] - Mark J Elkins, Cisco CCIE
/ |/ |ARK \_/ /__ LKINS Tel: +27 12 807 0590 Cell: +27 82 601 0496
-
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html