Skip to content

Commit a8cd7cd

Browse files
committed
Add Nagios/Sensu checks
1 parent d675129 commit a8cd7cd

File tree

9 files changed

+147
-1
lines changed

9 files changed

+147
-1
lines changed

40simta.cron

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# simta admin tasks
22
10 00 * * * root /usr/sbin/simtamaint
33
*/5 * * * * root /usr/sbin/simc -q &>/dev/null
4-
5,15,25,35,45,55 * * * * root netstat -na | awk '$4 ~ /\:465$|\:587$|\:25$/ { print $6 }' | sort | uniq -c | sort -rn | while read count type; do echo -n "$type: $count "; done | logger -p mail.info -t smtp_ports

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
dist_bin_SCRIPTS = simqc simqgrep simtrans
22
dist_sbin_SCRIPTS = simqclean simtamaint
3+
dist_pkglibexec_SCRIPTS = check-simta-expansion check-simta-queue check-simta-queue-age check-simta-queue-jailed check-simta-queue-ownership metrics-simta
34

45
EXTRA_DIST = 40simta.cron packaging/rpm/simta-admin.spec
56

check-simta-expansion

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
while getopts g:t: opt; do
4+
case $opt in
5+
g) group=$OPTARG
6+
;;
7+
t) terminal=$OPTARG
8+
;;
9+
esac
10+
done
11+
12+
expanded=$(simexpander /etc/simta.conf $group | awk '/^Terminal:/{print $NF}')
13+
echo "$group expanded to '$expanded'"
14+
[[ $expanded != $terminal ]] && exit 2
15+
16+
exit 0

check-simta-queue

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
base=/var/spool/simta
4+
critical=1000
5+
warn=500
6+
7+
while getopts c:q:w: opt; do
8+
case $opt in
9+
c) critical=$OPTARG
10+
;;
11+
w) warn=$OPTARG
12+
;;
13+
q) queue=${base}/$OPTARG
14+
;;
15+
esac
16+
done
17+
18+
if [[ ! -d $queue ]]; then
19+
echo "No queue directory: $queue"
20+
exit 2
21+
fi
22+
23+
qcount=$(find $queue -ignore_readdir_race -type f -name 'E*' 2>/dev/null | wc -l)
24+
echo "$qcount messages in $queue"
25+
if [[ $qcount -gt $critical ]]; then
26+
exit 2
27+
elif [[ $qcount -gt $warn ]]; then
28+
exit 1
29+
fi
30+
31+
exit 0

check-simta-queue-age

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
base=/var/spool/simta
4+
critical=4
5+
warn=1
6+
age=120
7+
8+
while getopts a:c:q:w: opt; do
9+
case $opt in
10+
a) age=$OPTARG
11+
;;
12+
c) critical=$OPTARG
13+
;;
14+
w) warn=$OPTARG
15+
;;
16+
q) queue=${base}/$OPTARG
17+
;;
18+
esac
19+
done
20+
21+
if [[ ! -d $queue ]]; then
22+
echo "No queue directory: $queue"
23+
exit 2
24+
fi
25+
26+
qcount=$(find $queue -ignore_readdir_race -type f -name 'E*' -mmin +$age 2>/dev/null | wc -l)
27+
echo "$qcount messages older than $age minutes in $queue"
28+
if [[ $qcount -gt $critical ]]; then
29+
exit 2
30+
elif [[ $qcount -gt $warn ]]; then
31+
exit 1
32+
fi
33+
34+
exit 0

check-simta-queue-jailed

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
base=/var/spool/simta
4+
critical=1000
5+
warn=500
6+
7+
while getopts c:q:w: opt; do
8+
case $opt in
9+
c) critical=$OPTARG
10+
;;
11+
w) warn=$OPTARG
12+
;;
13+
q) queue=${base}/$OPTARG
14+
;;
15+
esac
16+
done
17+
18+
if [[ ! -d $queue ]]; then
19+
echo "No queue directory: $queue"
20+
exit 2
21+
fi
22+
23+
qcount=$(find $queue -ignore_readdir_race -type f -mmin +1 -name 'E*' 2>/dev/null | xargs grep -l '^J2$' | wc -l)
24+
echo "$qcount jailed messages in $queue"
25+
if [[ $qcount -gt $critical ]]; then
26+
exit 2
27+
elif [[ $qcount -gt $warn ]]; then
28+
exit 1
29+
fi
30+
31+
exit 0

check-simta-queue-ownership

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
base=/var/spool/simta
4+
5+
unowned=$(find $base -ignore_readdir_race -type f \! -user simta -print 2>/dev/null | wc -l)
6+
if [[ $unowned -gt 0 ]]; then
7+
echo "$unowned files not owned by simta"
8+
exit 2
9+
fi
10+
11+
echo "All files owned by simta"
12+
exit 0
13+

metrics-simta

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
prefix=$(hostname)
4+
ts=$(date +%s)
5+
6+
simc -q &>/dev/null
7+
8+
ss -na -o '( sport = :25 or sport = :465 or sport = :587 )' | awk 'NR > 2 { sockstate[$2]++ } END{ for (state in sockstate) print tolower(state), sockstate[state]; }' | while read state count; do
9+
echo ${prefix}.simta.sockets.$state $count $ts
10+
done
11+
12+
cat /var/spool/simta/etc/queue_schedule | awk 'NR > 5 && $2 > 5 { gsub(/\./, "_", $3); print $2, $3 }' | while read count queue; do
13+
echo ${prefix}.simta.queue.host.$queue $count $ts
14+
done
15+
16+
for q in slow fast local; do
17+
echo ${prefix}.simta.queue.${q} $(find /var/spool/simta/$q -ignore_readdir_race -type f -name 'E*' 2>/dev/null | wc -l) $ts
18+
done

packaging/rpm/simta-admin.spec.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Requires: gawk
1414
Requires: grep
1515
Requires: xz
1616
Requires: net-tools
17+
Requires: iproute
1718
Requires: sed
1819
Requires: simta
1920
Requires: util-linux
@@ -41,6 +42,8 @@ install -m 0644 40simta.cron %{buildroot}%{_sysconfdir}/cron.d/40simta
4142
%{_bindir}/simqc
4243
%{_bindir}/simqgrep
4344
%{_bindir}/simtrans
45+
%{_libexecdir}/%{name}/check-simta-*
46+
%{_libexecdir}/%{name}/metrics-simta
4447

4548
%changelog
4649
* %(date "+%a %b %d %Y") (Automated RPM build) - %{version}-%{release}

0 commit comments

Comments
 (0)