insight

package
v1.16.3 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

process

Index

Constants

This section is empty.

Variables

View Source
var (
	// GitBranch is initialized during make
	GitBranch = "Not Provided"

	// GitCommit is initialized during make
	GitCommit = "Not Provided"
)

Version information

Functions

func GetProcPath

func GetProcPath(paths ...string) string

GetProcPath is getting the proc path

func GetSysUptime

func GetSysUptime() (float64, float64, error)

GetSysUptime gets the system uptime

Types

type BlockDev

type BlockDev struct {
	Name       string     `json:"name,omitempty"`
	Partition  bool       `json:"partition,omitempty"`
	Mount      MountInfo  `json:"mount,omitempty"`
	UUID       string     `json:"uuid,omitempty"`
	Sectors    uint64     `json:"sectors,omitempty"`
	Size       uint64     `json:"size,omitempty"`
	SubDev     []BlockDev `json:"subdev,omitempty"`
	Holder     []string   `json:"holder_of,omitempty"`
	Slave      []string   `json:"slave_of,omitempty"`
	Rotational string     `json:"rotational,omitempty"`
}

BlockDev is similar to blkDev_cxt in lsblk (from util-linux) contains metadata of a block device

func GetPartitionStats

func GetPartitionStats() []BlockDev

GetPartitionStats is getting disk partition statistics

type ChronyStat

type ChronyStat struct {
	ReferenceID    string  `json:"referenceid,omitempty"`
	Stratum        int     `json:"stratum,omitempty"`
	RefTime        string  `json:"ref_time,omitempty"`
	SystemTime     string  `json:"system_time,omitempty"`
	LastOffset     float64 `json:"last_offset,omitempty"` // millisecond
	RMSOffset      float64 `json:"rms_offset,omitempty"`  // millisecond
	Frequency      float64 `json:"frequency,omitempty"`   // millisecond
	ResidualFreq   string  `json:"residual_freq,omitempty"`
	Skew           string  `json:"skew,omitempty"`
	RootDelay      float64 `json:"root_delay,omitempty"`      // millisecond
	RootDispersion float64 `json:"root_dispersion,omitempty"` // millisecond
	UpdateInterval float64 `json:"update_interval,omitempty"` // millisecond
	LeapStatus     string  `json:"leap_status,omitempty"`
}

ChronyStat is holding the chrony statistics

type Info

type Info struct {
	Meta       Meta            `json:"meta"`
	SysInfo    sysinfo.SysInfo `json:"sysinfo,omitempty"`
	NTP        TimeStat        `json:"ntp,omitempty"`
	ChronyStat ChronyStat      `json:"chrony,omitempty"`
	Partitions []BlockDev      `json:"partitions,omitempty"`
	ProcStats  []ProcessStat   `json:"proc_stats,omitempty"`
	EpollExcl  bool            `json:"epoll_exclusive,omitempty"`
	SysConfig  *SysCfg         `json:"system_configs,omitempty"`
	DMesg      []*kmsg.Msg     `json:"dmesg,omitempty"`
	Sockets    []Socket        `json:"sockets,omitempty"`
}

Info are information gathered from the system

func (*Info) GetInfo

func (info *Info) GetInfo(opts Options)

GetInfo collects Info

type Meta

type Meta struct {
	Timestamp time.Time `json:"timestamp"`
	UPTime    float64   `json:"uptime,omitempty"`
	IdleTime  float64   `json:"idle_time,omitempty"`
	SiVer     string    `json:"sysinfo_ver"`
	GitBranch string    `json:"git_branch"`
	GitCommit string    `json:"git_commit"`
	GoVersion string    `json:"go_version"`
}

Meta are information about insight itself

type MountInfo

type MountInfo struct {
	MountPoint string `json:"mount_point,omitempty"`
	FSType     string `json:"filesystem,omitempty"`
	// Mount options used to mount this device
	Options string `json:"mount_options,omitempty"`
}

MountInfo is the metadata of a mounted device

type Options

type Options struct {
	Pid    string
	Proc   bool
	Syscfg bool // collect kernel configs or not
	Dmesg  bool // collect kernel logs or not
}

Options sets options for info collection

type ProcessStat

type ProcessStat struct {
	Name      string                  `json:"name"`
	Pid       int32                   `json:"pid"`
	Exec      string                  `json:"exec"`
	Cmdline   string                  `json:"cmd"`
	Status    string                  `json:"status"`
	StartTime float64                 `json:"start_time"`
	CPUTimes  *cpu.TimesStat          `json:"cpu_times"`
	Memory    *process.MemoryInfoStat `json:"memory"`
	Rlimit    []RlimitUsage           `json:"resource_limit"`
}

ProcessStat contains basic info of a running process

func GetProcessStats

func GetProcessStats(pidList []string) []ProcessStat

GetProcessStats gets processlist statistics

type RlimitUsage

type RlimitUsage struct {
	Resource string `json:"resource"`
	Soft     int64  `json:"soft"`
	Hard     int64  `json:"hard"`
	Used     uint64 `json:"used"`
}

RlimitUsage is the resource limit usage of a process

type SecLimitField

type SecLimitField struct {
	Domain string `json:"domain"`
	Type   string `json:"type"`
	Item   string `json:"item"`
	Value  int    `json:"value"`
}

SecLimitField is the config field in security limit file

type Socket

type Socket struct {
	Family     uint8  `json:"family"`
	State      uint8  `json:"state"`
	SourceAddr string `json:"source_addr"`
	SourcePort uint16 `json:"source_port"`
	DestAddr   string `json:"dest_addr"`
	DestPort   uint16 `json:"dest_port"`
}

Socket is a network socket

func GetIPV4Sockets

func GetIPV4Sockets(states ...uint8) ([]Socket, error)

GetIPV4Sockets is getting sockets from states

type SysCfg

type SysCfg struct {
	SecLimit []SecLimitField   `json:"sec_limit,omitempty"`
	SysCtl   map[string]string `json:"sysctl,omitempty"`
}

SysCfg are extra system configs we collected

type TimeStat

type TimeStat struct {
	Ver       string  `json:"version,omitempty"`
	Sync      string  `json:"sync,omitempty"`
	Stratum   int     `json:"stratum,omitempty"`
	Precision int     `json:"precision,omitempty"`
	Rootdelay float64 `json:"rootdelay,omitempty"`
	Rootdisp  float64 `json:"rootdisp,omitempty"`
	Refid     string  `json:"refid,omitempty"`
	Peer      int     `json:"peer,omitempty"`
	TC        int     `json:"tc,omitempty"`
	Mintc     int     `json:"mintc,omitempty"`
	Offset    float64 `json:"offset,omitempty"`
	Frequency float64 `json:"frequency,omitempty"`
	Jitter    float64 `json:"jitter,omitempty"`
	ClkJitter float64 `json:"clk_jitter,omitempty"`
	ClkWander float64 `json:"clk_wander,omitempty"`
	Status    string  `json:"status,omitempty"`
}

TimeStat is holding the NTP time statistics

Jump to

Keyboard shortcuts

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