本文整理汇总了Golang中collectd/org/api.ValueList类的典型用法代码示例。如果您正苦于以下问题:Golang ValueList类的具体用法?Golang ValueList怎么用?Golang ValueList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ValueList类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:octo,项目名称:collectd_exporter,代码行数:18,代码来源:main.go
示例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
}
开发者ID:li-ang,项目名称:influxdb,代码行数:46,代码来源:service.go
示例3: parseTime
func parseTime(partType uint16, payload []byte, state *api.ValueList) error {
v, err := parseInt(payload)
if err != nil {
return err
}
switch partType {
case typeInterval:
state.Interval = time.Duration(v) * time.Second
case typeIntervalHR:
state.Interval = cdtime.Time(v).Duration()
case typeTime:
state.Time = time.Unix(int64(v), 0)
case typeTimeHR:
state.Time = cdtime.Time(v).Time()
}
return nil
}
开发者ID:zj8487,项目名称:go-collectd,代码行数:19,代码来源:parse.go
示例4: 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
}
开发者ID:rubenk,项目名称:go-collectd,代码行数:26,代码来源:graphite.go
示例5: 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))
}
开发者ID:octo,项目名称:collectd_exporter,代码行数:7,代码来源:main.go
注:本文中的collectd/org/api.ValueList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论