本文整理汇总了Golang中collectd/org/api.ValueList.DSName方法的典型用法代码示例。如果您正苦于以下问题:Golang ValueList.DSName方法的具体用法?Golang ValueList.DSName怎么用?Golang ValueList.DSName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collectd/org/api.ValueList
的用法示例。
在下文中一共展示了ValueList.DSName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newName
// newName converts one data source of a value list to a string representation.
func newName(vl api.ValueList, index int) string {
var name string
if vl.Plugin == vl.Type {
name = "collectd_" + vl.Type
} else {
name = "collectd_" + vl.Plugin + "_" + vl.Type
}
if dsname := vl.DSName(index); dsname != "value" {
name += "_" + dsname
}
switch vl.Values[index].(type) {
case api.Counter:
name += "_total"
}
return name
}
示例2: UnmarshalValueList
// Unmarshal translates a ValueList into InfluxDB data points.
func (s *Service) UnmarshalValueList(vl *api.ValueList) []models.Point {
timestamp := vl.Time.UTC()
var points []models.Point
for i := range vl.Values {
var name string
name = fmt.Sprintf("%s_%s", vl.Identifier.Plugin, vl.DSName(i))
tags := make(map[string]string)
fields := make(map[string]interface{})
// Convert interface back to actual type, then to float64
switch value := vl.Values[i].(type) {
case api.Gauge:
fields["value"] = float64(value)
case api.Derive:
fields["value"] = float64(value)
case api.Counter:
fields["value"] = float64(value)
}
if vl.Identifier.Host != "" {
tags["host"] = vl.Identifier.Host
}
if vl.Identifier.PluginInstance != "" {
tags["instance"] = vl.Identifier.PluginInstance
}
if vl.Identifier.Type != "" {
tags["type"] = vl.Identifier.Type
}
if vl.Identifier.TypeInstance != "" {
tags["type_instance"] = vl.Identifier.TypeInstance
}
// Drop invalid points
p, err := models.NewPoint(name, models.NewTags(tags), fields, timestamp)
if err != nil {
s.Logger.Info(fmt.Sprintf("Dropping point %v: %v", name, err))
atomic.AddInt64(&s.stats.InvalidDroppedPoints, 1)
continue
}
points = append(points, p)
}
return points
}
示例3: Write
// Write formats the ValueList in the PUTVAL format and writes it to the
// assiciated io.Writer.
func (g *Graphite) Write(vl api.ValueList) error {
for i, v := range vl.Values {
dsName := ""
if g.AlwaysAppendDS || len(vl.Values) != 1 {
dsName = vl.DSName(i)
}
name := g.formatName(vl.Identifier, dsName)
val, err := g.formatValue(v)
if err != nil {
return err
}
t := vl.Time
if t.IsZero() {
t = time.Now()
}
fmt.Fprintf(g.W, "%s %s %d\r\n", name, val, t.Unix())
}
return nil
}
示例4: newDesc
// newDesc converts one data source of a value list to a Prometheus description.
func newDesc(vl api.ValueList, index int) *prometheus.Desc {
help := fmt.Sprintf("Collectd exporter: '%s' Type: '%s' Dstype: '%T' Dsname: '%s'",
vl.Plugin, vl.Type, vl.Values[index], vl.DSName(index))
return prometheus.NewDesc(newName(vl, index), help, []string{}, newLabels(vl))
}