From 2a939bf754401a29198e846f5f37fcd955f6bcf8 Mon Sep 17 00:00:00 2001 From: Galorhallen Date: Wed, 5 Jan 2022 21:58:06 +0100 Subject: [PATCH] Fix error message --- internal/server/server.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/server/server.go b/internal/server/server.go index 3c5efd4..1f70ffa 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -33,13 +33,16 @@ func NewServer(port uint16, clients []*pihole.Client) *Server { mux.HandleFunc("/metrics", func(writer http.ResponseWriter, request *http.Request) { log.Printf("request.Header: %v\n", request.Header) - + for _, client := range clients { go client.CollectMetricsAsync(writer, request) } for _, client := range clients { - log.Printf("Received %s from %s\n", <-client.Status, client.GetHostname()) + status := <-client.Status + if status.Status == pihole.MetricsCollectionError { + log.Printf("An error occured while contacting %s: %s", client.GetHostname(), status.Err.Error()) + } } promhttp.Handler().ServeHTTP(writer, request)