<div dir="ltr">I like this, very simple. Please ensure that this ends up in goodies.<div><br></div><div>Thanks,</div><div>Barry</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 5, 2016 at 5:47 AM, Heikki Vatiainen <span dir="ltr">&lt;<a href="mailto:hvn@open.com.au" target="_blank">hvn@open.com.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2.2.2016 13.14, Karl Gaissmaier wrote:<br>
<br>
&gt; yes, like heka <a href="http://hekad.readthedocs.org" rel="noreferrer" target="_blank">http://hekad.readthedocs.org</a> as forwarding agent and/or<br>
&gt; anomaly processor.<br>
<br>
Interesting, thanks for sharing this.<br>
<br>
&gt; Heka has also a sandboxed Lua interpreter to decode unusual log formats,<br>
&gt; maybe I&#39;ll not implement the hook in RADIATOR.<br>
&gt;<br>
&gt; Maybe it&#39;s really enough to create normal logs and use heka (or similar<br>
&gt; tools)<br>
&gt; to process anomaly detection and forward it to graphite/influxdb.<br>
<br>
Meanwhile, I did a basic Influxdb and Grafana installation to test it a<br>
little. Below is a simple AuthLog FILE format hook that creates an entry<br>
in Influxdb line protocol format and sends it before logging it to a<br>
file. It simply removes some of the characters that need to be quoted in<br>
the line protocol format and creates a new socket for each call. It&#39;s<br>
very primitive but, it will do basic logging and is a quick way to<br>
experiment and get something stored in Influxdb and visible in Grafana.<br>
<br>
The entry that gets logged in authlog file is useful to see how the line<br>
that was sent to Influxdb was formatted.<br>
<br>
# AuthLog in InfluxDB format<br>
sub<br>
{<br>
     my ($s, $reason, $p) = @_;<br>
<br>
     my $ap = $p-&gt;get_attr(&#39;NAS-Identifier&#39;);<br>
     my $client_mac = $p-&gt;get_attr(&#39;Calling-Station-Id&#39;);<br>
     my $username = $p-&gt;get_attr(&#39;User-Name&#39;);<br>
<br>
     my ($sec, $usec) = Radius::Util::getTimeHires();<br>
     my $influxtime = &quot;$sec$usec&quot;.&quot;000&quot;;<br>
<br>
     # Strip space, \ and &quot;<br>
     # See Influxdb docs for what/how to quote<br>
     $username =~ s/[ \\&quot;]//g;<br>
     $reason =~ s/[ \\&quot;]//g;<br>
<br>
     my $dp; # InfluxDB line protocol data point<br>
     if ($s == $main::ACCEPT)<br>
     {<br>
         my $key =<br>
&quot;radius,type=accept,ap=$ap,special=$username,special_type=username&quot;;<br>
<br>
         my $fields = &quot;value=\&quot;$username\&quot;&quot;;<br>
         $dp = &quot;$key $fields $influxtime&quot;;<br>
     }<br>
     elsif ($s == $main::REJECT)<br>
     {<br>
         my $key =<br>
&quot;radius,type=rejected,ap=$ap,special=$reason,special_type=reason&quot;;<br>
<br>
         my $fields = &quot;value=\&quot;$username\&quot;,special_val=\&quot;$reason\&quot;&quot;;<br>
         $dp = &quot;$key $fields $influxtime&quot;;<br>
     }<br>
<br>
     use IO::Socket::INET;<br>
     my $socket = IO::Socket::INET-&gt;new(PeerAddr =&gt; &#39;127.0.0.1&#39;,<br>
                                  PeerPort =&gt; &#39;8090&#39;,<br>
                                  Proto    =&gt; &#39;udp&#39;);<br>
     $socket-&gt;send($dp . &quot;\n&quot;);<br>
     return $dp;<br>
}<br>
<br>
Here&#39;s the config I used.<br>
<br>
Foreground<br>
LogStdout<br>
LogDir          .<br>
DbDir           .<br>
Trace           4<br>
<br>
&lt;Client DEFAULT&gt;<br>
        Secret  mysecret<br>
&lt;/Client&gt;<br>
<br>
&lt;AuthLog FILE&gt;<br>
        Identifier myauthlogger-influxdb<br>
        Filename %L/authlog-influx.txt<br>
        LogFormatHook file:&quot;%D/<a href="http://format-influx.pl" rel="noreferrer" target="_blank">format-influx.pl</a>&quot;<br>
        LogSuccess 1<br>
        LogFailure 1<br>
&lt;/AuthLog&gt;<br>
<br>
&lt;Handler&gt;<br>
        &lt;AuthBy FILE&gt;<br>
                Filename %D/users<br>
        &lt;/AuthBy&gt;<br>
<br>
        AuthLog myauthlogger-influxdb<br>
&lt;/Handler&gt;<br>
<br>
<br>
--<br>
Heikki Vatiainen &lt;<a href="mailto:hvn@open.com.au">hvn@open.com.au</a>&gt;<br>
<br>
Radiator: the most portable, flexible and configurable RADIUS server<br>
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,<br>
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,<br>
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,<br>
DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS,<br>
NetWare etc.<br>
_______________________________________________<br>
radiator mailing list<br>
<a href="mailto:radiator@open.com.au">radiator@open.com.au</a><br>
<a href="http://www.open.com.au/mailman/listinfo/radiator" rel="noreferrer" target="_blank">http://www.open.com.au/mailman/listinfo/radiator</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><br>Barry Ard                                   <a href="mailto:barry.ard@ualberta.ca" target="_blank">barry.ard@ualberta.ca</a><br><div>IST<br>University of Alberta<br>Edmonton, Alberta   Canada</div></div></div>
</div>