Remove -lganglia ldflag and check dl lib

This commit is contained in:
Thomas Roehl 2022-02-21 17:01:13 +01:00
parent 3ade75490c
commit 842395682c

View File

@ -2,7 +2,7 @@ package sinks
/* /*
#cgo CFLAGS: -DGM_PROTOCOL_GUARD #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 <stdlib.h> #include <stdlib.h>
// This is a copy&paste snippet of ganglia.h (BSD-3 license) // This is a copy&paste snippet of ganglia.h (BSD-3 license)
@ -71,6 +71,7 @@ import (
"fmt" "fmt"
"unsafe" "unsafe"
cclog "github.com/ClusterCockpit/cc-metric-collector/internal/ccLogger"
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric" lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
"github.com/NVIDIA/go-nvml/pkg/dl" "github.com/NVIDIA/go-nvml/pkg/dl"
) )
@ -120,7 +121,7 @@ func (s *LibgangliaSink) Init(config json.RawMessage) error {
if len(config) > 0 { if len(config) > 0 {
err = json.Unmarshal(config, &s.config) err = json.Unmarshal(config, &s.config)
if err != nil { 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 return err
} }
} }
@ -128,6 +129,10 @@ func (s *LibgangliaSink) Init(config json.RawMessage) error {
if lib == nil { if lib == nil {
return fmt.Errorf("error instantiating DynamicLibrary for %s", s.config.GangliaLib) 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 // Set up cache for the C strings
s.cstrCache = make(map[string]*C.char) s.cstrCache = make(map[string]*C.char)