devmon

package
v0.0.0-...-e4d4864 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	Kilo       = 1 << 10
	Mega       = 1 << 20
	Giga       = 1 << 30
	Tera       = 1 << 40
	Peta       = 1 << 50
	SectorSize = 512
)
View Source
const (
	HostnameEnvKey     = "HOSTNAME"
	PodNameEnvKey      = "POD_NAME"
	PodNamespaceEnvKey = "POD_NAMESPACE"
	PodIPEnvKey        = "POD_IP"
	HostIPEnvKey       = "HOST_IP"
)

Variables

View Source
var (
	DefaultMetricsPort = int(8080)
)

Functions

func GetRunningPod

func GetRunningPod(ctx context.Context, clnt *client,
	nname types.NamespacedName) (*corev1.Pod, error)

func ListAllRunningPods

func ListAllRunningPods(ctx context.Context, clnt *client) ([]*corev1.Pod, error)

func ListRunningPodsWith

func ListRunningPodsWith(ctx context.Context, clnt *client,
	namePrefix, hostIP string) ([]*corev1.Pod, error)

func LocateSsa

func LocateSsa() (string, error)

func LogSelfIdent

func LogSelfIdent(log logr.Logger)

func ParseSsaVersion

func ParseSsaVersion(dat string) (string, error)

func ProbePrintDevices

func ProbePrintDevices() error

func Progname

func Progname() string

func RunDevicesExporter

func RunDevicesExporter(port int) error

func RunSsaVersion

func RunSsaVersion() (string, error)

func Version

func Version() string

Types

type BlkdevID

type BlkdevID struct {
	MajorNumber uint32 `json:"major"`
	MinorNumber uint32 `json:"minor"`
	DeviceName  string `json:"devname"`
}

type BlkdevIOInfo

type BlkdevIOInfo struct {
	BlkdevID
	BlkdevIOStat
}

func DescoveBlockDevicesIO

func DescoveBlockDevicesIO(procfs *ProcFS, sysfs *SysFS) ([]BlkdevIOInfo, error)

type BlkdevIOStat

type BlkdevIOStat struct {
	ReadsIOs         uint64 `json:"readios"`
	ReadsMerged      uint64 `json:"readsmerged"`
	ReadsBytes       uint64 `json:"readsbytes"`
	ReadTimeMS       uint64 `json:"readtimems"`
	WritesIOs        uint64 `json:"writeios"`
	WritesMerged     uint64 `json:"writesmerged"`
	WritesBytes      uint64 `json:"writesbytes"`
	WriteTimeMS      uint64 `json:"writetimems"`
	InFlight         uint64 `json:"inflight"`
	IOTimeMS         uint64 `json:"iotimems"`
	WeightedIOTimeMS uint64 `json:"weightediotimems"`
}

BlkdevIOStat represents procfs diskstats info https://www.kernel.org/doc/Documentation/iostats.txt, https://www.kernel.org/doc/Documentation/block/stat.txt, https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats

type BlkdevInfo

type BlkdevInfo struct {
	Major    uint32 `json:"major"`
	Minor    uint32 `json:"minor"`
	Name     string `json:"name"`
	Size     uint64 `json:"size"`
	Vendor   string `json:"vendor"`
	Model    string `json:"model"`
	Readonly bool   `json:"readonly"`
}

BlkdevInfo contains collection of raw information under /sys/block/<disk>/... https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-block

func DiscoverBlkdevInfo

func DiscoverBlkdevInfo(procfs *ProcFS, sysfs *SysFS) ([]BlkdevInfo, error)

type BlkdevMap

type BlkdevMap struct {
	IDs     map[string]BlkdevID
	IOStats map[string]*BlkdevIOStat
	QStats  map[string]*BlkdevQueueStats
}

func DiscoverBlkdevStats

func DiscoverBlkdevStats(procfs *ProcFS, sysfs *SysFS) (*BlkdevMap, error)

type BlkdevQueueStats

type BlkdevQueueStats struct {
	AddRandom            bool   `json:"addrandom"`
	DAX                  bool   `json:"dax"`
	DiscardGranularity   uint64 `json:"discardgranularity"`
	DiscardMaxHWBytes    uint64 `json:"discardmaxhwbytes"`
	DiscardMaxBytes      uint64 `json:"discardmaxbytes"`
	FUA                  bool   `json:"fua"`
	HWSectorSize         uint32 `json:"hwsectorsize"`
	IOPoll               bool   `json:"iopoll"`
	IOPollDelay          int    `json:"iopolldelay"`
	IOTimeout            uint64 `json:"iotimeout"`
	IOStats              bool   `json:"iostats"`
	LogicalBlockSize     uint64 `json:"logicalblocksize"`
	MaxHWSectorsKB       uint64 `json:"maxhwsectorskb"`
	MaxIntegritySegments uint64 `json:"maxintegritysegments"`
	MaxSectorsKB         uint64 `json:"maxsectorskb"`
	MaxSegments          uint64 `json:"maxsegments"`
	MaxSegmentSize       uint64 `json:"maxsegmentsize"`
	MinimumIOSize        uint64 `json:"minimumiosize"`
	NoMerges             uint32 `json:"nomerges"`
	NRRequests           uint64 `json:"nrrequests"`
	OptimalIOSize        uint64 `json:"optimaliosize"`
	PhysicalBlockSize    uint64 `json:"physicalblocksize"`
	ReadAHeadKB          uint64 `json:"readaheadkb"`
	Rotational           bool   `json:"rotational"`
	RQAffinity           uint32 `json:"rqaffinity"`
	Scheduler            string `json:"scheduler"`
	WriteCache           string `json:"writecache"`
	WriteSameMaxBytes    uint64 `json:"writesamemaxbytes"`
	WBTLatUSec           int    `json:"wbtlatusec"`
	Zoned                string `json:"zoned"`
	ZoneWriteGranularity int    `json:"zonewritegranularity"`
}

BlkdevQueueStats represents sysfs block-queue info https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt https://www.kernel.org/doc/html/latest/block/queue-sysfs.html

type Ident

type Ident struct {
	Progname  string     `json:"program"`
	Version   string     `json:"version"`
	Hostname  string     `json:"hostname"`
	Name      string     `json:"name"`
	Namespace string     `json:"namespace"`
	HostIP    string     `json:"hostip"`
	PodIP     string     `json:"podip"`
	User      *user.User `json:"user"`
}

func SelfIdent

func SelfIdent() *Ident

type NodeInfo

type NodeInfo struct {
	SysUname
	HostIP []string `json:"hostip"`
}

type ProcFS

type ProcFS struct {
	PseudoFS
}

func NewProcFS

func NewProcFS() *ProcFS

func (*ProcFS) Devices

func (procfs *ProcFS) Devices() (map[int]string, map[int]string, error)

Devices parses "/proc/devices" into maps of character-devices and block-devices, indexed by device-number. See man(5) proc.

func (*ProcFS) DiskStats

func (procfs *ProcFS) DiskStats() ([]BlkdevIOInfo, error)

DiskStats converts "/proc/diskstats" info into BlkdevIOStat representation. See: https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats

func (*ProcFS) LoadAvg

func (procfs *ProcFS) LoadAvg() (*SysLoadAvg, error)

type PseudoFS

type PseudoFS struct {
	Prefix string
}

func (*PseudoFS) IsDir

func (pfs *PseudoFS) IsDir(subs ...string) (bool, error)

func (*PseudoFS) ParseBool

func (pfs *PseudoFS) ParseBool(s string) (bool, error)

func (*PseudoFS) ParseFloat

func (pfs *PseudoFS) ParseFloat(s string) (float64, error)

func (*PseudoFS) ParseInt

func (pfs *PseudoFS) ParseInt(s string) (int, error)

func (*PseudoFS) ParseMultUint64

func (pfs *PseudoFS) ParseMultUint64(s string, mul uint64) (uint64, error)

func (*PseudoFS) ParseUint32

func (pfs *PseudoFS) ParseUint32(s string) (uint32, error)

func (*PseudoFS) ParseUint64

func (pfs *PseudoFS) ParseUint64(s string) (uint64, error)

func (*PseudoFS) ReadDir

func (pfs *PseudoFS) ReadDir(subs ...string) ([]string, error)

func (*PseudoFS) ReadFile

func (pfs *PseudoFS) ReadFile(subs ...string) (string, error)

func (*PseudoFS) ReadFileAsBool

func (pfs *PseudoFS) ReadFileAsBool(subs ...string) (bool, error)

func (*PseudoFS) ReadFileAsInt

func (pfs *PseudoFS) ReadFileAsInt(subs ...string) (int, error)

func (*PseudoFS) ReadFileAsUInt32

func (pfs *PseudoFS) ReadFileAsUInt32(subs ...string) (uint32, error)

func (*PseudoFS) ReadFileAsUInt64

func (pfs *PseudoFS) ReadFileAsUInt64(subs ...string) (uint64, error)

func (*PseudoFS) ReadFileFields

func (pfs *PseudoFS) ReadFileFields(subs ...string) ([]string, error)

func (*PseudoFS) ReadFileLines

func (pfs *PseudoFS) ReadFileLines(subs ...string) ([]string, error)

func (*PseudoFS) ReadFileTrim

func (pfs *PseudoFS) ReadFileTrim(subs ...string) (string, error)

func (*PseudoFS) SplitFields

func (pfs *PseudoFS) SplitFields(s string, min int) ([]string, error)

type SsaArray

type SsaArray struct {
	SsaEntry
	LogicalDrive  []*SsaLogicalDrive
	PhysicalDrive []*SsaPhysicalDrive
}

type SsaConfigInfo

type SsaConfigInfo struct {
	Slots []*SsaSlot
}

func ParseSsaShowConfig

func ParseSsaShowConfig(dat string) (*SsaConfigInfo, error)

func RunSsaShowConfig

func RunSsaShowConfig() (*SsaConfigInfo, error)

type SsaEntry

type SsaEntry struct {
	Title  string
	Values map[string]string
}

type SsaLogicalDrive

type SsaLogicalDrive struct {
	SsaEntry
}

type SsaLogicalDriveInfo

type SsaLogicalDriveInfo struct {
	ID             string `json:"id"`
	DiskName       string `json:"diskname"`
	Size           string `json:"size"`
	SizeBytes      uint64 `json:"sizebytes"`
	Status         string `json:"status"`
	UniqueID       string `json:"uniqueid"`
	ArrayName      string `json:"arrayname"`
	PhysicalDrives []SsaPhysicalDriveInfo
}

type SsaMap

type SsaMap struct {
	DevMap map[string]SsaLogicalDriveInfo
}

func NewSsaMap

func NewSsaMap() *SsaMap

func ParseConfigToLogical

func ParseConfigToLogical(config *SsaConfigInfo) (*SsaMap, error)

type SsaPhysicalDrive

type SsaPhysicalDrive struct {
	SsaEntry
}

type SsaPhysicalDriveInfo

type SsaPhysicalDriveInfo struct {
	ID         string `json:"id"`
	Box        string `json:"box"`
	Bay        string `json:"bay"`
	Size       string `json:"size"`
	SizeBytes  uint64 `json:"sizebytes"`
	Status     string `json:"status"`
	Serial     string `json:"serial"`
	TempCurr   int64  `json:"tempcurr"`
	TempMaxi   int64  `json:"tempmaxi"`
	UniqueID   string `json:"uniqueid"`
	PowerHours int64  `json:"powerhours"` // nolint:misspell
}

type SsaSlot

type SsaSlot struct {
	SsaEntry
	Array []*SsaArray
}

type SysFS

type SysFS struct {
	PseudoFS
}

func NewSysFS

func NewSysFS() *SysFS

func (*SysFS) BlkdevInfo

func (sysfs *SysFS) BlkdevInfo(dev string) (*BlkdevInfo, error)

BlkdevInfo parses raw information from under /sys/block/<dev>/...

func (*SysFS) BlockDeviceQueueSub

func (sysfs *SysFS) BlockDeviceQueueSub(dev string) *PseudoFS

func (*SysFS) BlockDeviceSub

func (sysfs *SysFS) BlockDeviceSub(dev string) *PseudoFS

func (*SysFS) BlockQueueStats

func (sysfs *SysFS) BlockQueueStats(dev string) (*BlkdevQueueStats, error)

BlockQueueStats parses /sys/block/<dev>/queue

func (*SysFS) BlockStat

func (sysfs *SysFS) BlockStat(dev string) (*BlkdevIOStat, error)

BlockStat parses /sys/block/<device>/stat https://www.kernel.org/doc/Documentation/block/stat.txt

func (*SysFS) IsBlock

func (sysfs *SysFS) IsBlock(name string) (bool, error)

IsBlock expects /sys/block/<name>/ dir

func (*SysFS) ListBlockDevices

func (sysfs *SysFS) ListBlockDevices() ([]string, error)

func (*SysFS) Sub

func (sysfs *SysFS) Sub(subpath string) *PseudoFS

type SysLoadAvg

type SysLoadAvg struct {
	Load1  float64 `json:"load1"`
	Load5  float64 `json:"load5"`
	Load15 float64 `json:"load15"`
}

type SysUname

type SysUname struct {
	Sysname  string `json:"sysname"`
	Nodename string `json:"nodename"`
	Release  string `json:"release"`
	Version  string `json:"version"`
	Machine  string `json:"machine"`
}

func Uname

func Uname() (*SysUname, error)

Jump to

Keyboard shortcuts

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