storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	SectorSize = 512
)

Variables

View Source
var (
	SupportedFileSystems = map[string]bool{
		"xfs":   true,
		"btrfs": true,
		"ext":   true,
		"ext2":  true,
		"ext3":  true,
		"ext4":  true,
		"hfs":   true,
		"vxfs":  true,
		"zfs":   true,
	}
)

Functions

func CalculateDeviceMapping

func CalculateDeviceMapping(activeDevices map[string]bool, isContainerized bool) (devToFullDevicePath map[string]string)

CalculateDeviceMapping maps devices found in mount information file to diskstats device name format "Normal" devices are mapped from /dev/sdxy to sdxy LVM devices will are mapped from /dev/mapper/xxx to dm-z where z comes either from

  • Min in MajMin if we have /proc/self[1]/mountInfo
  • LogVol[z] if the device is named with VolGroup[x]-LogVol[z]

Mounts in /dev/root are mapped to the actual device name using /proc/partitions This mapping will fail if we do not have mountInfo (for example older systems with just /proc/mounts) and the device is not named with the above pattern of VolGroup-LogVol. If we find ourselves in this situation we have to refactor this a lot more and use other tools to make this mapping instead of relying in the simple mount files

func GetDiskSerialNumber

func GetDiskSerialNumber(name string) string

GetDiskSerialNumber returns Serial Number of given device or empty string on error. Name of device is expected, eg. /dev/sda

func PlatformFsByteScale

func PlatformFsByteScale(b uint64) float64

Types

type BaseSample

type BaseSample struct {
	sample.BaseEvent

	MountPoint     string `json:"mountPoint"`
	Device         string `json:"device"`
	IsReadOnly     string `json:"isReadOnly"`
	FileSystemType string `json:"filesystemType"`
	CountersSource string `json:"countersSource,omitempty"` // Source for the IOCounters: wmi, pdh, diskstats

	UsedBytes               *float64 `json:"diskUsedBytes,omitempty"`
	UsedPercent             *float64 `json:"diskUsedPercent,omitempty"`
	FreeBytes               *float64 `json:"diskFreeBytes,omitempty"`
	FreePercent             *float64 `json:"diskFreePercent,omitempty"`
	TotalBytes              *float64 `json:"diskTotalBytes,omitempty"`
	TotalUtilizationPercent *float64 `json:"totalUtilizationPercent,omitempty"`
	ReadUtilizationPercent  *float64 `json:"readUtilizationPercent,omitempty"`
	WriteUtilizationPercent *float64 `json:"writeUtilizationPercent,omitempty"`
	ReadBytesPerSec         *float64 `json:"readBytesPerSecond,omitempty"`
	WriteBytesPerSec        *float64 `json:"writeBytesPerSecond,omitempty"`
	ReadWriteBytesPerSecond *float64 `json:"readWriteBytesPerSecond,omitempty"`
	ReadsPerSec             *float64 `json:"readIoPerSecond,omitempty"`
	WritesPerSec            *float64 `json:"writeIoPerSecond,omitempty"`
	IOTimeDelta             uint64   `json:"-"`
	ReadTimeDelta           uint64   `json:"-"`
	WriteTimeDelta          uint64   `json:"-"`
	ReadCountDelta          uint64   `json:"-"`
	WriteCountDelta         uint64   `json:"-"`
	ElapsedSampleDeltaMs    int64    `json:"-"`
	HasDelta                bool     `json:"-"`
}

BaseSample provides the basic fields for the storage.Sample instances of all the operating systems. The actual storage.Sample types are defined in the corresponding OS-bounded code files. We use pointers to floats instead of plain floats so that if we don't set one of the values, it will not be sent to Dirac. (Not using pointers would mean that Go would always send a default value of 0.)

type BlockDevice

type BlockDevice struct {
	Major string
	Minor string

	Name string
	// contains filtered or unexported fields
}

BlockDevice represents a linux fixed-sized blocks device

type IOCountersStat

type IOCountersStat interface {
	fmt.Stringer
	// Source returns an enumerative string of the IO counter source (e.g. "wmi", "pdh", "diskstats"...)
	Source() string
}

type LinuxIoCountersStat

type LinuxIoCountersStat struct {
	ReadCount               uint64 `json:"readCount"`
	MergedReadCount         uint64 `json:"mergedReadCount"`
	WriteCount              uint64 `json:"writeCount"`
	MergedWriteCount        uint64 `json:"mergedWriteCount"`
	ReadBytes               uint64 `json:"readBytes"`
	WriteBytes              uint64 `json:"writeBytes"`
	ReadTime                uint64 `json:"readTime"`
	WriteTime               uint64 `json:"writeTime"`
	IopsInProgress          uint64 `json:"iopsInProgress"`
	IoTime                  uint64 `json:"ioTime"`
	Name                    string `json:"name"`
	SerialNumber            string `json:"serialNumber"`
	TotalUtilizationPercent uint64 `json:"totalUtilizationPercent"`
	ReadUtilizationPercent  uint64 `json:"readUtilizationPercent"`
	WriteUtilizationPercent uint64 `json:"writeUtilizationPercent"`
}

Enhanced from GOPSUtil, Adding Utilization

func (*LinuxIoCountersStat) Source

func (*LinuxIoCountersStat) Source() string

func (*LinuxIoCountersStat) String

func (d *LinuxIoCountersStat) String() string

type LinuxStorageSampleWrapper

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

func (*LinuxStorageSampleWrapper) CalculateSampleValues

func (ssw *LinuxStorageSampleWrapper) CalculateSampleValues(counter, lastStats IOCountersStat, elapsedMs int64) *Sample

func (*LinuxStorageSampleWrapper) IOCounters

func (ssw *LinuxStorageSampleWrapper) IOCounters() (map[string]IOCountersStat, error)

func (*LinuxStorageSampleWrapper) Partitions

func (ssw *LinuxStorageSampleWrapper) Partitions() ([]PartitionStat, error)

func (*LinuxStorageSampleWrapper) Usage

func (ssw *LinuxStorageSampleWrapper) Usage(path string) (*disk.UsageStat, error)

type MountInfoStat

type MountInfoStat struct {
	Device      string
	MountPoint  string
	Root        string
	MajMin      string
	FSType      string
	MountSource string
	Opts        string
	// contains filtered or unexported fields
}

MountInfoStat represents linux mount information.

type PartitionStat

type PartitionStat struct {
	Device     string `json:"device"`
	Mountpoint string `json:"mountpoint"`
	Fstype     string `json:"fstype"`
	Opts       string `json:"opts"`
}

func (*PartitionStat) IsReadOnly

func (p *PartitionStat) IsReadOnly() bool

type PartitionsCache

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

PartitionsCache avoids polling for partitions on each sample, since they do not change so frequently

func (*PartitionsCache) Get

func (c *PartitionsCache) Get() ([]PartitionStat, error)

type Sample

type Sample struct {
	BaseSample
	InodesUsed        *uint64  `json:"inodesUsed,omitempty"`
	InodesFree        *uint64  `json:"inodesFree,omitempty"`
	InodesTotal       *uint64  `json:"inodesTotal,omitempty"`
	InodesUsedPercent *float64 `json:"inodesUsedPercent,omitempty"`
}

func CalculateSampleValues

func CalculateSampleValues(ioCounter IOCountersStat, ioLastStats IOCountersStat, elapsedMs int64) (ioSample *Sample)

type SampleWrapper

type SampleWrapper interface {
	Partitions() ([]PartitionStat, error)
	Usage(path string) (*disk.UsageStat, error)
	IOCounters() (map[string]IOCountersStat, error)
	CalculateSampleValues(counter, lastStats IOCountersStat, elapsedMs int64) *Sample
}

func NewStorageSampleWrapper

func NewStorageSampleWrapper(cfg *config.Config) SampleWrapper

type Sampler

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

func NewSampler

func NewSampler(context agent.AgentContext) *Sampler

func (*Sampler) Disabled

func (ss *Sampler) Disabled() bool

func (*Sampler) Interval

func (ss *Sampler) Interval() time.Duration

func (*Sampler) LastDiskStats

func (ss *Sampler) LastDiskStats() map[string]IOCountersStat

func (*Sampler) Name

func (ss *Sampler) Name() string

func (*Sampler) OnStartup

func (ss *Sampler) OnStartup()

func (*Sampler) Sample

func (ss *Sampler) Sample() (samples sample.EventBatch, err error)

Sample samples the storage devices

func (*Sampler) SampleWrapper

func (ss *Sampler) SampleWrapper() SampleWrapper

func (*Sampler) Samples

func (ss *Sampler) Samples() sample.EventBatch

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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