Beispiel #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
}
Beispiel #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}
}
Beispiel #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
}
Beispiel #4
0
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
}
Beispiel #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
}
Beispiel #6
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
}