-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrics-simta
More file actions
40 lines (31 loc) · 1023 Bytes
/
metrics-simta
File metadata and controls
40 lines (31 loc) · 1023 Bytes
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
#!/bin/bash
prefix='simta_'
tags=''
ts=$(date +%s)
qlimit=5
# Tell simta to update the queue_schedule file
simc -q &>/dev/null
while getopts l:p:t: opt; do
case $opt in
l)
qlimit=$OPTARG
;;
p)
prefix=$OPTARG
;;
t)
tags=$OPTARG
;;
esac
done
socks=$(ss -na -o '( sport = :25 or sport = :465 or sport = :587 )' 2>/dev/null | awk 'NR > 2 { sockstate[$2]++ } BEGIN { ORS="," } END { for (state in sockstate) print tolower(state) "=" sockstate[state]; }')
[[ $socks ]] && echo ${prefix}sockets${tags} ${socks%,} $ts
awk -v limit=$qlimit 'NR > 5 && $2 > limit { print $2, $3 }' /var/spool/simta/etc/queue_schedule | while read count queue; do
echo ${prefix}host_queue,remote_host=${queue}${tags} messages=$count $ts
done
queues=''
for q in slow fast local dead; do
count=$(find /var/spool/simta/$q -ignore_readdir_race -type f -name 'E*' 2>/dev/null | wc -l)
queues="${queues}${q}=${count},"
done
echo ${prefix}queue${tags} ${queues%,} $ts