From 6591315eadd6419b6b6ba8ad9b32850de04d8a5a Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Tue, 19 Apr 2016 10:39:20 +0100 Subject: [PATCH] Make iowait example get correct hostname when launced remotely --- examples/plugins/iowait/Makefile | 7 ++++++- examples/plugins/iowait/main.go | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/plugins/iowait/Makefile b/examples/plugins/iowait/Makefile index 496249816..63040e03c 100644 --- a/examples/plugins/iowait/Makefile +++ b/examples/plugins/iowait/Makefile @@ -5,7 +5,12 @@ IMAGE=weavescope-iowait-plugin UPTODATE=.$(EXE).uptodate run: $(UPTODATE) - docker run --rm -it --privileged -v /var/run/scope/plugins:/var/run/scope/plugins --name $(IMAGE) $(IMAGE) -hostname=$(shell hostname) + # --net=host gives us the remote hostname, in case we're being launched against a non-local docker host. + # We could also pass in the `-hostname=foo` flag, but that doesn't work against a remote docker host. + docker run --rm -it \ + --net=host \ + -v /var/run/scope/plugins:/var/run/scope/plugins \ + --name $(IMAGE) $(IMAGE) $(UPTODATE): $(EXE) Dockerfile docker build -t $(IMAGE) . diff --git a/examples/plugins/iowait/main.go b/examples/plugins/iowait/main.go index b70da412a..a77b899fb 100644 --- a/examples/plugins/iowait/main.go +++ b/examples/plugins/iowait/main.go @@ -22,7 +22,7 @@ func main() { ) flag.Parse() - log.Println("Starting...") + log.Printf("Starting on %s...\n", *hostID) // Check we can get the iowait for the system _, err := iowait() @@ -80,7 +80,9 @@ func (p *Plugin) Report(w http.ResponseWriter, r *http.Request) { %q: { "metrics": { "iowait": { - "samples": [ {"date": %q, "value": %f} ] + "samples": [ {"date": %q, "value": %f} ], + "min": 0, + "max": 100 } } }