-
Notifications
You must be signed in to change notification settings - Fork 4
/
check_imapds.sh
executable file
·92 lines (77 loc) · 2.02 KB
/
check_imapds.sh
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
#!/bin/bash
#
# Copyright 2009-2017 Martin Scharm
#
# This file is part of bf-monitoring.
# <https://binfalse.de/software/nagios/>
# <https://github.com/binfalse/monitoring>
#
# bf-monitoring 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 3 of the License, or (at your option) any
# later version.
#
# bf-monitoring 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
# bf-monitoring If not, see <http://www.gnu.org/licenses/>.
#
###################################
#
# check the number of running
# imapd's, we had some trouble
# with them, few days ago
#
# written by Martin Scharm
# see http://binfalse.de
#
###################################
REVISION=0.1
PROGNAME=`/usr/bin/basename $0`
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
CONFIGFILE="/etc/courier/imapd-ssl"
source /usr/lib/nagios/plugins/utils.sh
usage ()
{
echo "\
Nagios plugin to check the number of imap deamons
Usage:
$PROGNAME --help
$PROGNAME --version
"
}
help ()
{
print_revision $PROGNAME $REVISION
echo; usage; echo; support
}
while [ -n "$1" ]; do
case "$1" in
--help | -h)
help
exit $STATE_OK;;
--version | -V)
print_revision $PROGNAME $REVISION
exit $STATE_OK;;
*)
usage; exit $STATE_UNKNOWN;;
esac
shift
done
max=(`grep MAXDEAMONS $CONFIGFILE`)
IFS="="
max=(${max[0]})
max=${max[1]}
ist=`ps -ef | grep imapd | wc -l`
if [ $ist -gt $max ]; then
echo "ERROR: "$ist" imapd laufen, max ist "$max"!"
exit $STATE_CRITICAL
fi
if [ `expr $ist + 5` -gt $max ]; then
echo "WARN: "$ist" imapd laufen, max ist "$max"!"
exit $STATE_WARNING
fi
echo "OK! "$ist" imapd laufen, max ist "$max
exit $STATE_OK