scripts/munin/innd_last
Michel Blockelet d1155a8a4e [munin/innd_*] Import initial de innd_connects, headers
darcs-hash:20090330131929-ddb99-9ce435a88e4c79481ad3ed5618d0f389b0851209.gz
2009-03-30 15:19:29 +02:00

53 lines
1.6 KiB
Bash
Executable file

#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2009 Michel Blockelet <blockelet@crans.org>
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
### Plugin munin de comptabilisation des posts de moins de 24h
## Configuration
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
## Sortie
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