From: Conor Broderick Date: Mon, 10 Jul 2017 16:14:06 +0000 (+0100) Subject: Log tcp errors (#188) X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b195fd4ecb7611a47a2b6bdce5bb49d1a2ccebf9;p=blackbox_exporter.git Log tcp errors (#188) --- diff --git a/tcp.go b/tcp.go index 3a1ac2f..d823f42 100644 --- a/tcp.go +++ b/tcp.go @@ -32,11 +32,13 @@ func dialTCP(target string, module Module, registry *prometheus.Registry) (net.C targetAddress, port, err := net.SplitHostPort(target) if err != nil { + log.Errorf("Error splitting target address and port: %v", err) return nil, err } ip, err := chooseProtocol(module.TCP.PreferredIPProtocol, targetAddress, registry) if err != nil { + log.Errorf("Error choosing protocol: %v", err) return nil, err } @@ -52,6 +54,7 @@ func dialTCP(target string, module Module, registry *prometheus.Registry) (net.C } tlsConfig, err := config.NewTLSConfig(&module.TCP.TLSConfig) if err != nil { + log.Errorf("Error creating TLS configuration: %v", err) return nil, err } return tls.DialWithDialer(dialer, dialProtocol, dialTarget, tlsConfig) @@ -66,6 +69,7 @@ func probeTCP(target string, module Module, registry *prometheus.Registry) bool deadline := time.Now().Add(module.Timeout) conn, err := dialTCP(target, module, registry) if err != nil { + log.Errorf("Error dialing TCP: %v", err) return false } defer conn.Close() @@ -74,6 +78,7 @@ func probeTCP(target string, module Module, registry *prometheus.Registry) bool // If a deadline cannot be set, better fail the probe by returning an error // now rather than blocking forever. if err := conn.SetDeadline(deadline); err != nil { + log.Errorf("Error setting deadline: %v", err) return false } if module.TCP.TLS {