diff --git a/sinks/libgangliaSink.go b/sinks/libgangliaSink.go index ed19145..051bd03 100644 --- a/sinks/libgangliaSink.go +++ b/sinks/libgangliaSink.go @@ -2,7 +2,7 @@ package sinks /* #cgo CFLAGS: -DGM_PROTOCOL_GUARD -#cgo LDFLAGS: -L. -lganglia -Wl,--unresolved-symbols=ignore-in-object-files +#cgo LDFLAGS: -L. -Wl,--unresolved-symbols=ignore-in-object-files #include // This is a copy&paste snippet of ganglia.h (BSD-3 license) @@ -71,6 +71,7 @@ import ( "fmt" "unsafe" + cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger" lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric" "github.com/NVIDIA/go-nvml/pkg/dl" ) @@ -120,7 +121,7 @@ func (s *LibgangliaSink) Init(config json.RawMessage) error { if len(config) > 0 { err = json.Unmarshal(config, &s.config) if err != nil { - fmt.Println(s.name, "Error reading config for", s.name, ":", err.Error()) + cclog.ComponentError(s.name, "Error reading config:", err.Error()) return err } } @@ -128,6 +129,10 @@ func (s *LibgangliaSink) Init(config json.RawMessage) error { if lib == nil { return fmt.Errorf("error instantiating DynamicLibrary for %s", s.config.GangliaLib) } + err = lib.Open() + if err != nil { + return fmt.Errorf("error opening %s: %v", s.config.GangliaLib, err) + } // Set up cache for the C strings s.cstrCache = make(map[string]*C.char)