From 909d374f4d7596ba8d23d81b5f91e4a483ec2789 Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Sat, 18 May 2013 01:15:00 +0200 Subject: [PATCH] [munin/wifi_auth] on centralise sur thot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Comme ça on a les contenus de gordon et eap en même temps. NB: j'ai déplacé le plugin hors du repo wifi_new --- munin/scripts/hosts_plugins.py | 5 +-- munin/wifi_auth | 68 ++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100755 munin/wifi_auth diff --git a/munin/scripts/hosts_plugins.py b/munin/scripts/hosts_plugins.py index b494c3c5..e838aa9c 100755 --- a/munin/scripts/hosts_plugins.py +++ b/munin/scripts/hosts_plugins.py @@ -73,13 +73,12 @@ hosts_plugins = { "bind9_rndc": "/usr/share/munin/plugins/bind9_rndc", }, "gordon": { - "wifi_clients": "/usr/scripts/wifi_new/munin.py", "ap_states": "/usr/scripts/wifi_new/munin.py", "wifi_auth": "/usr/scripts/wifi_new/munin_auth", "bind9_rndc": "/usr/share/munin/plugins/bind9_rndc" }, - "eap": { - "wifi_auth": "/usr/scripts/wifi_new/munin_auth", + "thot": { + "wifi_auth": "wifi_auth", }, "xmpp": { "jabber": "jabber", diff --git a/munin/wifi_auth b/munin/wifi_auth new file mode 100755 index 00000000..b82f6522 --- /dev/null +++ b/munin/wifi_auth @@ -0,0 +1,68 @@ +#!/bin/sh +# -*- sh -*- + +mktempfile () { + #cmd=`echo $MUNIN_MKTEMP | sed s/\\$1/$1/` + #$cmd + touch /tmp/$1 + echo /tmp/$1 +} + +FREERADIUS_LOG=${freeradiuslog:-/var/log/wifi_auth.log} +LOGTAIL=${logtail:-/usr/sbin/logtail} +MUNIN_PLUGSTATE=${MUNIN_PLUGSTATE:-/var/lib/munin/plugin-state/} +STATEFILE=$MUNIN_PLUGSTATE/wifi_auth.offset + +if [ "$1" = "autoconf" ]; then + if [ -f "${FREERADIUS_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then + echo yes + exit 0 + else + echo no + exit 0 + fi +fi + +# Try tailing a random file to check how arguments are passed +ARGS=0 +`$LOGTAIL /etc/hosts 2>/dev/null >/dev/null` +if [ $? = 66 ]; then + if [ ! -n "$logtail" ]; then + ARGS=1 + fi +fi + +if [ "$1" = "config" ]; then + echo 'graph_title Authentifications WiFi' + echo 'graph_vlabel Auth' + echo 'graph_category wifi' + echo 'failures.label Échecs' + echo 'failures.draw AREASTACK' + echo 'failures.colour FF0000' + echo 'success.label Succès' + echo 'success.draw AREASTACK' + echo 'success.colour 00FF00' + exit 0 +fi + +success=U +failures=U + +TEMP_FILE=$(mktempfile munin-radius-wifi.XXXXXX) + +if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ] +then + if [ $ARGS != 0 ]; then + $LOGTAIL -f ${FREERADIUS_LOG} -o ${STATEFILE} | grep 'freeradius\[.*\]:' > ${TEMP_FILE} + else + $LOGTAIL ${FREERADIUS_LOG} ${STATEFILE} | grep 'freeradius\[.*\]:' > ${TEMP_FILE} + fi + success=$(grep -c 'Login OK' ${TEMP_FILE}) + failures=$(grep -c 'Login incorrect' ${TEMP_FILE}) + + /bin/rm -f $TEMP_FILE +fi + +echo "success.value ${success}" +echo "failures.value ${failures}" +