W dniu 2015-12-09 o 14:23, Marcin pisze:
Witam Męczę się by ożenić freeradiusa z lms, sesje i statystyki.
jak na razie mam coś takiego: #v+ accounting { reference = "%{tolower:type.%{%{Acct-Status-Type}:-none}.query}"
type { start { query = "UPDATE nodes SET lastonline =
EXTRACT(EPOCH FROM now()) WHERE name='%{SQL-User-Name}'; \ INSERT INTO nodesessions (customerid,nodeid,ipaddr,mac,start,stop,tag,type) VALUES \ ((SELECT ownerid FROM nodes WHERE name='%{SQL-User-Name}'),\ (SELECT id FROM nodes WHERE name='%{SQL-User-Name}'),\ INET_ATON('%{Framed-IP-Address}'),\ '%{Calling-Station-Id}',\ '%{integer:Event-Timestamp}',\ '%{integer:Event-Timestamp}',\ '%{Acct-Session-Id}',\ '1')" }
interim-update { query = "UPDATE nodes SET lastonline =
EXTRACT(EPOCH FROM now()) WHERE name='%{User-Name}';\ UPDATE nodesessions \ SET \ download = (('%{%{Acct-Output-Gigawords}:-0}'::bigint << 32) + '%{%{Acct-Output-Octets}:-0}'::bigint), \ upload = (('%{%{Acct-Input-Gigawords}:-0}'::bigint << 32) + '%{%{Acct-Input-Octets}:-0}'::bigint), \ stop = '%{integer:Event-Timestamp}' \ WHERE tag = '%{Acct-Session-Id}'" }
stop { query = "UPDATE nodes SET lastonline =
EXTRACT(EPOCH FROM now()) WHERE name='%{User-Name}';\ UPDATE nodesessions \ SET \ download = (('%{%{Acct-Output-Gigawords}:-0}'::bigint << 32) + '%{%{Acct-Output-Octets}:-0}'::bigint), \ upload = (('%{%{Acct-Input-Gigawords}:-0}'::bigint << 32) + '%{%{Acct-Input-Octets}:-0}'::bigint), \ stop = '%{integer:Event-Timestamp}', \ terminatecause = '%{Acct-Terminate-Cause}' \ WHERE tag = '%{Acct-Session-Id}'" } # # No Acct-Status-Type == ignore the packet # none { query = "SELECT true" } } }
#v-
Jeżeli chodzi o sam status online to wystarczy dodać
w accounting_start_query i accounting_update_query = " \ UPDATE nodes SET lastonline = unix_timestamp() WHERE name='%{User-Name}'" (to dla mysql)
trzeba też w UI ustawić odpowiedni czas lastonline_limit który musi być większy niż czas interim-update