示例#1
0
文件: parser.go 项目: sclasen/l2met
func (p *parser) handleHkRouter(t *tuple) error {
	if string(p.lr.Header().Procid) != routerPrefix {
		return nil
	}
	id := new(bucket.Id)
	id.Resolution = p.Resolution()
	id.Time = p.Time()
	id.User = p.User()
	id.Pass = p.Pass()
	id.Source = p.ld.Source()
	id.Units = t.Units()
	switch t.Name() {
	case "bytes":
		id.Name = p.Prefix("router.bytes")
	case "connect":
		id.Name = p.Prefix("router.connect")
	case "service":
		id.Name = p.Prefix("router.service")
	default:
		return nil
	}
	val, err := t.Float64()
	if err != nil {
		return err
	}
	p.out <- &bucket.Bucket{Id: id, Vals: []float64{val}}
	return nil
}
示例#2
0
func testBucket(name, source, user, pass string, t time.Time, res time.Duration, vals []float64) *bucket.Bucket {
	id := new(bucket.Id)
	id.Name = name
	id.Source = source
	id.User = user
	id.Pass = pass
	id.Time = t.Truncate(res)
	id.Resolution = res
	return &bucket.Bucket{Id: id, Vals: vals}
}
示例#3
0
func (p *parser) buildId(id *bucket.Id, t *tuple) {
	id.Resolution = p.Resolution()
	id.Time = p.Time()
	id.Auth = p.Auth()
	id.ReadyAt = id.Time.Add(id.Resolution).Truncate(id.Resolution)
	id.Name = p.Prefix(t.Name())
	id.Units = t.Units()
	id.Source = p.SourcePrefix(p.ld.Source())
	return
}
示例#4
0
文件: parser.go 项目: Jwpe/l2met
func (p *parser) buildId(id *bucket.Id, t *tuple) {
	id.Resolution = p.Resolution()
	id.Time = p.Time()
	id.User = p.User()
	id.Pass = p.Pass()
	id.Name = p.Prefix(t.Name())
	id.Units = t.Units()
	id.Source = p.ld.Source()
	return
}
示例#5
0
func (p *parser) handleHkRouter(t *tuple) error {
	if string(p.lr.Header().Procid) != routerPrefix {
		return nil
	}
	id := new(bucket.Id)
	p.buildId(id, t)
	id.Type = "measurement"
	switch t.Name() {
	case "bytes":
		id.Name = p.Prefix("router.bytes")
	case "connect":
		id.Name = p.Prefix("router.connect")
	case "service":
		id.Name = p.Prefix("router.service")
	default:
		return nil
	}
	val, err := t.Float64()
	if err != nil {
		return err
	}
	p.out <- &bucket.Bucket{Id: id, Vals: []float64{val}}
	return nil
}
示例#6
0
文件: parser.go 项目: sclasen/l2met
func (p *parser) handlMeasurements(t *tuple) error {
	if !strings.HasPrefix(t.Name(), measurePrefix) {
		return nil
	}
	id := new(bucket.Id)
	id.Resolution = p.Resolution()
	id.Time = p.Time()
	id.User = p.User()
	id.Pass = p.Pass()
	id.Name = p.Prefix(t.Name())
	id.Units = t.Units()
	id.Source = p.ld.Source()
	val, err := t.Float64()
	if err != nil {
		return err
	}
	p.out <- &bucket.Bucket{Id: id, Vals: []float64{val}}
	return nil
}