Simple question (Request Duration)

Matthew Newton mcn at freeradius.org
Wed Sep 27 18:04:06 UTC 2023


On 27/09/2023 18:45, Alan DeKok wrote:
> On Sep 27, 2023, at 1:22 PM, Andy Arp <bubbaandy89 at gmail.com> wrote:
>> Is there a builtin value i can emit to linelog that will indicate how long
>> a given request has taken from start to finish?
> 
>    You can use:
> 
> 	%{expr: %l - %c}
> 
>    which gets you the time difference in seconds.  However, that is not generally useful.

Yeah - until now the best was

   update session-state {
       &Tmp-Integer64-1 = "%{expr:(%c*1000) + (%C/1000)}"
   }

at the start of authorize, and then

   update request {
     &Tmp-Integer64-0 := "%{expr:(%c*1000) + (%C/1000) - 
%{session-state:Tmp-Integer64-1}}"
   }

to find the time taken so far. It'll work most of the time, but fails 
randomly because %c and %C are calculated separately.

>    Matthew just added something related to v3.2.x:  https://github.com/FreeRADIUS/freeradius-server/commit/1b4f1d0a622384495ba5529e60822b02b9f2303a
> 
>    That will be in the next release.

It makes things much nicer :)

   update session-state {
     &Tmp-Integer64-1 = "%{time_since:ms}"
   }

and

   update request {
     &Tmp-Integer64-0 := "%{time_since:ms &session-state:Tmp-Integer64-1}"
   }

Debian/Ubuntu packages in the freeradius-devel-3.2 repo contain it.

-- 
Matthew


More information about the Freeradius-Users mailing list