From d477e483b2402c697ced9430b8a269324c5f9e47 Mon Sep 17 00:00:00 2001
From: Jan Philipp Timme <jan.philipp@timme.it>
Date: Thu, 8 Aug 2019 18:32:38 +0200
Subject: [PATCH] Add new plugin to monitor freeradius logs

---
 freeradius-logstats.sh | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100755 freeradius-logstats.sh

diff --git a/freeradius-logstats.sh b/freeradius-logstats.sh
new file mode 100755
index 0000000..6ed5e9f
--- /dev/null
+++ b/freeradius-logstats.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#
+# This script is supposed to be called periodically.
+# It goes through the last few lines of a freeradius log and counts events.
+# The resulting numbers are then reported in the simple check_mk format.
+#
+
+# Debugging option
+#set -x
+
+# Go into appropriate directory
+cd `dirname $0`
+
+# Include log watch functions
+. ./logwatch.functions.sh
+
+# Use helper function to get $log_start and $log_end for current log
+lookAtLog "/var/log/freeradius/radius.log" "freeradius-logstats.db"
+
+
+### Initialize counters ###
+login_ok=0
+login_incorrect=0
+
+### Do the statistics ###
+
+login_ok=$(getLogLines | grep ' cli ' | grep 'Login OK' | wc -l)
+login_incorrect=$(getLogLines | grep ' cli ' | grep 'Login incorrect' | wc -l)
+
+### Report counter results ###
+echo "P Freeradius-logstats login-ok=$login_ok|login-incorrect=$login_incorrect Additional metrics from freeradius"
+
+# That's it.
+exit 0
+
-- 
GitLab