<div dir="ltr">Hi,<div>I am using Freeradius version <font color="#666666" face="sans-serif"><span style="font-size:14px;line-height:21.599998474121094px">2.2.4, I want to execute an external Java program, whenever I receive an Accounting Stop packet, I have added the below code in the "Accounting" section of /etc/raddb/sites-enabled/default </span></font></div>
<div><font color="#666666" face="sans-serif"><span style="font-size:14px;line-height:21.599998474121094px"><br></span></font></div><div><font color="#666666" face="sans-serif"><div style><div style><span style="font-size:14px;line-height:21.599998474121094px">accounting {</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # Create a 'detail'ed log of the packets.</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # Note that accounting requests which are proxied</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # are also logged in the detail file.</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> detail</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"># daily</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br>
</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # Update the wtmp file</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # If you don't use "radlast", you can delete this line.</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> unix</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # For Simultaneous-Use tracking.</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # Due to packet losses in the network, the data here</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # may be incorrect. There is little we can do about it.</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> radutmp</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"># sradutmp</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # Return an address to the IP Pool when we see a stop record.</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"># main_pool</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # Log traffic to an SQL database.</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # See "Accounting queries" in sql.conf</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> sql</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # If you receive stop packets with zero session length,</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # they will NOT be logged in the database. The SQL module</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # will print a message (only in debugging mode), and will</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # return "noop".</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div><div style>
<span style="font-size:14px;line-height:21.599998474121094px"> # You can ignore these packets by uncommenting the following</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # three lines. Otherwise, the server will not respond to the</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # accounting request, and the NAS will retransmit.</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"><span class="" style="white-space:pre"> </span># if (noop) {</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"># ok</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"># }</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # Instead of sending the query to the SQL server,</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # write it into a log file.</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"># sql_log</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br>
</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # Cisco VoIP specific bulk accounting</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"># pgsql-voip</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # For Exec-Program and Exec-Program-Wait</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> exec</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> # Filter attributes from the accounting response.</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> attr_filter.accounting_response</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style>
<span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> update reply {</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> Tmp-String-0 = "%{exec:/usr/bin/java -jar "/var/AccountingProcessor.jar" arg1 arg2 >> /home/user/capture.log}"</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> }</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"> # See "Autz-Type Status-Server" for how this works.</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"> #</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"># Acct-Type Status-Server {</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px">#</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"># }</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px">}</span></div><div style="font-size:14px;line-height:21.599998474121094px"><br></div></div><div style="font-size:14px;line-height:21.599998474121094px">
<br></div><div style="font-size:14px;line-height:21.599998474121094px">where arg1 and arg2 will be the radius accounting stop packet attributes. i will add the IF condition for checking stop packets later</div><div style="font-size:14px;line-height:21.599998474121094px">
<br></div><div style="font-size:14px;line-height:21.599998474121094px">Currently I am receiving error in logs, error is mentioned below</div><div style="font-size:14px;line-height:21.599998474121094px"><br></div><div style>
<div style><span style="font-size:14px;line-height:21.599998474121094px">++[exec] returns noop</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px">[attr_filter.accounting_response] expand: %{User-Name} -> <a href="mailto:muhd.usman@hotmail.com">muhd.usman@hotmail.com</a></span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px">attr_filter: Matched entry DEFAULT at line 12</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px">++[attr_filter.accounting_response] returns updated</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px">ERROR: Badly formatted variable: %{exec:/usr/bin/java -jar </span></div><div style><span style="font-size:14px;line-height:21.599998474121094px">++[reply] returns updated</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px">Sending Accounting-Response of id 14 to 192.168.6.121 port 55006</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px">Finished request 1.</span></div>
<div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br>
</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br></span></div><div style><span style="font-size:14px;line-height:21.599998474121094px"><br>
</span></div><div style><span style="font-size:14px;line-height:21.599998474121094px">Thanks in advance</span></div></div></font></div></div>