diff --git a/munin/innd_last b/munin/innd_last new file mode 100755 index 00000000..9188dd77 --- /dev/null +++ b/munin/innd_last @@ -0,0 +1,30 @@ +#!/bin/sh + +if [ "$1" = "config" ]; then + echo 'host_name news.crans.org' + echo 'graph_title Posts de moins de 24h' + echo "graph_args --base 1000 --lower-limit 0" + echo "graph_vlabel posts" + echo "graph_category News" + echo "posts.label posts" + exit 0 +fi + +TMPFILE="/tmp/munin_innd_last" + +zcat -f /var/log/news/OLD/news.notice.3.gz /var/log/news/OLD/news.notice.2.gz /var/log/news/OLD/news.notice.1.gz /var/log/news/news.notice | grep "post ok" > $TMPFILE + +CURDATE=`date +%s` +DATE=0 +while [ $(($CURDATE - $DATE)) -gt 86400 ] +do + tail -n +2 $TMPFILE > ${TMPFILE}2 + cp ${TMPFILE}2 $TMPFILE + DATESTR=`head -n 1 $TMPFILE | cut -d ' ' -f 1-3` + DATE=`date -d "$DATESTR" +%s` +done + +echo -n "posts.value " +cat $TMPFILE | wc -l + +rm -f $TMPFILE ${TMPFILE}2 &> /dev/null diff --git a/munin/innd_total b/munin/innd_total index e1ebf27f..345b16fa 100755 --- a/munin/innd_total +++ b/munin/innd_total @@ -20,8 +20,7 @@ """Plugin munin pour innd.""" ## Importations -import socket -import sys +import socket, sys, time def recvlines(sock): buff = sock.recv(4096) @@ -35,6 +34,10 @@ s.connect(('localhost', 119)) ## Mise en mode reader (pour utiliser 'listgroup') s.send("mode reader\r\n") + +# Petit "hack" en attendant d'utiliser la nntplib +time.sleep(0.5) + s.recv(4096) ## Récupération des newsgroups et du nombre de posts @@ -63,9 +66,9 @@ for l in recvlines(s)[1:]: if len(sys.argv) > 1 and sys.argv[1] == 'config': # Configuration du graphe print 'host_name news.crans.org' - print 'graph_title Nombre de posts' + print 'graph_title Nombre total de posts' print 'graph_args --base 1000 --lower-limit 0' - print 'graph_vlabel nombre de posts' + print 'graph_vlabel posts' print 'graph_category News' print 'graph_description Nombre de posts pour chaque newsgroup' (ng0, cng0, val0) = newsgroups[0]