Projet

Général

Profil

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

root / plugins / ssh / openssh-denyhosts @ b0b39b01

Historique | Voir | Annoter | Télécharger (1,44 ko)

1 8713e7a9 Sven Breunig
#!/bin/bash
2
#
3
# Plugin to monitor SSH
4
#
5
# Parameters understood:
6
#
7
# 	config   (required)
8
# 	autoconf (optional)
9
#
10
# Made by Sven Breunig ( sven AT breunig DOT be )
11
#
12
13
mktempfile () {
14 17f78427 Lars Kruse
mktemp -t
15
}
16 8713e7a9 Sven Breunig
17
AUTH_LOG=${logfile:-/var/log/auth.log}
18 ca7cbd71 dmzkrsk
STATEFILE=$MUNIN_PLUGSTATE/sshd.offset
19 8713e7a9 Sven Breunig
LOGTAIL=${logtail:-`which logtail`}
20
21
if [ "$1" = "autoconf" ]; then
22
        if [ -f "${AUTH_LOG}"  -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
23
		echo yes
24
	else
25
		echo no
26
	fi
27 e4cd049b Lars Kruse
	exit 0
28 8713e7a9 Sven Breunig
fi
29
30
if [ "$1" = "config" ]; then
31
	echo 'graph_title SSH Statistics'
32
	echo 'graph_order refused invalid accepted'
33 3a6fdce8 dipohl
	echo 'graph_category security'
34 8713e7a9 Sven Breunig
	echo 'graph_vlabel Count'
35
	echo 'graph_scale no'
36
37
##	echo 'graph_args --base 1000 -l 0'
38
	echo 'refused.label refused'
39
#	echo 'delayed.type DERIVE'
40
	echo 'invalid.label invalid'
41
#	echo 'passed.type DERIVE'
42
	echo 'accepted.label accepted'
43
#	echo 'whitelisted.type DERIVE'
44
	echo 'failedpass.label Failed password'
45
        exit 0
46
fi
47
48
49
refused=0
50
invalid=0
51
accepted=0
52
failed=0
53
54
TEMP_FILE=`mktempfile munin-sshd.XXXXXX`
55
56
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
57
then
58
	$LOGTAIL ${AUTH_LOG} $STATEFILE | grep 'sshd' > ${TEMP_FILE}
59
60
	refused=`grep -ic 'refused' ${TEMP_FILE}`
61 17f78427 Lars Kruse
	accepted=`grep -ic 'accepted' ${TEMP_FILE}`
62 8713e7a9 Sven Breunig
	invalid=`grep -ic 'invalid user' ${TEMP_FILE}`
63
	failed=`grep -ic 'failed password' ${TEMP_FILE}`
64
65
	/bin/rm -f $TEMP_FILE
66
fi
67
68
echo "refused.value ${refused}"
69
echo "accepted.value ${accepted}"
70
echo "invalid.value ${invalid}"
71
echo "failedpass.value ${failed}"