func DynamicStatusValuesDo(f func(DynamicStatusValue)) error {
	monitor.RLock()
	defer monitor.RUnlock()
	return monitor.backend().DynamicStatusValuesDo(f)
}
DynamicStatusValuesDo performs the function f for all
status values.
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
}
func (m *monitoring) setBackend(mb Backend) {
	if m.b != nil {
		m.b.Stop()
	}
	m.b = mb
}
var monitor = &monitoring{}
func SetBackend(mb Backend) {
	monitor.Lock()
	defer monitor.Unlock()
	monitor.setBackend(mb)
}
func BeginMeasuring(id string) Measuring {
	monitor.RLock()
	defer monitor.RUnlock()
	return monitor.backend().BeginMeasuring(id)
}
func Measure(id string, f func()) time.Duration {
	m := BeginMeasuring(id)
	f()
	return m.EndMeasuring()
}
func ReadMeasuringPoint(id string) (MeasuringPoint, error) {
	monitor.RLock()
	defer monitor.RUnlock()
	return monitor.backend().ReadMeasuringPoint(id)
}
func MeasuringPointsDo(f func(MeasuringPoint)) error {
	monitor.RLock()
	defer monitor.RUnlock()
	return monitor.backend().MeasuringPointsDo(f)
}
func MeasuringPointsWrite(w io.Writer, ff func(MeasuringPoint) bool) error {
	fmt.Fprint(w, etmTLine)
	fmt.Fprint(w, etmHeader)
	fmt.Fprint(w, etmTLine)
	if err := MeasuringPointsDo(func(mp MeasuringPoint) {
		if ff(mp) {
			fmt.Fprintf(w, etmFormat, mp.ID(), mp.Count(), mp.MinDuration(), mp.MaxDuration(), mp.AvgDuration())
		}
	}); err != nil {
		return err
	}
	fmt.Fprint(w, etmTLine)
	return nil
}
func MeasuringPointsPrintAll() error {
	return MeasuringPointsWrite(os.Stdout, func(mp MeasuringPoint) bool { return true })
}
func SetVariable(id string, v int64) {
	monitor.RLock()
	defer monitor.RUnlock()
	monitor.backend().SetVariable(id, v)
}
func IncrVariable(id string) {
	monitor.RLock()
	defer monitor.RUnlock()
	monitor.backend().IncrVariable(id)
}
func DecrVariable(id string) {
	monitor.RLock()
	defer monitor.RUnlock()
	monitor.backend().DecrVariable(id)
}
func ReadVariable(id string) (StaySetVariable, error) {
	monitor.RLock()
	defer monitor.RUnlock()
	return monitor.backend().ReadVariable(id)
}
func StaySetVariablesDo(f func(StaySetVariable)) error {
	monitor.RLock()
	defer monitor.RUnlock()
	return monitor.backend().StaySetVariablesDo(f)
}
func StaySetVariablesWrite(w io.Writer, ff func(StaySetVariable) bool) error {
	fmt.Fprint(w, ssvTLine)
	fmt.Fprint(w, ssvHeader)
	fmt.Fprint(w, ssvTLine)
	if err := StaySetVariablesDo(func(ssv StaySetVariable) {
		if ff(ssv) {
			fmt.Fprintf(w, ssvFormat, ssv.ID(), ssv.Count(), ssv.ActValue(), ssv.MinValue(), ssv.MaxValue(), ssv.AvgValue())
		}
	}); err != nil {
		return err
	}
	fmt.Fprint(w, ssvTLine)
	return nil
}
func StaySetVariablesPrintAll() error {
	return StaySetVariablesWrite(os.Stdout, func(ssv StaySetVariable) bool { return true })
}
func Register(id string, rf DynamicStatusRetriever) {
	monitor.RLock()
	defer monitor.RUnlock()
	monitor.backend().Register(id, rf)
}
func ReadStatus(id string) (string, error) {
	monitor.RLock()
	defer monitor.RUnlock()
	return monitor.backend().ReadStatus(id)
}