monitor

package
v0.0.0-...-ef77147 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CPUAll is for reading all cpu jiffies
	CPUAll = 0
	// CPUSum is just read one sum of cpu jiffies
	CPUSum = 1
)

Variables

This section is empty.

Functions

func AddHandle

func AddHandle(h HandleFunc)

AddHandle add callback handles

func ConnectToInfluxdb

func ConnectToInfluxdb(addr string, db string) error

ConnectToInfluxdb create database client

func HandleInfluxdb

func HandleInfluxdb(s *Sample)

HandleInfluxdb is for saving data to influxdb

func SetLogger

func SetLogger(log *log.Logger)

SetLogger set logger

func SetMonitorProcess

func SetMonitorProcess(names []string)

SetMonitorProcess accepts names of processes

func Start

func Start(period int) error

Start is action for monitor begin

func Stop

func Stop()

Stop is action to stop the monitor

Types

type CPUInfo

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

CPUInfo for cpu calc

type Cache

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

Cache for cpu and processes

type HandleFunc

type HandleFunc func(s *Sample)

HandleFunc is callback for result

type LinuxInfo

type LinuxInfo struct{}

LinuxInfo is for linux platform

func (*LinuxInfo) GetCPUInfo

func (li *LinuxInfo) GetCPUInfo(target int, cpus []CPUInfo) (int, error)

GetCPUInfo returns cpu jiffies

func (*LinuxInfo) GetCPUNum

func (li *LinuxInfo) GetCPUNum() int

GetCPUNum returns the number of CPU Cores

func (*LinuxInfo) GetMemInfo

func (li *LinuxInfo) GetMemInfo(m *MemInfo) error

GetMemInfo returns memory usaged infos

func (*LinuxInfo) GetProcessInfo

func (li *LinuxInfo) GetProcessInfo(pid int, p *ProcessInfo) error

GetProcessInfo returns process stats

func (*LinuxInfo) GetProcessPids

func (li *LinuxInfo) GetProcessPids(names []string) (map[string][]int, error)

GetProcessPids return pids of process names

func (*LinuxInfo) Init

func (li *LinuxInfo) Init()

Init calls before everything

type MemInfo

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

MemInfo for os memory

type ProcessInfo

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

ProcessInfo for Process calc

type Sample

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

Sample unit for objects

func NewSample

func NewSample(sys SysInfo, cpu, mem bool, processes []string) Sample

NewSample returns sample object

func (*Sample) Action

func (s *Sample) Action() (time.Duration, error)

Action does a sample action

func (*Sample) GetCPUIdle

func (s *Sample) GetCPUIdle(id int) float32

GetCPUIdle return the load average

func (*Sample) GetCPUIoWait

func (s *Sample) GetCPUIoWait(id int) float32

GetCPUIoWait return the load average

func (*Sample) GetCPULoad

func (s *Sample) GetCPULoad(id int) float32

GetCPULoad return the load average

func (*Sample) GetCPUNice

func (s *Sample) GetCPUNice(id int) float32

GetCPUNice return the load average

func (*Sample) GetCPUSys

func (s *Sample) GetCPUSys(id int) float32

GetCPUSys return the load average

func (*Sample) GetCPUTimeStamp

func (s *Sample) GetCPUTimeStamp() time.Time

GetCPUTimeStamp return sample time stamp

func (*Sample) GetCPUUser

func (s *Sample) GetCPUUser(id int) float32

GetCPUUser return the load average

func (*Sample) GetMemBufferSize

func (s *Sample) GetMemBufferSize() uint64

GetMemBufferSize return the mem free size

func (*Sample) GetMemCacheSize

func (s *Sample) GetMemCacheSize() uint64

GetMemCacheSize return the mem free size

func (*Sample) GetMemFreeSize

func (s *Sample) GetMemFreeSize() uint64

GetMemFreeSize return the mem free size

func (*Sample) GetMemTimeStamp

func (s *Sample) GetMemTimeStamp() time.Time

GetMemTimeStamp return sample time stamp

func (*Sample) GetMemTotalSize

func (s *Sample) GetMemTotalSize() uint64

GetMemTotalSize return the mem totalsize

func (*Sample) GetMemUsaged

func (s *Sample) GetMemUsaged() float32

GetMemUsaged return the mem usaged

func (*Sample) GetProcessCPULoad

func (s *Sample) GetProcessCPULoad(pid int) float32

GetProcessCPULoad return the process cpu load

func (*Sample) GetProcessMemSize

func (s *Sample) GetProcessMemSize(pid int) uint64

GetProcessMemSize return the process mem size

func (*Sample) GetProcessMemUsaged

func (s *Sample) GetProcessMemUsaged(pid int) float32

GetProcessMemUsaged return the process mem usaged

func (*Sample) GetProcessName

func (s *Sample) GetProcessName(pid int) string

GetProcessName return the process name

func (*Sample) GetProcessPids

func (s *Sample) GetProcessPids() []int

GetProcessPids returns pids of processes

func (*Sample) GetProcessTimeStamp

func (s *Sample) GetProcessTimeStamp(pid int) time.Time

GetProcessTimeStamp return the process name

func (*Sample) GetProcessVMemSize

func (s *Sample) GetProcessVMemSize(pid int) uint64

GetProcessVMemSize return the process virtual mem size

type SysInfo

type SysInfo interface {
	Init()
	GetCPUNum() int
	GetProcessPids(names []string) (map[string][]int, error)
	GetMemInfo(*MemInfo) error
	GetCPUInfo(int, []CPUInfo) (int, error)
	GetProcessInfo(int, *ProcessInfo) error
}

SysInfo is an interface for OS

Jump to

Keyboard shortcuts

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