-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path42_turn_check.sh
More file actions
executable file
·66 lines (57 loc) · 2.1 KB
/
42_turn_check.sh
File metadata and controls
executable file
·66 lines (57 loc) · 2.1 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
#!/usr/bin/env bash
set -euo pipefail
# 0) Load your .env (via your helper)
source ./90_lib.sh 2>/dev/null || true
type load_env >/dev/null 2>&1 && load_env || {
# fallback: load .env if 90_lib.sh not available
set -a; [ -f .env ] && . ./.env; set +a
}
: "${TURN_DOMAIN:?TURN_DOMAIN missing in .env}"
: "${TURN_USER:?TURN_USER missing in .env}"
: "${TURN_PASS:?TURN_PASS missing in .env}"
TURN_PROM_ENABLE="${TURN_PROM_ENABLE:-false}"
echo "TURN_DOMAIN=$TURN_DOMAIN"
echo "TURN_USER=$TURN_USER"
echo "TURN_PROM_ENABLE=$TURN_PROM_ENABLE"
echo
# 1) Does this coturn binary support Prometheus?
echo "== binary feature check =="
if turnserver -h 2>/dev/null | grep -qi prometheus; then
echo "coturn HAS prometheus support"
else
echo "coturn has NO prometheus support"
fi
echo
# 2) Is the prometheus directive present in config?
echo "== config check =="
grep -nE '^(listening-port|tls-listening-port|realm|user|prometheus)' /etc/turnserver.conf || true
echo
# 3) Service & listeners
echo "== service & ports =="
systemctl --no-pager --lines=0 status coturn || true
ss -lntup | egrep ':3478|:5349|:9641' || true
echo
# 4) Try metrics (only if enabled in .env AND supported)
if [[ "$TURN_PROM_ENABLE" == "true" ]] && turnserver -h 2>/dev/null | grep -qi prometheus; then
echo "== prometheus endpoint =="
if curl -fsS --max-time 2 http://127.0.0.1:9641/ >/dev/null; then
echo "health: OK"
echo "--- metrics (first lines) ---"
curl -fsS --max-time 2 http://127.0.0.1:9641/metrics | head || true
else
echo "metrics not reachable on 127.0.0.1:9641"
fi
echo
fi
# 5) Functional TURN tests (local VPS works; best from another host for NAT path)
echo "== functional tests =="
echo "-- UDP 3478 --"
turnutils_uclient -v -y -u "$TURN_USER" -w "$TURN_PASS" "$TURN_DOMAIN" || true
echo
echo "-- TLS/TCP 5349 --"
turnutils_uclient -v -t -S -y -u "$TURN_USER" -w "$TURN_PASS" -p 5349 "$TURN_DOMAIN" || true
echo
# 6) TLS certificate quick info
echo "== TLS cert (5349) =="
echo | openssl s_client -connect "${TURN_DOMAIN}:5349" -servername "${TURN_DOMAIN}" 2>/dev/null \
| openssl x509 -noout -subject -issuer -enddate || true