Make iowait example get correct hostname when launced remotely

This commit is contained in:
Paul Bellamy
2016-04-19 10:39:20 +01:00
parent 387a3c047e
commit 6591315ead
2 changed files with 10 additions and 3 deletions

View File

@@ -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) .

View File

@@ -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
}
}
}