-
Notifications
You must be signed in to change notification settings - Fork 0
/
wireshark.sh
executable file
·43 lines (38 loc) · 1.77 KB
/
wireshark.sh
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
#!/bin/bash
set -euo pipefail
script_directory_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
script_path="$script_directory_path/$(basename "${BASH_SOURCE[0]}")"
container_name="${1:-quotes}"; shift || true
container_id="$(docker compose ps --no-trunc --format '{{.ID}}' "$container_name")"
container_br="br-$(docker inspect --format '{{range .NetworkSettings.Networks}}{{.NetworkID}}{{end}}' "$container_id" | cut -c1-12)"
container_mac="$(docker inspect --format '{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' "$container_id")"
# download the otlp protobuf files.
otlp_version='1.1.0'
otlp_path="$PWD/tmp/opentelemetry-proto-$otlp_version"
if [ ! -d "$otlp_path/opentelemetry/proto" ]; then
otlp_parent_path="$(dirname "$otlp_path")"
install -d "$otlp_parent_path"
wget -qO- "https://github.com/open-telemetry/opentelemetry-proto/archive/refs/tags/v$otlp_version.tar.gz" \
| tar xzf - -C "$otlp_parent_path"
fi
# configure the wireshark proto search path.
# TODO instead of always overriding the file, modify it in-place when required.
# see https://wiki.wireshark.org/gRPC
# see https://wiki.wireshark.org/Protobuf
# see https://github.com/open-telemetry/opentelemetry-proto/tree/main/opentelemetry/proto
# NB wireshark searches for proto files at the directories configured in the
# ~/.config/wireshark/protobuf_search_paths file.
# NB wireshark preferences are loaded from the ~/.config/wireshark/preferences
# file.
cat >~/.config/wireshark/protobuf_search_paths <<EOF
# This file is automatically generated, DO NOT MODIFY.
# Generated by $script_path.
"$otlp_path","TRUE"
EOF
# call wireshark.
exec wireshark \
-o "gui.window_title:$container_name" \
-k \
-d 'tcp.port==4317,http2' \
-i "$container_br" \
-f "ether host $container_mac"