From 98936fe9ad96d9009f33abaede8165c5abd1c9f2 Mon Sep 17 00:00:00 2001 From: Alexander Renz Date: Wed, 1 Jan 2025 15:43:21 +0100 Subject: [PATCH] feat: add metrics retrieval to updateUI and pass metrics to HMAC table --- cmd/monitor/monitor.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cmd/monitor/monitor.go b/cmd/monitor/monitor.go index 78d70be..a308783 100644 --- a/cmd/monitor/monitor.go +++ b/cmd/monitor/monitor.go @@ -421,8 +421,9 @@ func updateUI(ctx context.Context, app *tview.Application, pages *tview.Pages, s err error }) hmacInfoCh := make(chan struct { - info *ProcessInfo - err error + info *ProcessInfo + metrics map[string]float64 + err error }) // Goroutine zur Datenbeschaffung @@ -472,10 +473,15 @@ func updateUI(ctx context.Context, app *tview.Application, pages *tview.Pages, s // hmac-file-server Informationen abrufen asynchron go func() { hmacInfo, err := fetchHmacFileServerInfo() + var metrics map[string]float64 + if metricsEnabled { + metrics, err = fetchMetrics() + } hmacInfoCh <- struct { - info *ProcessInfo - err error - }{hmacInfo, err} + info *ProcessInfo + metrics map[string]float64 + err error + }{hmacInfo, metrics, err} }() } } @@ -550,7 +556,7 @@ func updateUI(ctx context.Context, app *tview.Application, pages *tview.Pages, s if currentPage, _ := pages.GetFrontPage(); currentPage == "hmac" && data.info != nil { hmacFlex := hmacPage.(*tview.Flex) hmacTable := hmacFlex.GetItem(0).(*tview.Table) - updateHmacTable(hmacTable, data.info, nil) // Metriken können separat behandelt werden + updateHmacTable(hmacTable, data.info, data.metrics) } }) }