Projet

Général

Profil

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

root / plugins / network / ssh / openssh-denyhosts @ e5ce7492

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

1
#!/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
mktemp -t 
15
}       
16

    
17
AUTH_LOG=${logfile:-/var/log/auth.log}
18
STATEFILE=/var/lib/munin/plugin-state/sshd.offset
19
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
		exit 0
25
	else
26
		echo no
27
		exit 1
28
	fi
29
fi
30

    
31
if [ "$1" = "config" ]; then
32
	echo 'graph_title SSH Statistics'
33
	echo 'graph_order refused invalid accepted'
34
	echo 'graph_category ssh'
35
	echo 'graph_vlabel Count'
36
	echo 'graph_scale no'
37

    
38
##	echo 'graph_args --base 1000 -l 0'
39
	echo 'refused.label refused'
40
#	echo 'delayed.type DERIVE'
41
	echo 'invalid.label invalid'
42
#	echo 'passed.type DERIVE'
43
	echo 'accepted.label accepted'
44
#	echo 'whitelisted.type DERIVE'
45
	echo 'failedpass.label Failed password'
46
        exit 0
47
fi
48

    
49

    
50
refused=0
51
invalid=0
52
accepted=0
53
failed=0
54

    
55
TEMP_FILE=`mktempfile munin-sshd.XXXXXX`
56

    
57
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
58
then
59
	$LOGTAIL ${AUTH_LOG} $STATEFILE | grep 'sshd' > ${TEMP_FILE}
60

    
61
	refused=`grep -ic 'refused' ${TEMP_FILE}`
62
	accepted=`grep -ic 'accepted' ${TEMP_FILE}` 
63
	invalid=`grep -ic 'invalid user' ${TEMP_FILE}`
64
	failed=`grep -ic 'failed password' ${TEMP_FILE}`
65

    
66
	/bin/rm -f $TEMP_FILE
67
fi
68

    
69
echo "refused.value ${refused}"
70
echo "accepted.value ${accepted}"
71
echo "invalid.value ${invalid}"
72
echo "failedpass.value ${failed}"