mmvdump

package
v3.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2017 License: MIT Imports: 7 Imported by: 5

README

mmvdump GoDoc

Package mmvdump implements a go port of the C mmvdump utility included in PCP Core

https://github.com/performancecopilot/pcp/blob/master/src/pmdas/mmv/mmvdump.c

It has been written for maximum portability with the C equivalent, without having to use cgo or any other ninja stuff

the main difference is that the reader is separate from the cli with the reading primarily implemented in mmvdump.go while the cli is implemented in cmd/mmvdump

the cli application is completely go gettable and outputs the same things, in mostly the same way as the C cli app, to try it out,

go get github.com/performancecopilot/speed/mmvdump/cmd/mmvdump

Documentation

Overview

Package mmvdump implements a go port of the C mmvdump utility included in PCP Core

https://github.com/performancecopilot/pcp/blob/master/src/pmdas/mmv/mmvdump.c

It has been written for maximum portability with the C equivalent, without having to use cgo or any other ninja stuff

the main difference is that the reader is separate from the cli with the reading primarily implemented in mmvdump.go while the cli is implemented in cmd/mmvdump

the cli application is completely go gettable and outputs the same things, in mostly the same way as the C cli app, to try it out,

``` go get github.com/performancecopilot/speed/mmvdump/cmd/mmvdump ```

Index

Constants

View Source
const (
	// NameMax is the maximum allowed length of a name
	NameMax = 64

	// StringMax is the maximum allowed length of a string
	StringMax = 256

	// NoIndom is a constant used to indicate absence of an indom from a metric
	NoIndom = -1
)
View Source
const (
	HeaderLength         uint64 = 40
	TocLength            uint64 = 16
	Metric1Length        uint64 = 104
	Metric2Length        uint64 = 48
	ValueLength          uint64 = 32
	Instance1Length      uint64 = 80
	Instance2Length      uint64 = 24
	InstanceDomainLength uint64 = 32
	StringLength         uint64 = 256
)

Byte Lengths for Different Components

View Source
const MMVVersion = 1

MMVVersion is the current mmv format version

Variables

This section is empty.

Functions

func Dump

func Dump(data []byte) (
	h *Header,
	tocs []*Toc,
	metrics map[uint64]Metric,
	values map[uint64]*Value,
	instances map[uint64]Instance,
	indoms map[uint64]*InstanceDomain,
	strings map[uint64]*String,
	err error,
)

Dump creates a data dump from the passed data

func FixedVal

func FixedVal(data uint64, t Type) (interface{}, error)

FixedVal will infer a fixed size value from the passed data

func Write

func Write(
	w io.Writer,
	header *Header,
	tocs []*Toc,
	metrics map[uint64]Metric,
	values map[uint64]*Value,
	instances map[uint64]Instance,
	indoms map[uint64]*InstanceDomain,
	strings map[uint64]*String,
) error

Write creates a writable representation of a MMV dump and writes it to the passed writer.

Types

type Header struct {
	Magic            [4]byte
	Version          int32
	G1, G2           uint64
	Toc              int32
	Flag             int32
	Process, Cluster int32
}

Header describes the data in a MMV header

type Instance

type Instance interface {
	Indom() uint64
	Internal() int32
	Padding() uint32
}

Instance is the base type for all instances

type Instance1

type Instance1 struct {
	InstanceBase
	External [NameMax]byte
}

Instance1 defines the contents in a valid mmv1 instance

type Instance2

type Instance2 struct {
	InstanceBase
	External uint64
}

Instance2 defines the contents in a valid mmv2 instance

type InstanceBase

type InstanceBase struct {
	// contains filtered or unexported fields
}

InstanceBase defines the common contents in a valid instance

func (InstanceBase) Indom

func (i InstanceBase) Indom() uint64

Indom returns the indom offset

func (InstanceBase) Internal

func (i InstanceBase) Internal() int32

Internal returns the internal id

func (InstanceBase) Padding

func (i InstanceBase) Padding() uint32

Padding returns the padding value

type InstanceDomain

type InstanceDomain struct {
	Serial, Count               uint32
	Offset, Shorttext, Longtext uint64
}

InstanceDomain defines the contents in a valid instance domain

type Metric

type Metric interface {
	Item() uint32
	Typ() Type
	Sem() Semantics
	Unit() Unit
	Indom() int32
	Padding() uint32
	ShortText() uint64
	LongText() uint64
}

Metric is the base type for all metrics

type Metric1

type Metric1 struct {
	Name [NameMax]byte
	MetricBase
}

Metric1 defines the contents in a valid Metric

type Metric2

type Metric2 struct {
	Name uint64
	MetricBase
}

Metric2 defines the contents in a valid Metric

type MetricBase

type MetricBase struct {
	// contains filtered or unexported fields
}

MetricBase defines the common contents in a valid Metric

func (MetricBase) Indom

func (m MetricBase) Indom() int32

Indom returns the indom id

func (MetricBase) Item

func (m MetricBase) Item() uint32

Item returns the item id

func (MetricBase) LongText

func (m MetricBase) LongText() uint64

LongText returns the longtext offset

func (MetricBase) Padding

func (m MetricBase) Padding() uint32

Padding returns the padding value

func (MetricBase) Sem

func (m MetricBase) Sem() Semantics

Sem returns the semantics

func (MetricBase) ShortText

func (m MetricBase) ShortText() uint64

ShortText returns the shorttext offset

func (MetricBase) Typ

func (m MetricBase) Typ() Type

Typ returns the type

func (MetricBase) Unit

func (m MetricBase) Unit() Unit

Unit returns the unit

type Semantics

type Semantics int32

Semantics represents an enumerated type representing all possible semantics of a metric

const (
	NoSemantics Semantics = 0
	CounterSemantics

	InstantSemantics
	DiscreteSemantics
)

Values for Semantics

func (Semantics) String

func (i Semantics) String() string

type String

type String struct {
	Payload [StringMax]byte
}

String wraps the payload for a PCP String

type Toc

type Toc struct {
	Type   TocType
	Count  int32
	Offset uint64
}

Toc defines the contents in a valid TOC

type TocType

type TocType int32

TocType is an enumerated type with different types as values

const (
	TocIndoms TocType = iota + 1
	TocInstances
	TocMetrics
	TocValues
	TocStrings
)

Values for TocType

func (TocType) String

func (i TocType) String() string

type Type

type Type int32

Type is an enumerated type representing all valid types for a metric

const (
	NoSupportType Type = iota - 1
	Int32Type
	Uint32Type
	Int64Type
	Uint64Type
	FloatType
	DoubleType
	StringType
	UnknownType Type = 255
)

Possible values for a Type

func (Type) String

func (i Type) String() string

type Unit

type Unit uint32

Unit is an enumerated type with all possible units as values

const (
	ByteUnit Unit = 1<<28 | iota<<16
	KilobyteUnit
	MegabyteUnit
	GigabyteUnit
	TerabyteUnit
	PetabyteUnit
	ExabyteUnit
)

Values for Space Units

const (
	NanosecondUnit Unit = 1<<24 | iota<<12
	MicrosecondUnit
	MillisecondUnit
	SecondUnit
	MinuteUnit
	HourUnit
)

Values for Time Units

const (
	OneUnit Unit = 1<<20 | iota<<8
)

Values for Count Units

func (Unit) CountDim

func (u Unit) CountDim() int8

CountDim gets the count dimension of the unit the right shift is on int32 to get an arithmetic right shift as the dimension is serialized in 2s complement form

https://docs.rs/hornet/0.1.0/src/hornet/client/metric/mod.rs.html#410

func (Unit) CountScale

func (u Unit) CountScale() uint8

CountScale gets the Count Scale of a unit

https://docs.rs/hornet/0.1.0/src/hornet/client/metric/mod.rs.html#406

func (Unit) SpaceDim

func (u Unit) SpaceDim() int8

SpaceDim gets the space dimension of the unit the right shift is on int32 to get an arithmetic right shift as the dimension is serialized in 2s complement form

https://docs.rs/hornet/0.1.0/src/hornet/client/metric/mod.rs.html#410

func (Unit) SpaceScale

func (u Unit) SpaceScale() uint8

SpaceScale gets the Space Scale of a unit

https://docs.rs/hornet/0.1.0/src/hornet/client/metric/mod.rs.html#398

func (Unit) TimeDim

func (u Unit) TimeDim() int8

TimeDim gets the time dimension of the unit the right shift is on int32 to get an arithmetic right shift as the dimension is serialized in 2s complement form

https://docs.rs/hornet/0.1.0/src/hornet/client/metric/mod.rs.html#410

func (Unit) TimeScale

func (u Unit) TimeScale() uint8

TimeScale gets the Time Scale of a unit

https://docs.rs/hornet/0.1.0/src/hornet/client/metric/mod.rs.html#402

type Value

type Value struct {
	// uint64 is a holder type here, while printing it is expected that
	// the user will infer the value using the Val functions
	Val uint64

	Extra    int64
	Metric   uint64
	Instance uint64
}

Value defines the contents in a PCP Value

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL