innd_connects 1.98 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/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 connexions


## Configuration
if [ "$1" = "config" ]; then
26 27 28 29
    echo 'host_name news.crans.org'
    echo 'graph_title Connexions par minute'
    echo "graph_args --base 1000 --lower-limit 0"
    echo "graph_vlabel connexions"
30 31
    echo "graph_period minute"
    echo "graph_category News"
32
    echo "graph_info Affiche le nombre de connexions par minute à InnD."
33 34 35
    echo "crans.label crans"
    echo "crans.type DERIVE"
    echo "crans.draw AREA"
36
    echo "crans.min 0"
37 38 39
    echo "ext.label exterieur"
    echo "ext.type DERIVE"
    echo "ext.draw STACK"
40
    echo "ext.min 0"
41 42
    echo "connects.label Total"
    echo "connects.type DERIVE"
43
    echo "connects.min 0"
44
    exit 0
45 46
fi

47 48
TMPFILE=/tmp/munin_innd_connects_grep

49 50 51
## Sortie
# Bon, ça fera une valeur négative (ramenée à 0 par le --lower-limit)
# à chaque rotation des logs, mais bon ...
52
egrep "connect( - port 119)?$" /var/log/news/news.notice > $TMPFILE
53 54 55 56

echo -n "connects.value "
cat $TMPFILE | wc -l
echo -n "crans.value "
57
cat $TMPFILE | egrep '\.crans\.org \(138\.231.*\) connect( - port 119)?$' | wc -l
58
echo -n "ext.value "
59
cat $TMPFILE | egrep -v '\.crans\.org \(138\.231.*\) connect( - port 119)?$' | wc -l
60 61

rm -f $TMPFILE &> /dev/null