From 72518e70360bb4a4fe5648018c1ff61fc25aeeec Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Tue, 12 Apr 2016 15:55:27 +0100 Subject: [PATCH] iowait example plugin should remove the socket when done --- examples/plugins/iowait/main.go | 9 +++++++++ probe/plugins/registry.go | 1 + 2 files changed, 10 insertions(+) diff --git a/examples/plugins/iowait/main.go b/examples/plugins/iowait/main.go index 39f331d1d..bec4b748e 100644 --- a/examples/plugins/iowait/main.go +++ b/examples/plugins/iowait/main.go @@ -9,6 +9,7 @@ import ( "net/http" "os" "os/exec" + "os/signal" "strconv" "strings" "time" @@ -31,6 +32,14 @@ func main() { } os.Remove(*addr) + interrupt := make(chan os.Signal, 1) + signal.Notify(interrupt, os.Interrupt) + go func() { + <-interrupt + os.Remove(*addr) + os.Exit(0) + }() + listener, err := net.Listen("unix", *addr) if err != nil { log.Fatal(err) diff --git a/probe/plugins/registry.go b/probe/plugins/registry.go index 648c01ad5..f4a12bb70 100644 --- a/probe/plugins/registry.go +++ b/probe/plugins/registry.go @@ -102,6 +102,7 @@ func (r *Registry) scan() error { } client := &http.Client{Transport: tr, Timeout: pluginTimeout} plugins[path] = NewPlugin(r.context, path, client, r.apiVersion, r.handshakeMetadata) + log.Infof("plugins: added plugin %s", path) } // remove plugins which weren't found for path, plugin := range r.pluginsBySocket {