forked from inuits/monitoring-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_mailman-moderator-approval.sh
executable file
·41 lines (35 loc) · 1.09 KB
/
check_mailman-moderator-approval.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
#!/bin/bash
#
# This script checks if there are any messages waiting for a moderator approval.
#
# Author: Pavel Pulec <kayn@inuits.eu>
#
data_dir=/var/lib/mailman/data
warning=1
critical=20
while getopts d:w:c: opts; do
case "$opts" in
d) data_dir="${OPTARG}";;
w) warning="${OPTARG}";;
c) critical="${OPTARG}";;
esac
done
queues () {
pending_queues=$(ls "${data_dir}"/heldmsg-*.pck 2>/dev/null | sed -r '/^$/d;s/.*heldmsg-(.*)-[0-9]+.pck/\1/' | sort -u | tr '\n' ' ')
}
err=$(ls "${data_dir}" 2>&1 >/dev/null) || {
echo "UNKNOWN: The content of '${data_dir}' directory can't be listed. Error: ${err}"
exit 3
}
count=$(ls "${data_dir}"/heldmsg-*.pck 2>/dev/null | wc -l)
if [ "${count}" -ge "${critical}" ]; then
queues
echo "CRITICAL: ${count} messages waiting for a moderator approval in the queues: ${pending_queues}"
exit 2
elif [ "${count}" -ge "${warning}" ]; then
queues
echo "WARNING: ${count} messages waiting for a moderator approval in the queues: ${pending_queues}"
exit 1
else
echo "OK: no messages waiting for a moderator approval"
fi