mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-11-10 12:37:25 +01:00
Fix for gangliaSink
This commit is contained in:
parent
1ea63332d3
commit
fec3c5981d
@ -14,17 +14,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const GMETRIC_EXEC = `gmetric`
|
const GMETRIC_EXEC = `gmetric`
|
||||||
|
const GMETRIC_CONFIG = `/etc/ganglia/gmond.conf`
|
||||||
|
|
||||||
type GangliaSinkConfig struct {
|
type GangliaSinkConfig struct {
|
||||||
defaultSinkConfig
|
defaultSinkConfig
|
||||||
GmetricPath string `json:"gmetric_path"`
|
GmetricPath string `json:"gmetric_path,omitempty"`
|
||||||
AddGangliaGroup bool `json:"add_ganglia_group"`
|
GmetricConfig string `json:"gmetric_config,omitempty"`
|
||||||
|
AddGangliaGroup bool `json:"add_ganglia_group,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GangliaSink struct {
|
type GangliaSink struct {
|
||||||
sink
|
sink
|
||||||
gmetric_path string
|
gmetric_path string
|
||||||
config GangliaSinkConfig
|
gmetric_config string
|
||||||
|
config GangliaSinkConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *GangliaSink) Init(config json.RawMessage) error {
|
func (s *GangliaSink) Init(config json.RawMessage) error {
|
||||||
@ -38,6 +41,7 @@ func (s *GangliaSink) Init(config json.RawMessage) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.gmetric_path = ""
|
s.gmetric_path = ""
|
||||||
|
s.gmetric_config = ""
|
||||||
if len(s.config.GmetricPath) > 0 {
|
if len(s.config.GmetricPath) > 0 {
|
||||||
p, err := exec.LookPath(s.config.GmetricPath)
|
p, err := exec.LookPath(s.config.GmetricPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -53,6 +57,9 @@ func (s *GangliaSink) Init(config json.RawMessage) error {
|
|||||||
if len(s.gmetric_path) == 0 {
|
if len(s.gmetric_path) == 0 {
|
||||||
err = errors.New("cannot find executable 'gmetric'")
|
err = errors.New("cannot find executable 'gmetric'")
|
||||||
}
|
}
|
||||||
|
if len(s.config.GmetricConfig) > 0 {
|
||||||
|
s.gmetric_config = s.config.GmetricConfig
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,6 +100,9 @@ func (s *GangliaSink) Write(point lp.CCMetric) error {
|
|||||||
if len(tagsstr) > 0 {
|
if len(tagsstr) > 0 {
|
||||||
argstr = append(argstr, fmt.Sprintf("--desc=%q", strings.Join(tagsstr, ",")))
|
argstr = append(argstr, fmt.Sprintf("--desc=%q", strings.Join(tagsstr, ",")))
|
||||||
}
|
}
|
||||||
|
if len(s.gmetric_config) > 0 {
|
||||||
|
argstr = append(argstr, fmt.Sprintf("--conf=%s", s.gmetric_config))
|
||||||
|
}
|
||||||
argstr = append(argstr, fmt.Sprintf("--name=%s", point.Name()))
|
argstr = append(argstr, fmt.Sprintf("--name=%s", point.Name()))
|
||||||
for k, v := range point.Fields() {
|
for k, v := range point.Fields() {
|
||||||
if k == "value" {
|
if k == "value" {
|
||||||
@ -115,7 +125,7 @@ func (s *GangliaSink) Write(point lp.CCMetric) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command := exec.Command(string(GMETRIC_EXEC), strings.Join(argstr, " "))
|
command := exec.Command(s.gmetric_path, argstr...)
|
||||||
command.Wait()
|
command.Wait()
|
||||||
_, err = command.Output()
|
_, err = command.Output()
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user