| 1 | package exporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/" |
| 5 | |
| 6 | "github.com/prometheus/client_golang/prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/" |
| 7 | "github.com/prometheus/client_golang/prometheus/promhttpscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/" |
| 8 | ) |
| 9 | |
| 10 | type HttpServerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer# struct { |
| 11 | muxscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#mux. *httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.ServeMuxscip-go gomod github.com/golang/go/src go1.18 `net/http`/ServeMux# |
| 12 | } |
| 13 | |
| 14 | func NewHttpServerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/NewHttpServer().() *HttpServerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer# { |
| 15 | s := &HttpServerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#{ |
| 16 | muxscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#mux.: httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.NewServeMuxscip-go gomod github.com/golang/go/src go1.18 `net/http`/NewServeMux().(), |
| 17 | } |
| 18 | s.muxscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#mux..HandleFuncscip-go gomod github.com/golang/go/src go1.18 `net/http`/ServeMux#HandleFunc().("/metrics", promhttpscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/.HandlerForscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/HandlerFor().(prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.DefaultGathererscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/DefaultGatherer., promhttpscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/.HandlerOptsscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/HandlerOpts#{}).ServeHTTPscip-go gomod github.com/golang/go/src go1.18 `net/http`/Handler#ServeHTTP().) |
| 19 | |
| 20 | s.muxscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#mux..HandleFuncscip-go gomod github.com/golang/go/src go1.18 `net/http`/ServeMux#HandleFunc().("/scrape", s.ScrapeHandlerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#ScrapeHandler().) |
| 21 | return s |
| 22 | } |
| 23 | |
| 24 | func (s *HttpServerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#) ServeHTTPscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#ServeHTTP().(w httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.18 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.18 `net/http`/Request#) { |
| 25 | s.muxscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#mux..ServeHTTPscip-go gomod github.com/golang/go/src go1.18 `net/http`/ServeMux#ServeHTTP().(w, r) |
| 26 | } |
| 27 | |
| 28 | //https://github.com/oliver006/redis_exporter/blob/master/exporter.go |
| 29 | func (s *HttpServerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#) ScrapeHandlerscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/HttpServer#ScrapeHandler().(w httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.18 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.18 `net/http`/Request#) { |
| 30 | target := r.URLscip-go gomod github.com/golang/go/src go1.18 `net/http`/Request#URL..Queryscip-go gomod github.com/golang/go/src go1.18 `net/url`/URL#Query().().Getscip-go gomod github.com/golang/go/src go1.18 `net/url`/Values#Get().("target") |
| 31 | if target == "" { |
| 32 | httpscip-go gomod github.com/golang/go/src go1.18 `net/http`/.Errorscip-go gomod github.com/golang/go/src go1.18 `net/http`/Error().(w, "'target' parameter must be specified", 400) |
| 33 | //e.targetScrapeRequestErrors.Inc() |
| 34 | return |
| 35 | } |
| 36 | |
| 37 | registry := prometheusscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/.NewRegistryscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/NewRegistry().() |
| 38 | e := NewExporterscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/NewExporter().(&ExporterTargetscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ExporterTarget#{ |
| 39 | Hostscip-go gomod github.com/fffonion/tplink-plug-exporter . `github.com/fffonion/tplink-plug-exporter/exporter`/ExporterTarget#Host.: target, |
| 40 | }) |
| 41 | registry.MustRegisterscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus`/Registry#MustRegister().(e) |
| 42 | |
| 43 | promhttpscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/.HandlerForscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/HandlerFor().(registry, promhttpscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/.HandlerOptsscip-go gomod github.com/prometheus/client_golang v1.13.0 `github.com/prometheus/client_golang/prometheus/promhttp`/HandlerOpts#{}).ServeHTTPscip-go gomod github.com/golang/go/src go1.18 `net/http`/Handler#ServeHTTP().(w, r) |
| 44 | } |