Init
This commit is contained in:
1 parent
9c58aab51c
commit
76fc9a89cf
4 files changed
+245
No files matched your search
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
HBBR="hbbr"
|
||||
|
||||
PID="$(docker inspect -f '{{.State.Pid}}' "$HBBR")"
|
||||
|
||||
if [ -z "$PID" ] || [ "$PID" = "0" ]; then
|
||||
echo "hbbr container is not running" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
get_connections() {
|
||||
nsenter -t "$PID" -n ss -H -tn state established '( sport = :21117 )'
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
connections)
|
||||
get_connections | wc -l
|
||||
;;
|
||||
|
||||
sessions)
|
||||
count="$(get_connections | wc -l)"
|
||||
echo $((count / 2))
|
||||
;;
|
||||
|
||||
relay_ips)
|
||||
get_connections |
|
||||
awk '{print $4}' |
|
||||
sed -E 's/^\[::ffff:([^]]+)\]:[0-9]+$/\1/' |
|
||||
sort -u
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {connections|sessions|relay_ips}" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
Reference in new issue
Block a user