Documentation ¶
Index ¶
- Constants
- Variables
- func CollectSampleFromSys(s *Sample, exit *ExitProcess, log *slog.Logger) error
- type CPUStat
- type CgoupStat
- type CgroupFile
- type CgroupSample
- type ExitProcess
- type IOStat
- type Index
- type LocalStore
- func (local *LocalStore) CleanOldFiles(opt WriteOption)
- func (local *LocalStore) Close() error
- func (local *LocalStore) CollectSample(s *Sample) error
- func (local *LocalStore) DeleteSingleFile(shard int64)
- func (local *LocalStore) FileStatInfo() (result string, err error)
- func (local *LocalStore) JumpSampleByTimeStamp(timestamp int64, sample *Sample) error
- func (local *LocalStore) NextSample(step int, sample *Sample) error
- func (local *LocalStore) Snapshot(begin int64, end int64) (string, error)
- func (local *LocalStore) WriteLoop(opt WriteOption) error
- func (local *LocalStore) WriteSample(s *Sample) (bool, error)
- type MemoryEvents
- type MemoryStat
- type NetStat
- type Option
- type PSIData
- type PSIStats
- type PidMap
- type ProcSample
- type Sample
- type Store
- type SystemSample
- type VmStat
- type WriteOption
Constants ¶
View Source
const ( NoCompress = uint32(1 << iota) ZstdCompress ZstdCompressWithDict )
View Source
const ( CompressModeShift = 0 CompressModeLen = 8 DictOffsetShift = 8 DictOffsetLen = 24 MaxDictOffset = 1<<DictOffsetLen - 1 )
Variables ¶
View Source
var ( CgroupV2MountPoint = "/sys/fs/cgroup" ErrInvalidFormat = errors.New("cgroups: parsing file with invalid format failed") ErrInvalidGroupPath = errors.New("cgroups: invalid group path") )
Functions ¶
func CollectSampleFromSys ¶
func CollectSampleFromSys(s *Sample, exit *ExitProcess, log *slog.Logger) error
Types ¶
type CgroupFile ¶ added in v0.1.5
type CgroupFile int
const ( CpuStatFile CgroupFile = iota MemoryStatFile CpuSetCpusFile CpuSetCpusEffectiveFile CpuSetMemsFileFile CpuSetMemsEffectiveFile CpuWeightFile CpuMaxFile MemoryCurrentFile MemoryLowFile MemoryHighFile MemoryMinFile MemoryMaxFile MemoryPeakFile MemorySwapCurrentFile MemorySwapMaxFile MemoryZswapCurrentFile MemoryZswapMaxFile MemoryEventsFile IoStatFile CpuPressureFile MemoryPressureFile IoPressureFile )
type CgroupSample ¶ added in v0.1.5
type CgroupSample struct { Path string Name string Level int Inode uint64 Child map[string]*CgroupSample IsNotExist map[CgroupFile]struct{} Controllers string CgoupStat CPUStat MemoryStat CpuSetCpus string CpuSetCpusEffective string CpuSetMems string CpuSetMemsEffective string CpuWeight uint64 CpuMax string MemoryCurrent uint64 MemoryLow uint64 MemoryHigh uint64 MemoryMin uint64 MemoryMax uint64 MemoryPeak uint64 SwapCurrent uint64 SwapMax uint64 ZswapCurrent uint64 ZswapMax uint64 MemoryEvents IOStats []IOStat CpuPressure PSIStats MemoryPressure PSIStats IOPressure PSIStats }
type ExitProcess ¶ added in v0.0.3
type ExitProcess struct { sync.Mutex Samples map[int]ProcSample // contains filtered or unexported fields }
func NewExitProcess ¶ added in v0.0.3
func NewExitProcess(log *slog.Logger) *ExitProcess
func (*ExitProcess) Collect ¶ added in v0.0.3
func (e *ExitProcess) Collect()
type Index ¶
type Index struct { TimeStamp int64 // unix time when sample was generated Offset int64 // offset of file where sample is exist Len int64 // length of one sample Flag uint32 // compress mode and dict offset CRC uint32 // crc for whole index, except CRC self }
Index represent short info for one sample, so that speed up to find specifed sample.
func (*Index) CompressMode ¶ added in v0.0.9
func (*Index) SetCompressMode ¶ added in v0.0.9
type LocalStore ¶
type LocalStore struct { Path string // path which index and data file is stored Index *os.File // current active index file Data *os.File // current active data file Log *slog.Logger DataOffset int64 // file offset which next sample was written to sync.Mutex // contains filtered or unexported fields }
LocalStore represent local store, which consist of index and data files. All files was stored into Path (default: /var/log/etop). file format: index_{shard}, data_{shard} shard is unix time of 00:00 utc every day It should work either readonly mode or writeonly mode.
func NewLocalStore ¶
func NewLocalStore(opts ...Option) (*LocalStore, error)
func (*LocalStore) CleanOldFiles ¶ added in v0.0.5
func (local *LocalStore) CleanOldFiles(opt WriteOption)
func (*LocalStore) Close ¶
func (local *LocalStore) Close() error
func (*LocalStore) CollectSample ¶ added in v0.0.2
func (local *LocalStore) CollectSample(s *Sample) error
func (*LocalStore) DeleteSingleFile ¶ added in v0.0.7
func (local *LocalStore) DeleteSingleFile(shard int64)
func (*LocalStore) FileStatInfo ¶ added in v0.0.2
func (local *LocalStore) FileStatInfo() (result string, err error)
func (*LocalStore) JumpSampleByTimeStamp ¶ added in v0.0.2
func (local *LocalStore) JumpSampleByTimeStamp(timestamp int64, sample *Sample) error
JumpSampleByTimeStamp get sample by specific timestamp (unix time) if no, search the nearest one. ignore 1st sample for better handle corner case.
func (*LocalStore) NextSample ¶ added in v0.0.2
func (local *LocalStore) NextSample(step int, sample *Sample) error
func (*LocalStore) Snapshot ¶ added in v0.0.2
func (local *LocalStore) Snapshot(begin int64, end int64) (string, error)
func (*LocalStore) WriteLoop ¶
func (local *LocalStore) WriteLoop(opt WriteOption) error
func (*LocalStore) WriteSample ¶
func (local *LocalStore) WriteSample(s *Sample) (bool, error)
type MemoryEvents ¶ added in v0.1.5
type MemoryStat ¶ added in v0.1.5
type MemoryStat struct { Anon uint64 File uint64 KernelStack uint64 Slab uint64 Sock uint64 Shmem uint64 Zswap uint64 Zswapped uint64 FileMapped uint64 FileDirty uint64 FileWriteback uint64 AnonThp uint64 InactiveAnon uint64 ActiveAnon uint64 InactiveFile uint64 ActiveFile uint64 Unevictable uint64 SlabReclaimable uint64 SlabUnreclaimable uint64 Pgfault uint64 Pgmajfault uint64 WorkingsetRefault uint64 WorkingsetActivate uint64 WorkingsetNodereclaim uint64 Pgrefill uint64 Pgscan uint64 Pgsteal uint64 Pgactivate uint64 Pgdeactivate uint64 Pglazyfree uint64 Pglazyfreed uint64 ZswpIn uint64 ZswpOut uint64 ThpFaultAlloc uint64 ThpCollapseAlloc uint64 }
type Option ¶ added in v0.0.2
type Option func(*LocalStore) error
func WithExitProcess ¶ added in v0.0.9
func WithPathAndLogger ¶ added in v0.0.9
func WithWriteOnly ¶ added in v0.0.2
type PidMap ¶ added in v0.0.3
type PidMap map[int]ProcSample
type ProcSample ¶
type Sample ¶
type Sample struct { TimeStamp int64 // unix time when sample was generated SystemSample // system information ProcSamples PidMap // process information CgroupSample *CgroupSample }
Sample represent all system info and process info.
type Store ¶
type Store interface { // if step is positive , advance the corresponding number of steps // otherwise back, then get sample NextSample(step int, sample *Sample) error // Get sample which collect at timestamp JumpSampleByTimeStamp(timestamp int64, sample *Sample) error }
Store is interface which operate file/network which include sample data.
type SystemSample ¶
Click to show internal directories.
Click to hide internal directories.