(RADIATOR) Compute the Start time from Timestamp and Acct-Session-Time

Hugh Irvine hugh at open.com.au
Fri Jul 16 20:17:53 CDT 2004


Hello Alex -

My apologies - I should have checked this myself.

The Timestamp is indeed added after the PreAuthHook is called, 
therefore you should use a PreAuthHook.

Have a look at the code in "Radius/Handler.pm sub handle_request()".

You should probably also check the Acct-Status-Type and only execute 
your code if its a Stop (although you will only have an 
Acct-Session-Time attribute in a Stop request).

regards

Hugh


On 16 Jul 2004, at 20:12, Lopez, A. wrote:

> Hugh, many thanks for the tip;
> I added this lines to the PreProcessingHook:
>
> sub {
>
>         my $p=${$_[0]};
>
>         print "\nThis is the timestamp:";
>         print ($p->get_attr('Timestamp'));
>         print "\nThis is the duration:";
>         print ($p->get_attr('Acct-Session-Time'));
>         print "\nThis is the new Timestamp:";
>         print ($p->get_attr('Timestamp') - 
> $p->get_attr('Acct-Session-Time'));
>         print "\n";
>         $p->add_attr('Timestamp_start',  $p->get_attr('Timestamp') - 
> $p->get_at$
>
>
> }
>
> So that I print the status of the variables.
> Well, the trace of Radiator shows that the duration of the call is 
> calculated correctly using $p->get_attr('Acct-Session-Time') (returns 
> 16) but when trying to get the timestamp with 
> ($p->get_attr('Timestamp'), it does not return anything. This is what 
> radiator shows:
>
> Fri Jul 16 12:02:06 2004: DEBUG: Handling request with Handler 
> 'NAS-Identifier=portier_dommel'
> This is the timestamp:
> This is the duration:16
> This is the new Timestamp:-16
>
> So... I guess that when the Hook is executed, the timestamp is still 
> not set (or something like that), should I use another kind of Hook in 
> order to execute it after the attribute timestamp has the correct 
> value??
> Best regards,
> Alex
>
>
>
> -----Original Message-----
> From: Hugh Irvine [mailto:hugh at open.com.au]
> Sent: vrijdag 16 juli 2004 3:24
> To: Lopez, A.
> Cc: radiator at open.com.au
> Subject: Re: (RADIATOR) Compute the Start time from Timestamp and 
> Acct-Session-Time
>
>
> Hello Alex -
>
> What you show below should work.
>
> The easiest way to see what is happening in a hook is to add "print
> ...." statements and then run radiusd from the command line so you can
> see what is printed.
>
> 	perl radiusd -foreground -log_stdout -trace 4 -config_file .....
>
> regards
>
> Hugh
>
>
> On 16 Jul 2004, at 02:03, Lopez, A. wrote:
>
>> Hello all,
>>
>> I want to store in MySQL database accounting information of calls
>> (using the GNU gatekeeper).
>>
>> This is part of my config:
>>
>>  
>>
>> AcctColumnDef USERNAME,User-Name,
>>
>> AcctColumnDef CALLINGSTATIONID,Calling-Station-Id,
>>
>> AcctColumnDef CALLEDSTATIONID,Called-Station-Id,
>>
>> AcctColumnDef STOP_TIME, Timestamp, integer-date, %H:%M:%S,
>>
>> AcctColumnDef DURATION_sec, Acct-Session-Time
>>
>>  
>>
>> Well, everything goes fine but I also want to store the Start Time of
>> the call in the format %H:%M:%S.
>>
>>  I though it would be easy to compute the start time by subtracting
>> the Acct-Session-Time to the Timestamp, but I don't find the way to do
>> it (perhaps I should take a rest!)
>>
>> Is it possible to do such a subtraction in the config file itself?? If
>> that's the case, what kind of command/syntax I should use??
>>
>>  
>>
>> I also tried to compute the start time using a PreProcessingHook,
>> which computes the difference and adds an attribute "Timestamp_start"
>>
>>   
>>
>> sub {
>>
>>         my $p=${$_[0]};
>>
>>  
>>
>>         $p->add_attr('Timestamp_start',  $p->get_attr('Timestamp') -
>> $p->get_attr('Acct-Session-Time'));
>>
>> }
>>
>>   
>>
>> After that, I add this line in the Config file, in order to store the
>> Timestamp in %H:%M:%S format:
>>
>>  
>>
>> AcctColumnDef START_TIME, Timestamp_start, integer-date, %H:%M:%S,
>>
>>  
>>
>> This adds wrong information to MySQL.
>>
>>  
>>
>> Any idea??
>>
>> Alex
>>
>
> NB: have you included a copy of your configuration file (no secrets),
> together with a trace 4 debug showing what is happening?
>
> -- 
> Radiator: the most portable, flexible and configurable RADIUS server
> anywhere. Available on *NIX, *BSD, Windows, MacOS X.
> -
> Nets: internetwork inventory and management - graphical, extensible,
> flexible with hardware, software, platform and database independence.
> -
> CATool: Private Certificate Authority for Unix and Unix-like systems.
>
>

NB: have you included a copy of your configuration file (no secrets),
together with a trace 4 debug showing what is happening?

-- 
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. Available on *NIX, *BSD, Windows, MacOS X.
-
Nets: internetwork inventory and management - graphical, extensible,
flexible with hardware, software, platform and database independence.
-
CATool: Private Certificate Authority for Unix and Unix-like systems.

--
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.


More information about the radiator mailing list