Codebase list prometheus-haproxy-exporter / b94dc26
Support tcp scheme (#243) Signed-off-by: Roman Vynar <roman.vynar@quiq.com> Roman Vynar authored 1 year, 11 months ago GitHub committed 1 year, 11 months ago
1 changed file(s) with 7 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
263263 case "http", "https", "file":
264264 fetchStat = fetchHTTP(uri, sslVerify, proxyFromEnv, timeout)
265265 case "unix":
266 fetchInfo = fetchUnix(u, showInfoCmd, timeout)
267 fetchStat = fetchUnix(u, showStatCmd, timeout)
266 fetchInfo = fetchUnix("unix", u.Path, showInfoCmd, timeout)
267 fetchStat = fetchUnix("unix", u.Path, showStatCmd, timeout)
268 case "tcp":
269 fetchInfo = fetchUnix("tcp", u.Host, showInfoCmd, timeout)
270 fetchStat = fetchUnix("tcp", u.Host, showStatCmd, timeout)
268271 default:
269272 return nil, fmt.Errorf("unsupported scheme: %q", u.Scheme)
270273 }
353356 }
354357 }
355358
356 func fetchUnix(u *url.URL, cmd string, timeout time.Duration) func() (io.ReadCloser, error) {
359 func fetchUnix(scheme, address, cmd string, timeout time.Duration) func() (io.ReadCloser, error) {
357360 return func() (io.ReadCloser, error) {
358 f, err := net.DialTimeout("unix", u.Path, timeout)
361 f, err := net.DialTimeout(scheme, address, timeout)
359362 if err != nil {
360363 return nil, err
361364 }