Skip to content

Commit

Permalink
Merge pull request #969 from iotaledger/feat/dashboard-external-multi…
Browse files Browse the repository at this point in the history
…address

Add external multiaddress to `NodeInfoExtended`
  • Loading branch information
muXxer committed May 14, 2024
2 parents 857a7cd + ba13e6b commit cd2c505
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-network-health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
# Run network
cd ./tools/docker-network
timeout 10m ./run.sh 0 0 &
timeout 10m ./run.sh &
RUN_PID=$!
# Wait for node-4 to be created before querying it
Expand Down
22 changes: 21 additions & 1 deletion components/dashboard_metrics/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@ func nodeInfoExtended() *NodeInfoExtended {
var m runtime.MemStats
runtime.ReadMemStats(&m)

getExternalMultiAddr := func() string {
var fallback string

for i, addr := range deps.Host.Addrs() {
if i == 0 {
fallback = addr.String()
}

for _, protocol := range addr.Protocols() {
// search the first dns address
if protocol.Name == "dns" {
return addr.String()
}
}
}

return fallback
}

status := &NodeInfoExtended{
Version: deps.AppInfo.Version,
LatestVersion: deps.AppInfo.LatestGitHubVersion,
Uptime: time.Since(nodeStartupTimestamp).Milliseconds(),
NodeID: deps.Host.ID().String(),
NodeAlias: ParamsNode.Alias,
MultiAddress: getExternalMultiAddr(),
Alias: ParamsNode.Alias,
MemoryUsage: int64(m.HeapAlloc + m.StackSys + m.MSpanSys + m.MCacheSys + m.BuckHashSys + m.GCSys + m.OtherSys),
}

Expand Down
3 changes: 2 additions & 1 deletion components/dashboard_metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ type NodeInfoExtended struct {
LatestVersion string `serix:",lenPrefix=uint8"`
Uptime int64 `serix:""`
NodeID string `serix:",lenPrefix=uint8"`
NodeAlias string `serix:",lenPrefix=uint8"`
MultiAddress string `serix:",lenPrefix=uint8"`
Alias string `serix:",lenPrefix=uint8"`
MemoryUsage int64 `serix:""`
}

Expand Down
2 changes: 1 addition & 1 deletion tools/docker-network/restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

docker compose kill
docker compose down
./run.sh 0
./run.sh
1 change: 1 addition & 0 deletions tools/docker-network/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ mkdir -p docker-network-snapshots/
chmod o+w docker-network-snapshots/

# Allow docker compose to build and cache an image
echo "Building docker image"
echo $DOCKER_BUILD_CONTEXT $DOCKERFILE_PATH
docker compose build --build-arg WITH_GO_WORK=${WITH_GO_WORK:-0} --build-arg DOCKER_BUILD_CONTEXT=${DOCKER_BUILD_CONTEXT} --build-arg DOCKERFILE_PATH=${DOCKERFILE_PATH}

Expand Down

0 comments on commit cd2c505

Please sign in to comment.