Documentation
¶
Index ¶
- type CpuFs
- type CpuPercentPid
- type Diskstats
- type MapHeader
- type Meminfo
- type NanoMeasureMethod
- type Partitions
- type PidInfos
- type ProcNetDev
- func (s *ProcNetDev) Close()
- func (s *ProcNetDev) GetAvailableInterfaces() []string
- func (s *ProcNetDev) GetWanAdress(adress string, useStunSrv ...bool) (string, error)
- func (s *ProcNetDev) SetSuffix(suffix string) error
- func (s *ProcNetDev) SetUnit(unit string) error
- func (s *ProcNetDev) Update() error
- type ProcPidStat
- type Smaps
- type StatusFile
- type SysTherm
- type TimeSpent
- func (s *TimeSpent) Close()
- func (s *TimeSpent) MesurementMethodGet() int
- func (s *TimeSpent) MesurementMethodSet(method NanoMeasureMethod)
- func (s *TimeSpent) NanoCalculate() float64
- func (s *TimeSpent) NanoGet()
- func (s *TimeSpent) SpentGet() float64
- func (s *TimeSpent) TicksCalculate() float64
- func (s *TimeSpent) TicksGet()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CpuFs ¶
type CpuFs struct {
CpuCount int
CurrFreq []int64
CpuList []cpuFs
// contains filtered or unexported fields
}
Structure to hold values retrieved from: '/sys/devices/system/cpu/cpufreq/policy*' directories
func (*CpuFs) CurrFreqUpdate ¶
func (*CpuFs) ListUpdate ¶
type CpuPercentPid ¶
type CpuPercentPid struct {
CpuPercent float32
MemoryRss int64
// contains filtered or unexported fields
}
func CpuPercentPidNew ¶
func CpuPercentPidNew(pid int) (*CpuPercentPid, error)
CpuPercentPidNew: Create and initialise 'C' structure.
type Diskstats ¶
type Diskstats struct {
Details []gdiskstats
// contains filtered or unexported fields
}
func DiskstatsNew ¶
DiskstatsNew: Create and initialise 'C' structure.
type MapHeader ¶
type Meminfo ¶
type Meminfo struct {
MemTotal uint32
MemFree uint32
MemAvailable uint32
Buffers uint32
Cached uint32
SwapCached uint32
Active uint32
Inactive uint32
ActiveAnon uint32
InactiveAnon uint32
ActiveFile uint32
InactiveFile uint32
Unevictable uint32
Mlocked uint32
SwapTotal uint32
SwapFree uint32
Dirty uint32
Writeback uint32
AnonPages uint32
Mapped uint32
Shmem uint32
Kreclaimable uint32
Slab uint32
Sreclaimable uint32
Sunreclaim uint32
KernelStack uint32
PageTables uint32
NfsUnstable uint32
Bounce uint32
WritebackTmp uint32
CommitLimit uint32
CommittedAs uint32
VmallocTotal uint32
VmallocUsed uint32
VmallocChunk uint32
Percpu uint32
HardwareCorrupted uint32
AnonHugePages uint32
ShmemHugePages uint32
ShmemPmdMapped uint32
FileHugePages uint32
FilePmdMapped uint32
HugePagesTotal uint32
HugePagesFree uint32
HugePagesRsvd uint32
HugePagesSurp uint32
Hugepagesize uint32
Hugetlb uint32
DirectMap4k uint32
DirectMap2M uint32
DirectMap1G uint32
// contains filtered or unexported fields
}
func MeminfoNew ¶
MeminfoNew: Create and initialise 'C' structure.
type NanoMeasureMethod ¶
const ( // (0) Wall time (also known as clock time or wall-clock time) is simply // the total time elapsed during the measurement. It’s the time you // can measure with a stopwatch, assuming that you are able to start // and stop it exactly at the execution points you want. NANO_CLOCK_WALL NanoMeasureMethod = C.CLOCK_REALTIME // (2) CPU Time, on the other hand, refers to the time the CPU was busy // processing the program’s instructions. The time spent waiting for // other things to complete (like I/O operations) is not included in // the CPU time. NANO_CLOCK_CPUTIME NanoMeasureMethod = C.CLOCK_PROCESS_CPUTIME_ID )
type Partitions ¶
type Partitions struct {
Details []partition
// contains filtered or unexported fields
}
func PartitionsNew ¶
func PartitionsNew() (*Partitions, error)
PartitionsNew: Create and initialise 'C' structure.
type PidInfos ¶
type PidInfos struct {
Details []storeFile
// contains filtered or unexported fields
}
PidInfos: structure to store PID information for all processes.
func PidInfosNew ¶
PidInfosNew: Create and initialise 'C' structure. No need to 'free' (close) anything, everything is already handled.
func (*PidInfos) GetPidFromFilename ¶
Get pid using the filename base. Returns "-1" if not found.
func (*PidInfos) GetPidFromName ¶
Get pid using the name. Note: Instead of the previous, this function is based on a 'comm' field which contains only 16 bytes, which means that if the name is greater than 16 characters, it will be truncated. Returns "-1" if not found.
type ProcNetDev ¶
type ProcNetDev struct {
// Suffix, default: 'iB' !!! max char length = 15
Suffix string
// Unit, default: '/s' !!! max char length = 15
Unit string
Interfaces []iface
// contains filtered or unexported fields
}
func ProcNetDevNew ¶
func ProcNetDevNew(pid ...uint32) (*ProcNetDev, error)
ProcNetDevNew: Create and initialize the "C" structure. If a "pid" is given, the statistics relate to the process. Otherwise, it's the overall flow
func (*ProcNetDev) GetAvailableInterfaces ¶
func (s *ProcNetDev) GetAvailableInterfaces() []string
Retrieve available network interfaces
func (*ProcNetDev) GetWanAdress ¶
func (s *ProcNetDev) GetWanAdress(adress string, useStunSrv ...bool) (string, error)
GetWanAdress: Retrieve wan adress using http get method or using a 'stun' server whether 'useStunSrv' was toggled. http get: "ifconfig.co" stun srv: "stun1.l.google.com:19302"
type ProcPidStat ¶
type ProcPidStat struct {
Pid uint
Comm string
State string
Ppid int
Pgrp int
Session int
TtyNr int
Tpgid int
Flags uint
Minflt uint32
Cminflt uint32
Majflt uint32
Cmajflt uint32
Utime uint32
Stime uint32
Cutime int32
Cstime int32
Priority int32
Nice int32
NumThreads int32
Itrealvalue int32
Starttime uint64
Vsize uint32
Rss int32
Rsslim uint32
Startcode uint32
Endcode uint32
Startstack uint32
Kstkesp uint32
Kstkeip uint32
Signal uint32
Blocked uint32
Sigignore uint32
Sigcatch uint32
Wchan uint32
Nswap uint32
Cnswap uint32
ExitSignal int
Processor int
RtPriority uint
Policy uint
DelayacctBlkioTicks uint64
GuestTime uint32
CguestTime int32
StartData uint32
EndData uint32
StartBrk uint32
ArgStart uint32
ArgEnd uint32
EnvStart uint32
EnvEnd uint32
ExitCode int
// contains filtered or unexported fields
}
func ProcPidStatNew ¶
func ProcPidStatNew(pid int) (*ProcPidStat, error)
ProcPidStatNew: Create and initialise 'C' structure.
type Smaps ¶
type Smaps struct {
Rollup *smapsRollup
Smaps []smap
// Values are given as kB inside parsed files,
// enable this flag to convert to Bytes
ConvertToBytes bool
// contains filtered or unexported fields
}
- Structures functions, this section handle files like 'smaps', 'smaps_rollup',
- 'maps' is not used here because information are contained inside 'smaps'
- via 'Header' variable of 'Rollup' or 'Smaps' structures
Information 'man procfs' search '/smaps' then press 'n' until '/proc/[pid]/smaps'
func SmapsNew ¶
StatNew: Create a new structure that will contains required information about 'proc/[pid]/stat' files 'maxReadEntries' define the length of the buffer to read 'smaps' file, default is set to 2k.
func (*Smaps) UpdateRollup ¶
Update: 'C' structure content with actual values.
func (*Smaps) UpdateSmaps ¶
Update: 'C' structure content with actual values.
type StatusFile ¶
type StatusFile struct {
Name string
Umask string
State string
Tgid uint
Ngid uint
Pid uint
Ppid uint
TracerPid uint
Uid *resfId
Gid *resfId
FdSize uint64
Groups []uint
NsTgid []uint
NsPid []uint
NsPgid []uint
NsSid []uint
Vm *statusFileVmem
Threads int
SigQ string
SigPnd string
ShdPnd string
SigBlk string
SigIgn string
SigCgt string
CapInh string
CapPrm string
CapEff string
CapBnd string
CapAmb string
NoNewPrivs int
Seccomp int
StoreBypass string
CpusAllowed string
CpusAllowedList string
MemsAllowed string
MemsAllowedList string
VoluntaryCtxtSwitches uint64
NonvoluntaryCtxtSwitches uint64
// contains filtered or unexported fields
}
func StatusFileNew ¶
func StatusFileNew(pid int) (*StatusFile, error)
StatusFileNew: create and initialize the "C" structure. No need to 'free' (close) anything, everything is already handled.
type SysTherm ¶
type SysTherm struct {
Interfaces []sysTherm
// contains filtered or unexported fields
}
Structure to hold Thermal information retrieved from: '/sys/class/hwmon/hwmon*' directories. Note: "n/a", "-0°C" or "-1" value means not available data.
func SysThermNew ¶
type TimeSpent ¶
type TimeSpent struct {
Spent float64
NANO_CLOCK_WALL NanoMeasureMethod
NANO_CLOCK_CPUTIME NanoMeasureMethod
SC_CLK_TCK int64
// contains filtered or unexported fields
}
func TimeSpentNew ¶
func TimeSpentNew(method ...NanoMeasureMethod) (*TimeSpent, error)
TimeSpentNew: Create and initialise 'C' structure. if argument is set to -1, the default value is 'NANO_CLOCK_WALL'
func (*TimeSpent) MesurementMethodGet ¶
GetMesurementMethod:
func (*TimeSpent) MesurementMethodSet ¶
func (s *TimeSpent) MesurementMethodSet(method NanoMeasureMethod)
SetMesurementMethod:
func (*TimeSpent) NanoCalculate ¶
NanoCalculate: calculate the nanoseconds between 2 measurement periods
func (*TimeSpent) NanoGet ¶
func (s *TimeSpent) NanoGet()
NanoGet: get current nano count measurement depend on defined 'method' argument 'NANO_CLOCK_WALL' or 'NANO_CLOCK_CPUTIME' Value is internally stored.
func (*TimeSpent) TicksCalculate ¶
TicksCalculate: calculate tick between 2 tick periods