host

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 11 Imported by: 0

README

Host Metrics

TODO

Known issues

  • machine disk space only consider filesystem mount to /
    • this is likely not the case in most cloud service providers, default volume is mainly for os instead of large data

Test data

cat /proc/stat > stat

Documentation

Index

Constants

View Source
const (
	// TODO: it seems it is always the case for x86, sysconf(_SC_CLK_TCK) would have the right value
	// TODO: should we / CPUUserHz like we did in xephon-k collector
	CPUUserHz = 100
)

TODO: /proc/stat has more than just cpu TODO: cadvisor change log says uint64 could overflow in version 0.23.4

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockDevice

type BlockDevice struct {
	// /dev/block/major:minor
	Major uint64
	Minor uint64
	Name  string

	// Field 1 - 11
	ReadsCompleted uint64
	// Reads and writes which are adjacent to each other may be merged for
	// efficiency.  Thus two 4K reads may become one 8K read before it is
	// ultimately handed to the disk, and so it will be counted (and queued)
	// as only one I/O.  This field lets you know how often this was done
	ReadsMerged        uint64
	SectorsRead        uint64 // TODO: sector size?
	TimeSpentReadingMs uint64
	WritesCompleted    uint64
	WritesMerged       uint64
	SectorsWritten     uint64 // TODO: same as read
	TimeSpentWritingMs uint64
	// Field 9: The only field that should go to zero. Incremented as requests are given to appropriate struct request_queue and decremented as they finish
	IoInProgress uint64
	// Field 10: This field increases so long as field 9 is nonzero
	TimeSpentIoMs         uint64
	WeightedTimeSpentIoMs uint64
}

type BlockDevices

type BlockDevices struct {
	Devices []BlockDevice
	// contains filtered or unexported fields
}

func NewBlockDevices

func NewBlockDevices(path string) *BlockDevices

func (*BlockDevices) IsStatic

func (s *BlockDevices) IsStatic() bool

func (*BlockDevices) Path

func (s *BlockDevices) Path() string

func (*BlockDevices) Update

func (s *BlockDevices) Update() error

Update simply open the file and call UpdateFrom, they are generated by gommon from go template

func (*BlockDevices) UpdateFrom

func (s *BlockDevices) UpdateFrom(r io.Reader) error

type Cpu

type Cpu struct {
	User      uint64
	Nice      uint64
	System    uint64
	Idle      uint64
	IOWait    uint64
	Irq       uint64
	SoftIrq   uint64
	Steal     uint64
	Guest     uint64
	GuestNice uint64
}

type Cpus

type Cpus struct {
	Total Cpu
	Cores []Cpu
	// contains filtered or unexported fields
}

func NewCpus

func NewCpus(path string) *Cpus

func (*Cpus) IsStatic

func (s *Cpus) IsStatic() bool

func (*Cpus) Path

func (s *Cpus) Path() string

func (*Cpus) Update

func (s *Cpus) Update() error

Update simply open the file and call UpdateFrom, they are generated by gommon from go template

func (*Cpus) UpdateFrom

func (s *Cpus) UpdateFrom(r io.Reader) error

type Filesystem

type Filesystem struct {
	Type int64
	// Optimal transfer block size
	BlockSize uint64
	// Total data blocks in filesystem
	Blocks uint64
	// Free blocks in filesystem
	BlocksFree uint64
	// Free blocks available to unprivileged user
	BlocksAvail uint64

	// Total file nodes in filesystem
	Files uint64
	// Free file nodes in filesystem
	FilesFree uint64
	// contains filtered or unexported fields
}

func NewFilesystem

func NewFilesystem(path string) *Filesystem

func (*Filesystem) IsStatic

func (s *Filesystem) IsStatic() bool

func (*Filesystem) Path

func (s *Filesystem) Path() string

func (*Filesystem) Update

func (s *Filesystem) Update() error

func (*Filesystem) UpdateFrom

func (s *Filesystem) UpdateFrom(_ io.Reader) error

type Machine

type Machine struct {
	NumCores       int
	MemTotal       uint64 // KB
	MemFree        uint64
	MemAvail       uint64 // NOTE: MemAvail = MemFree + Cache + Buffer
	DiskSpaceTotal uint64 // B
	DiskSpaceFree  uint64
	DiskInodeTotal uint64
	DiskInodeFree  uint64
	HostName       string
	BootTime       uint64
	// contains filtered or unexported fields
}

TODO: release information from lsb-release and os-release, saw it in gopsutil TODO: Machine contains information about physical node or vm, it won't change unless there are external forces

func NewMachine

func NewMachine() *Machine

func (*Machine) IsStatic

func (s *Machine) IsStatic() bool

func (*Machine) Update

func (s *Machine) Update() error

type Mem

type Mem struct {
	MemTotal     uint64
	MemFree      uint64
	MemAvailable uint64
	Buffers      uint64
	Cached       uint64
	Active       uint64
	Inactive     uint64
	Dirty        uint64
	Writeback    uint64 // Memory which is actively being written back to the disk
	Mapped       uint64 // Files which have been mapped into memory (with mmap(2)), such as librarie
	Shmem        uint64 // Amount of memory consumed in tmpfs(5) filesystems
	Slab         uint64 // In-kernel data structures cache
	SReclaimable uint64
	SUnreclaim   uint64
	KernelStack  uint64 // Amount of memory allocated to kernel stacks
	PageTables   uint64
	WritebackTmp uint64 // Memory used by FUSE for temporary writeback buffers
	HugePagesize uint64
	DirectMap4k  uint64
	DirectMap2M  uint64
	DirectMap1G  uint64

	SwapCached uint64
	SwapTotal  uint64
	SwapFree   uint64
	// contains filtered or unexported fields
}

TODO: the code for reading mem should be generated, also we can add descriptions

func NewMem

func NewMem(path string) *Mem

func (*Mem) IsStatic

func (s *Mem) IsStatic() bool

func (*Mem) Path

func (s *Mem) Path() string

func (*Mem) Update

func (s *Mem) Update() error

Update simply open the file and call UpdateFrom, they are generated by gommon from go template

func (*Mem) UpdateFrom

func (s *Mem) UpdateFrom(r io.Reader) error

type ProcFile

type ProcFile interface {
	Path() string
}

type Stat

type Stat interface {
	IsStatic() bool
	Update() error
	UpdateFrom(r io.Reader) error
}

Jump to

Keyboard shortcuts

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