Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / vsftpd / vsftpd-rel @ c3e309c6

Historique | Voir | Annoter | Télécharger (3,11 ko)

1
#! /bin/bash
2

    
3
#  Copyright (C) 2008 Joey Schulze <joey@infodrom.org>
4
#
5
#  This program is free software; you can redistribute it and/or modify
6
#  it under the terms of the GNU General Public License as published by
7
#  the Free Software Foundation; version 2 dated June, 1991.
8
#
9
#  This program is distributed in the hope that it will be useful,
10
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
#  GNU General Public License for more details.
13
#
14
#  You should have received a copy of the GNU General Public License
15
#  along with this program;  if not, write to the Free Software
16
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
17

    
18
# Source: http://www.infodrom.org/Infodrom/tools/munin.html
19

    
20
# Supported configuration:
21
#
22
#   [vsftpd-rel]
23
#   user root
24
#   env.logfile /var/log/vsftpd.log
25
#   env.logtail /usr/bin/logtail
26

    
27
PROGNAME=vsftpd
28
STATEDIR=/var/lib/munin/plugin-state
29

    
30
LOGFILE=${logfile:-/var/log/vsftpd.log}
31
LOGTAIL=${logtail:-`which logtail`}
32

    
33
OFFSET=${STATEDIR}/${PROGNAME}.offset
34
STATE=${STATEDIR}/${PROGNAME}.state
35
PIVOT=${STATEDIR}/${PROGNAME}.pivot
36

    
37

    
38
install_ok()
39
{
40
    tempfile=$(which tempfile)
41
    if [ ! -r ${LOGFILE} -o \
42
	 -z "${LOGTAIL}" -o ! -x "${LOGTAIL}" -o \
43
	 -z "${tempfile}" -o ! -x "${tempfile}" ]
44
    then
45
	return 1
46
    fi
47

    
48
    return 0
49
}
50

    
51
if [ "$1" = "autoconf" ]
52
then
53
    tmpfile=`which tempfile`
54
    if install_ok
55
    then
56
	echo yes
57
	exit 0
58
    else
59
	echo no
60
	exit 1
61
    fi
62
fi
63

    
64
if [ "$1" = "config" ]
65
then
66
    echo 'system.type ABSOLUTE'
67
    echo 'graph_title Very Secure FTP Server'
68
    echo 'graph_vlabel Requests'
69
    echo 'graph_category FTP'
70
    echo 'ftp_conn.label connections'
71
    echo 'ftp_loginok.label successful logins'
72
    echo 'ftp_loginfail.label failed logins'
73
    echo 'ftp_uploadok.label successful uploads'
74
    echo 'ftp_uploadfail.label failed uploads'
75
    echo 'ftp_downloadok.label successful downloads'
76
    echo 'ftp_downloadfail.label failed downloads'
77
    echo 'ftp_deleteok.label successful deletes'
78
    echo 'ftp_deletefail.label failed deletes'
79
    exit 0
80
fi
81

    
82
test install_ok || exit 1
83

    
84
touch -d now-5minutes+30seconds $PIVOT
85
TEMP=`tempfile`
86
trap "rm -f ${PIVOT} ${TEMP}" INT EXIT
87

    
88
test -n "$TEMP" -a -w "$TEMP" || exit 1
89

    
90
if [ ! -s ${OFFSET} ]
91
then
92
    $LOGTAIL ${LOGFILE} ${OFFSET} > ${TEMP}
93
    exit 0
94
fi
95

    
96
if [ $STATE -ot $PIVOT ]
97
then
98
    $LOGTAIL ${LOGFILE} ${OFFSET} > ${TEMP}
99
    echo -n > ${STATE}
100

    
101
    echo "ftp_conn.value $(grep 'CONNECT' ${TEMP} | wc -l)" >> $STATE
102
    echo "ftp_loginok.value $(grep 'OK LOGIN' ${TEMP} | wc -l)" >> $STATE
103
    echo "ftp_loginfail.value $(grep 'FAIL LOGIN' ${TEMP} | wc -l)" >> $STATE
104
    echo "ftp_uploadok.value $(grep 'OK UPLOAD' ${TEMP} | wc -l)" >> $STATE
105
    echo "ftp_uploadfail.value $(grep 'FAIL UPLOAD' ${TEMP} | wc -l)" >> $STATE
106
    echo "ftp_downloadok.value $(grep 'OK DOWNLOAD' ${TEMP} | wc -l)" >> $STATE
107
    echo "ftp_downloadfail.value $(grep 'FAIL DOWNLOAD' ${TEMP} | wc -l)" >> $STATE
108
    echo "ftp_deleteok.value $(grep 'OK DELETE' ${TEMP} | wc -l)" >> $STATE
109
    echo "ftp_deletefail.value $(grep 'FAIL DELETE' ${TEMP} | wc -l)" >> $STATE
110
fi
111

    
112
cat $STATE