From d734b69c38f512d1ec338d12f0962a3660788c96 Mon Sep 17 00:00:00 2001 From: Diretnan Domnan Date: Sat, 5 Nov 2022 21:01:36 +0100 Subject: [PATCH 1/2] Fix polling issue after connection closed --- client/controller.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/controller.go b/client/controller.go index 0bf5675..0c36706 100644 --- a/client/controller.go +++ b/client/controller.go @@ -89,7 +89,9 @@ func (hosts *HostsController) sendMetric(host config.Host, client *Client) { }, Error: false, } - client.Send <- message + if config.Contains(hosts.ReadOnlyHosts, host) { + client.Send <- message + } } else { // check for error 127 which means command was not found var errorContent string @@ -112,7 +114,10 @@ func (hosts *HostsController) sendMetric(host config.Host, client *Client) { func (hosts *HostsController) Poll(client *Client) { for { for _, host := range hosts.Info.Hosts { - if config.Contains(hosts.ReadOnlyHosts, host) && hosts.clientConnected() { + if !hosts.clientConnected() { + return + } + if config.Contains(hosts.ReadOnlyHosts, host) { go hosts.sendMetric(host, client) } } From cbb49aef62cd789c0603c01dc4144c6c9100cd2b Mon Sep 17 00:00:00 2001 From: Diretnan Domnan Date: Sat, 5 Nov 2022 21:07:38 +0100 Subject: [PATCH 2/2] Adding error fatalf to TcpLinux for debug --- inspector/tcp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inspector/tcp.go b/inspector/tcp.go index cd968cf..4d6e31d 100644 --- a/inspector/tcp.go +++ b/inspector/tcp.go @@ -129,7 +129,7 @@ func (i *TcpLinux) Parse(output string) { portString := address[len(address)-1] port, err := strconv.Atoi(portString) if err != nil { - log.Fatal("Could not parse port number in TcpLinux") + log.Fatalf("Could not parse port number in TcpLinux %s", err.Error()) } ports[port] = status }