-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.dovecot
116 lines (103 loc) · 4.21 KB
/
functions.dovecot
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/sh
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
# function library - please call with external script
#
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#############################################################################
# MoSSHe: remote server monitoring environment
#
# Copyright (C) 2013- Volker Tanger
#
# This program 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.
#
# For bug reports and suggestions or if you just want to talk to me please
# contact me at [email protected]
#
# Updates will be available at http://www.wyae.de/software/mosshe/
# please check there for updates prior to submitting patches!
#
# For list of changes please refer to the HISTORY file. Thanks.
#############################################################################
#############################################################################
# Dovecot checks - functions below
#############################################################################
#---------------------------------------------------------
# DovecotStored - WARN ALERT
#---------------------------------------------------------
DovecotStored () {
MossheLog "DovecotStored $1 $2"
typeset -i ALERT WARN VALUE RTN
WARN=$1
ALERT=$2
if [ -x /usr/bin/journalctl ]; then
VALUE=`journalctl --since "5 minute ago" -u dovecot | fgrep lmtp | fgrep ' saved mail to ' | wc -l`
if [ "$VALUE" -gt "$ALERT" ]; then
STATUS="ALERT"
MESSAGE="Excessive stored mails for Dovecot $MYGROUP: $MYNAME "
elif [ "$VALUE" -gt "$WARN" ]; then
STATUS="WARN"
MESSAGE="High number of stored mails for Dovecot $MYGROUP: $MYNAME "
else
STATUS="OK"
MESSAGE="Normal number of stored mail by Dovecot $MYGROUP: $MYNAME "
fi
echo "${DATIM};$MYGROUP;$MYNAME;DovecotStored;$STATUS;$VALUE;$MESSAGE" >> $TEMPDIR/tmp.$$.collected.tmp
else
echo "${DATIM};$MYGROUP;$MYNAME;DovecotStored;-5;not a SYSTEMD system" >> $TEMPDIR/tmp.$$.collected.tmp
fi
}
#---------------------------------------------------------
# DovecotSieved - WARN ALERT
#---------------------------------------------------------
DovecotSieved () {
MossheLog "DovecotSieved $1 $2"
typeset -i ALERT WARN VALUE RTN
WARN=$1
ALERT=$2
if [ -x /usr/bin/journalctl ]; then
VALUE=`journalctl --since "5 minute ago" -u dovecot | fgrep lmtp | fgrep ' sieve: ' | wc -l`
if [ "$VALUE" -gt "$ALERT" ]; then
STATUS="ALERT"
MESSAGE="Excessive mails sieved for Dovecot $MYGROUP: $MYNAME "
elif [ "$VALUE" -gt "$WARN" ]; then
STATUS="WARN"
MESSAGE="High number of sieved mails for Dovecot $MYGROUP: $MYNAME "
else
STATUS="OK"
MESSAGE="Normal number of sieved mail by Dovecot $MYGROUP: $MYNAME "
fi
echo "${DATIM};$MYGROUP;$MYNAME;DovecotSieved;$STATUS;$VALUE;$MESSAGE" >> $TEMPDIR/tmp.$$.collected.tmp
else
echo "${DATIM};$MYGROUP;$MYNAME;DovecotSieved;-5;not a SYSTEMD system" >> $TEMPDIR/tmp.$$.collected.tmp
fi
}
#---------------------------------------------------------
# DovecotLoginFailed - WARN ALERT
#---------------------------------------------------------
DovecotLoginFailed () {
MossheLog "DovecotLoginFailed $1 $2"
typeset -i ALERT WARN VALUE RTN
WARN=$1
ALERT=$2
if [ -x /usr/bin/journalctl ]; then
VALUE=`journalctl --since "5 minute ago" -u dovecot | fgrep ' imap-login: Disconnected (auth failed, ' | wc -l`
if [ "$VALUE" -gt "$ALERT" ]; then
STATUS="ALERT"
MESSAGE="Excessive failed logins for Dovecot $MYGROUP: $MYNAME "
elif [ "$VALUE" -gt "$WARN" ]; then
STATUS="WARN"
MESSAGE="High number of failed logins for Dovecot $MYGROUP: $MYNAME "
else
STATUS="OK"
MESSAGE="Normal number failed logins by Dovecot $MYGROUP: $MYNAME "
fi
echo "${DATIM};$MYGROUP;$MYNAME;DovecotLoginFailed;$STATUS;$VALUE;$MESSAGE" >> $TEMPDIR/tmp.$$.collected.tmp
else
echo "${DATIM};$MYGROUP;$MYNAME;DovecotLoginFailed;-5;not a SYSTEMD system" >> $TEMPDIR/tmp.$$.collected.tmp
fi
}
#############################################################################