mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 15:09:05 +01:00
Use old metric name in Ganglia if rename has happened in the router (#60)
* Use old metric name if rename has happened in the router * Also check for Ganglia renames for the oldname
This commit is contained in:
parent
73f22c1041
commit
1de3dda7be
@ -148,10 +148,14 @@ type GangliaMetricConfig struct {
|
|||||||
Unit string
|
Unit string
|
||||||
Group string
|
Group string
|
||||||
Value string
|
Value string
|
||||||
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCommonGangliaConfig(point lp.CCMetric) GangliaMetricConfig {
|
func GetCommonGangliaConfig(point lp.CCMetric) GangliaMetricConfig {
|
||||||
mname := GangliaMetricRename(point.Name())
|
mname := GangliaMetricRename(point.Name())
|
||||||
|
if oldname, ok := point.GetMeta("oldname"); ok {
|
||||||
|
mname = GangliaMetricRename(oldname)
|
||||||
|
}
|
||||||
for _, group := range CommonGangliaMetrics {
|
for _, group := range CommonGangliaMetrics {
|
||||||
for _, metric := range group.Metrics {
|
for _, metric := range group.Metrics {
|
||||||
if metric.Name == mname {
|
if metric.Name == mname {
|
||||||
@ -187,6 +191,7 @@ func GetCommonGangliaConfig(point lp.CCMetric) GangliaMetricConfig {
|
|||||||
Tmax: metric.Tmax,
|
Tmax: metric.Tmax,
|
||||||
Unit: metric.Unit,
|
Unit: metric.Unit,
|
||||||
Value: valueStr,
|
Value: valueStr,
|
||||||
|
Name: GangliaMetricRename(mname),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,10 +203,15 @@ func GetCommonGangliaConfig(point lp.CCMetric) GangliaMetricConfig {
|
|||||||
Tmax: 0,
|
Tmax: 0,
|
||||||
Unit: "",
|
Unit: "",
|
||||||
Value: "",
|
Value: "",
|
||||||
|
Name: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGangliaConfig(point lp.CCMetric) GangliaMetricConfig {
|
func GetGangliaConfig(point lp.CCMetric) GangliaMetricConfig {
|
||||||
|
mname := GangliaMetricRename(point.Name())
|
||||||
|
if oldname, ok := point.GetMeta("oldname"); ok {
|
||||||
|
mname = GangliaMetricRename(oldname)
|
||||||
|
}
|
||||||
group := ""
|
group := ""
|
||||||
if g, ok := point.GetMeta("group"); ok {
|
if g, ok := point.GetMeta("group"); ok {
|
||||||
group = g
|
group = g
|
||||||
@ -254,5 +264,6 @@ func GetGangliaConfig(point lp.CCMetric) GangliaMetricConfig {
|
|||||||
Tmax: DEFAULT_GANGLIA_METRIC_TMAX,
|
Tmax: DEFAULT_GANGLIA_METRIC_TMAX,
|
||||||
Unit: unit,
|
Unit: unit,
|
||||||
Value: valueStr,
|
Value: valueStr,
|
||||||
|
Name: GangliaMetricRename(mname),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,16 +39,13 @@ func (s *GangliaSink) Write(point lp.CCMetric) error {
|
|||||||
//var tagsstr []string
|
//var tagsstr []string
|
||||||
var argstr []string
|
var argstr []string
|
||||||
|
|
||||||
// Get metric name
|
|
||||||
metricname := GangliaMetricRename(point.Name())
|
|
||||||
|
|
||||||
// Get metric config (type, value, ... in suitable format)
|
// Get metric config (type, value, ... in suitable format)
|
||||||
conf := GetCommonGangliaConfig(point)
|
conf := GetCommonGangliaConfig(point)
|
||||||
if len(conf.Type) == 0 {
|
if len(conf.Type) == 0 {
|
||||||
conf = GetGangliaConfig(point)
|
conf = GetGangliaConfig(point)
|
||||||
}
|
}
|
||||||
if len(conf.Type) == 0 {
|
if len(conf.Type) == 0 {
|
||||||
return fmt.Errorf("metric %s has no 'value' field", metricname)
|
return fmt.Errorf("metric %q (Ganglia name %q) has no 'value' field", point.Name(), conf.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.config.AddGangliaGroup {
|
if s.config.AddGangliaGroup {
|
||||||
@ -70,7 +67,7 @@ func (s *GangliaSink) Write(point lp.CCMetric) error {
|
|||||||
if s.config.AddTypeToName {
|
if s.config.AddTypeToName {
|
||||||
argstr = append(argstr, fmt.Sprintf("--name=%s", GangliaMetricName(point)))
|
argstr = append(argstr, fmt.Sprintf("--name=%s", GangliaMetricName(point)))
|
||||||
} else {
|
} else {
|
||||||
argstr = append(argstr, fmt.Sprintf("--name=%s", metricname))
|
argstr = append(argstr, fmt.Sprintf("--name=%s", conf.Name))
|
||||||
}
|
}
|
||||||
argstr = append(argstr, fmt.Sprintf("--slope=%s", conf.Slope))
|
argstr = append(argstr, fmt.Sprintf("--slope=%s", conf.Slope))
|
||||||
argstr = append(argstr, fmt.Sprintf("--value=%s", conf.Value))
|
argstr = append(argstr, fmt.Sprintf("--value=%s", conf.Value))
|
||||||
|
@ -124,24 +124,21 @@ func (s *LibgangliaSink) Write(point lp.CCMetric) error {
|
|||||||
return s.cstrCache[key]
|
return s.cstrCache[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get metric name
|
|
||||||
metricname := GangliaMetricRename(point.Name())
|
|
||||||
|
|
||||||
conf := GetCommonGangliaConfig(point)
|
conf := GetCommonGangliaConfig(point)
|
||||||
if len(conf.Type) == 0 {
|
if len(conf.Type) == 0 {
|
||||||
conf = GetGangliaConfig(point)
|
conf = GetGangliaConfig(point)
|
||||||
}
|
}
|
||||||
if len(conf.Type) == 0 {
|
if len(conf.Type) == 0 {
|
||||||
return fmt.Errorf("metric %s has no 'value' field", metricname)
|
return fmt.Errorf("metric %q (Ganglia name %q) has no 'value' field", point.Name(), conf.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.config.AddTypeToName {
|
if s.config.AddTypeToName {
|
||||||
metricname = GangliaMetricName(point)
|
conf.Name = GangliaMetricName(point)
|
||||||
}
|
}
|
||||||
|
|
||||||
c_value = C.CString(conf.Value)
|
c_value = C.CString(conf.Value)
|
||||||
c_type = lookup(conf.Type)
|
c_type = lookup(conf.Type)
|
||||||
c_name = lookup(metricname)
|
c_name = lookup(conf.Name)
|
||||||
|
|
||||||
// Add unit
|
// Add unit
|
||||||
unit := ""
|
unit := ""
|
||||||
|
Loading…
Reference in New Issue
Block a user