MCPcopy
hub / github.com/prometheus/node_exporter / queryExporter

Function queryExporter

node_exporter_test.go:111–127  ·  view source on GitHub ↗
(address string)

Source from the content-addressed store, hash-verified

109}
110
111func queryExporter(address string) error {
112 resp, err := http.Get(fmt.Sprintf("http://%s/metrics", address))
113 if err != nil {
114 return err
115 }
116 b, err := io.ReadAll(resp.Body)
117 if err != nil {
118 return err
119 }
120 if err := resp.Body.Close(); err != nil {
121 return err
122 }
123 if want, have := http.StatusOK, resp.StatusCode; want != have {
124 return fmt.Errorf("want /metrics status code %d, have %d. Body:\n%s", want, have, b)
125 }
126 return nil
127}
128
129func runCommandAndTests(cmd *exec.Cmd, address string, fn func(pid int) error) error {
130 if err := cmd.Start(); err != nil {

Callers 3

TestFileDescriptorLeakFunction · 0.85
runCommandAndTestsFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected