forked from aarond10/https_dns_proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttps_dns_proxy.plugin
More file actions
executable file
·71 lines (63 loc) · 1.7 KB
/
https_dns_proxy.plugin
File metadata and controls
executable file
·71 lines (63 loc) · 1.7 KB
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
#!/bin/bash
case $1 in
config)
cat <<'EOM'
multigraph https_dns_proxy_count
graph_title HTTPS DNS proxy - count
graph_vlabel count
graph_category network
graph_scale no
graph_args --base 1000 --lower-limit 0
requests.label Requests
responses.label Responses
multigraph https_dns_proxy_latency
graph_title HTTPS DNS proxy - latency
graph_vlabel latency
graph_category network
graph_scale no
graph_args --base 1000 --lower-limit 0
latency.label Latency
multigraph https_dns_proxy_connections
graph_title HTTPS DNS proxy - connections
graph_vlabel count
graph_category network
graph_scale no
graph_args --base 1000 --lower-limit 0
opened.label Opened
closed.label Closed
reused.label Reused
EOM
exit 0;;
autoconf)
pgrep https_dns_proxy >/dev/null 2>&1 \
&& echo "yes" \
|| echo "no"
exit 0;;
esac
log_lines=$(journalctl --unit https_dns_proxy.service --output cat --since '6 minutes ago')
pattern='stat\.c:[0-9]+ ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)$'
# match log lines with pattern (last match will be used)
IFS='
'
for line in $log_lines; do
if [[ $line =~ $pattern ]]; then
stat=("${BASH_REMATCH[@]}")
# else
# echo "stat regexp did not match with line: $line" >&2
fi
done
latency='U'
if [ -n "${stat[3]}" ] && \
[ -n "${stat[2]}" ] && \
[ "${stat[2]}" -gt "0" ]; then
latency=$((${stat[3]} / ${stat[2]}))
fi
echo "multigraph https_dns_proxy_count"
echo "requests.value ${stat[1]:-U}"
echo "responses.value ${stat[2]:-U}"
echo "multigraph https_dns_proxy_latency"
echo "latency.value ${latency}"
echo "multigraph https_dns_proxy_connections"
echo "opened.value ${stat[6]:-U}"
echo "closed.value ${stat[7]:-U}"
echo "reused.value ${stat[8]:-U}"