DB Value Lookup Issue

Gabriel Marais gabriel.j.marais at gmail.com
Wed Jun 10 21:22:58 CEST 2020


Good evening users,

I am currently trying to resolve an issue with calculating the
difference between the value of acctinputoctets and acctoutputoctets
from a MySQL lookup and the latest interim update received from the
carrier.

My calculation is currently in the preacct section which looks like this:-

preacct {
        preprocess
                if("%{sql:SELECT count(*) from radacct where
acctsessionid = '%{Acct-Session-Id}'}" >= 1) {

                update request {

        Acct-Diff = "%{sql:SELECT greatest(0, ('%{Acct-Input-Octets}'
+ '%{Acct-Output-Octets}') - (acctinputoctets + acctoutputoctets)) as
diff from radacct where acctsessionid = '%{Acct-Session-Id}'}"

                                        }

        }


The query works fine, until the values from the radacct table
(acctinputoctets + acctoutputoctets) are greater than 4 294 967 296
for the particular acctsessionid. When the value is larger than that
we get 0. Under that we get the actual difference.


*Above 4 294 967 296                   Wed Jun 10 15:27:17 2020 :
Debug: (12)   Acct-Diff = "0"

*Below 4 294 967 296                    Tue Jun  9 15:10:42 2020 :
Debug: (9)   Acct-Diff += "254631"


I changed the dictionary entry for Acct-Diff from Integer to String.
The calculation works again until the number is greater than
4294967296.

I suspect what might be happening is the sum (acctinputoctets +
acctoutputoctets) is getting treated as two integer values. So when
they reach a value higher than 4294967296 the calculation does not
work and sends 0 due to the SQL SELECT greatest(0,

I was hoping someone on the list would be able to point me in the
right direction...

Many thanks,
Gabriel


More information about the Freeradius-Users mailing list