Documentation ¶
Index ¶
- Variables
- type BucketRange
- type Database
- type Iterator
- func (i *Iterator) Close() error
- func (i *Iterator) Prev(snapshot *Snapshot) bool
- func (i *Iterator) ReadAll() []Snapshot
- func (i *Iterator) ReadBucketEdges(precision time.Duration) SnapshotBuckets
- func (i *Iterator) ReadExact(precision time.Duration) SnapshotBuckets
- func (i *Iterator) ReadRemaining() []Snapshot
- func (i *Iterator) Remaining() int
- func (i *Iterator) Rewind()
- type IteratorOpts
- type Snapshot
- type SnapshotBucket
- type SnapshotBuckets
Constants ¶
This section is empty.
Variables ¶
var ErrUninitialized = errors.New("bucket not initialized")
ErrUninitialized is returned when sysmet's bucket is not found in the database. This may happen when the database has never been updated before.
Functions ¶
This section is empty.
Types ¶
type BucketRange ¶
type BucketRange struct { // From is always after To. From time.Time `json:"from"` To time.Time `json:"to"` Prec time.Duration `json:"prec"` }
BucketRange describes the range of snapshot buckets.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database describes a wrapped database instance.
func (*Database) GC ¶
GC cleans up the database. Since this is a fairly expensive operation, it should only be called rarely.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is a backwards metric iterator that allows iterating over points.
func (*Iterator) Prev ¶
Prev reads the previous item into the given snapshot pointer or the last item if the Reader has never been used before. If snapshot is nil, then the iterator is still updated, but no unmarshaling is done.
False is returned if nothing is read and the reader is closed, otherwise true is.
func (*Iterator) ReadAll ¶
ReadAll is similar to ReadRemaining, except the cursor is rewound to the requested position "from" and read again.
func (*Iterator) ReadBucketEdges ¶
func (i *Iterator) ReadBucketEdges(precision time.Duration) SnapshotBuckets
ReadBucketEdges behaves similarly to ReadExact, except each bucket will only have the latest point. This is great when data has to be read over a wide range of time.
func (*Iterator) ReadExact ¶
func (i *Iterator) ReadExact(precision time.Duration) SnapshotBuckets
ReadExact reads exactly the given time range, meaning the list of buckets will describe exactly the requested range and precision. The cursor will automatically be rewound back to the "from" position. The function returns a zero-value if from or to was 0.
func (*Iterator) ReadRemaining ¶
ReadRemaining reads all of the reader from the current position to end.
type IteratorOpts ¶
type IteratorOpts struct { // From is the time to start reading the metrics backwards. The default // zero-value means to read from the latest point. From time.Time // To is the time to stop reading the metrics backwards. By default, the // zero-value is used, which would read all metrics. The To time must // ALWAYS be before From. To time.Time }
IteratorOpts is the options for reading. It describes the range of data to read.
type Snapshot ¶
type Snapshot struct { CPUs []cpu.TimesStat Memory mem.VirtualMemoryStat Swap mem.SwapMemoryStat Network []net.IOCountersStat Disks []disk.UsageStat Temps []host.TemperatureStat LoadAvgs load.AvgStat HostStats load.MiscStat Time uint32 `json:"-"` }
Snapshot describes a single snapshot of data.
func PrepareMetrics ¶
PrepareMetrics prepares a set of metrics to write at once.
type SnapshotBucket ¶
type SnapshotBucket struct {
Snapshots []Snapshot `json:"snapshots"`
}
SnapshotBucket contains a bucket of snapshot timeframes. It is used by ReadExact to allow the caller to manually calculate the averages.
type SnapshotBuckets ¶
type SnapshotBuckets struct { Range BucketRange `json:"range"` Snapshots []Snapshot `json:"-"` Buckets []SnapshotBucket `json:"buckets"` }
SnapshotBuckets contains all snapshots as well as buckets of those snapshots over the given time.
func (*SnapshotBuckets) FillGaps ¶
func (buckets *SnapshotBuckets) FillGaps(gapPerc float64)
FillGaps fills the buckets with the given multiplier for determine the threshold. A good gapMult value is 0.10.
func (SnapshotBuckets) GapThreshold ¶
func (buckets SnapshotBuckets) GapThreshold(perc float64) int
GapThreshold returns the threshold that determine a gap after n empty buckets. The given perc variable determines the percentage from 0 to 1 that determines after how many empty buckets should be treated as a gap.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
sysmet-http/frontend/components/metric
Package metric draws metric graphs using SVG lines.
|
Package metric draws metric graphs using SVG lines. |