func (m *monitoring) setBackend(mb Backend) {
	if m.b != nil {
		m.b.Stop()
	}
	m.b = mb
}
setBackend sets the current backend. If one
is already set it will be stopped.
package monitoring
import (
	"fmt"
	"io"
	"os"
	"sync"
	"time"
)
const (
	etmTLine  = "+----------------------------------------------------+------------+--------------------+--------------------+--------------------+\n"
	etmHeader = "| Measuring Point Name                               | Count      | Min Dur            | Max Dur            | Avg Dur            |\n"
	etmFormat = "| %-50s | %10d | %18s | %18s | %18s |\n"
	ssvTLine  = "+----------------------------------------------------+-----------+---------------+---------------+---------------+---------------+\n"
	ssvHeader = "| Stay-Set Variable Name                             | Count     | Act Value     | Min Value     | Max Value     | Avg Value     |\n"
	ssvFormat = "| %-50s | %9d | %13d | %13d | %13d | %13d |\n"
	dsrTLine  = "+----------------------------------------------------+---------------------------------------------------------------------------+\n"
	dsrHeader = "| Dynamic Status                                     | Value                                                                     |\n"
	dsrFormat = "| %-50s | %-73s |\n"
)
type IDFilter func(id string) bool
type Measuring interface {
	EndMeasuring() time.Duration
}
type MeasuringPoint interface {
	fmt.Stringer
	ID() string
	Count() int64
	MinDuration() time.Duration
	MaxDuration() time.Duration
	AvgDuration() time.Duration
}
type MeasuringPoints []MeasuringPoint
func (m MeasuringPoints) Len() int           { return len(m) }
func (m MeasuringPoints) Swap(i, j int)      { m[i], m[j] = m[j], m[i] }
func (m MeasuringPoints) Less(i, j int) bool { return m[i].ID() < m[j].ID() }
type StaySetVariable interface {
	fmt.Stringer
	ID() string
	Count() int64
	ActValue() int64
	MinValue() int64
	MaxValue() int64
	AvgValue() int64
}
type StaySetVariables []StaySetVariable
func (s StaySetVariables) Len() int           { return len(s) }
func (s StaySetVariables) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s StaySetVariables) Less(i, j int) bool { return s[i].ID() < s[j].ID() }
type DynamicStatusRetriever func() (string, error)
type DynamicStatusValue interface {
	fmt.Stringer
	ID() string
	Value() string
}
type DynamicStatusValues []DynamicStatusValue
func (d DynamicStatusValues) Len() int           { return len(d) }
func (d DynamicStatusValues) Swap(i, j int)      { d[i], d[j] = d[j], d[i] }
func (d DynamicStatusValues) Less(i, j int) bool { return d[i].ID() < d[j].ID() }
type Backend interface {
	BeginMeasuring(id string) Measuring
	ReadMeasuringPoint(id string) (MeasuringPoint, error)
	MeasuringPointsDo(f func(MeasuringPoint)) error
	SetVariable(id string, v int64)
	IncrVariable(id string)
	DecrVariable(id string)
	ReadVariable(id string) (StaySetVariable, error)
	StaySetVariablesDo(f func(StaySetVariable)) error
	Register(id string, rf DynamicStatusRetriever)
	ReadStatus(id string) (string, error)
	DynamicStatusValuesDo(f func(DynamicStatusValue)) error
	SetMeasuringsFilter(f IDFilter) IDFilter
	SetVariablesFilter(f IDFilter) IDFilter
	SetRetrieversFilter(f IDFilter) IDFilter
	Reset() error
	Stop()
}
type monitoring struct {
	sync.RWMutex
	b Backend
}
func (m *monitoring) backend() Backend {
	if m.b == nil {
		m.b = NewStandardBackend()
	}
	return m.b
}