Exemplo n.º 1
0
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
}
Exemplo n.º 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}
}
Exemplo n.º 3
0
Arquivo: parser.go Projeto: 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
}
Exemplo n.º 4
0
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
}