interface postgres login pgsql password xxx keepopen no idle_timeout 14400 doacct yes acct_max_connections 1 acct_db voice_base acct_start_query BEGIN work; \ LOCK current_calls IN ACCESS EXCLUSIVE MODE; \ INSERT INTO current_calls SELECT \ %C{Acct-Status-Type},\ '%u',\ '%D',\ '%C{NAS-IP-Address}',\ '%C{Connection-ID}',\ '%C{Acct-Session-Id}',\ 0,\ '%C{Called-Station-Id}',\ '%C{Calling-Station-Id}',\ %C{Call-Direction},\ %C{Call-Type},\ '',\ '',\ '127.0.0.1'; \ COMMIT work; # Query to be used on session end acct_stop_query UPDATE current_calls \ SET status=%C{Acct-Status-Type},\ session_time=%C{Acct-Session-Time},\ disconnect_cause='%C{Disconnect-Cause}',\ voice_quality='%C{Voice-Quality}',\ remote_gateway_id='%C{Remote-Gateway-ID}' \ WHERE connection_id='%C{Connection-ID}' \ and session_id='%C{Acct-Session-Id}' \ # and called_station_id='%C{Called-Station-Id}' \ and nas_ip_address='%C{NAS-IP-Address}' \ and call_direction=%C{Call-Direction} \ and call_type=%C{Call-Type} \ AND status = 1;