When using
AcctColumnDef, you can tell Radiator to log a particular attribute by its
integer value, which is what I want to do. Unfortunately, I'm not using
AcctColumnDef, I'm using my own AcctSQLStatement for more flexibility.
Specifically, I'm using the following:
AcctSQLStatement \
insert into accounting set \
mailbox = '%U', \
domain = '%R', \
timestamp = from_unixtime(%{Timestamp}), \
statustype = '%{Acct-Status-Type}', \
ipaddress = '%{Framed-IP-Address}', \
inputoctets = '%{Acct-Input-Octets}', \
outputoctets = '%{Acct-Output-Octets}', \
sessionid = '%{Acct-Session-Id}', \
terminatecause = '%{Acct-Terminate-Cause}', \
ascendcause = '%{Ascend-Disconnect-Cause}', \
nasipaddress = '%N', \
nasport = '%{NAS-Port}', \
nasporttype = '%{NAS-Port-Type}', \
servicetype = '%{Service-Type}', \
callednumber = '%{Called-Station-Id}', \
callingnumber = '%{Calling-Station-Id}'
I've omitted the
rest of the config...it all works fine. Note that 1) from_unixtime is a mysql
function, so don't go looking for it, and 2) this "insert into table SET" syntax
is not standard SQL, but mysql supports it, and this syntax works
fine.
My question is, how
can I make certain attributes (specifically Status-Type, Terminate-Cause, and
Ascend-Disconnect-Cause) log as integers instead of strings. Is there a
corresponding %-substitution that would give me the integer?
If there's is no
such %-substitution, then it occurred to me to use a PreClientHook to add a
pseudo-attribute containing the integer, and then log that in the
SQL statement (or with AcctColumnDef, for that matter), so that no translation
is done, with something like:
$request->changeattr('Acct-Terminate-Cause-Int', \
$request->getAttrByNum($Radius::Radius::ACCT_TERMINATE_CAUSE));
I believe this would
work fine for the well-known attributes, but one of the attributes I want to do
this with is vendor-specific (Ascend-Disconnect-Cause), and being the neophyte
perl programmer I am, I don't see a way to get to the integer information. Come
to think of it, i would PREFER this solution, because I'm then free to massage
the data a bit more and store either Acct-Terminate-Cause or
Ascend-Disconnect-Cause in a single field in the database, since each NAS only
sends one or the other. To tell them apart, I'd add 1000 to the value if its an
Ascend-Disconnect-Cause.
So my
question becomes: Within a hook, how do I get the integer value of
a vendor-specific-attribute instead of its string value from the
dictionary?