linux

package
v0.0.0-...-c95fcf8 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: MIT Imports: 12 Imported by: 152

Documentation

Index

Constants

View Source
const (
	DefaultBufferSize = 1024
)

Variables

This section is empty.

Functions

func ListPID

func ListPID(path string, max uint64) ([]uint64, error)

func NetIPv4Decoder

func NetIPv4Decoder(s string) (string, error)

NetIPv4Decoder decodes an IPv4 address with port from a given hex string NOTE: This function match NetIPDecoder type

func NetIPv6Decoder

func NetIPv6Decoder(s string) (string, error)

NetIPv6Decoder decodes an IPv6 address with port from a given hex string NOTE: This function match NetIPDecoder type

func ReadMaxPID

func ReadMaxPID(path string) (uint64, error)

func ReadProcessCmdline

func ReadProcessCmdline(path string) (string, error)

Types

type CPUInfo

type CPUInfo struct {
	Processors []Processor `json:"processors"`
}

func ReadCPUInfo

func ReadCPUInfo(path string) (*CPUInfo, error)

func (*CPUInfo) NumCPU

func (self *CPUInfo) NumCPU() int

func (*CPUInfo) NumCore

func (self *CPUInfo) NumCore() int

func (*CPUInfo) NumPhysicalCPU

func (self *CPUInfo) NumPhysicalCPU() int

type CPUStat

type CPUStat struct {
	Id        string `json:"id"`
	User      uint64 `json:"user"`
	Nice      uint64 `json:"nice"`
	System    uint64 `json:"system"`
	Idle      uint64 `json:"idle"`
	IOWait    uint64 `json:"iowait"`
	IRQ       uint64 `json:"irq"`
	SoftIRQ   uint64 `json:"softirq"`
	Steal     uint64 `json:"steal"`
	Guest     uint64 `json:"guest"`
	GuestNice uint64 `json:"guest_nice"`
}

type Disk

type Disk struct {
	All        uint64 `json:"all"`
	Used       uint64 `json:"used"`
	Free       uint64 `json:"free"`
	FreeInodes uint64 `json:"freeInodes"`
}

func ReadDisk

func ReadDisk(path string) (*Disk, error)

type DiskStat

type DiskStat struct {
	Major        int    `json:"major"`         // major device number
	Minor        int    `json:"minor"`         // minor device number
	Name         string `json:"name"`          // device name
	ReadIOs      uint64 `json:"read_ios"`      // number of read I/Os processed
	ReadMerges   uint64 `json:"read_merges"`   // number of read I/Os merged with in-queue I/O
	ReadSectors  uint64 `json:"read_sectors"`  // number of 512 byte sectors read
	ReadTicks    uint64 `json:"read_ticks"`    // total wait time for read requests in milliseconds
	WriteIOs     uint64 `json:"write_ios"`     // number of write I/Os processed
	WriteMerges  uint64 `json:"write_merges"`  // number of write I/Os merged with in-queue I/O
	WriteSectors uint64 `json:"write_sectors"` // number of 512 byte sectors written
	WriteTicks   uint64 `json:"write_ticks"`   // total wait time for write requests in milliseconds
	InFlight     uint64 `json:"in_flight"`     // number of I/Os currently in flight
	IOTicks      uint64 `json:"io_ticks"`      // total time this block device has been active in milliseconds
	TimeInQueue  uint64 `json:"time_in_queue"` // total wait time for all requests in milliseconds
}

DiskStat is disk statistics to help measure disk activity.

Note:

  • On a very busy or long-lived system values may wrap.
  • No kernel locks are held while modifying these counters. This implies that minor inaccuracies may occur.

More more info see: https://www.kernel.org/doc/Documentation/iostats.txt and https://www.kernel.org/doc/Documentation/block/stat.txt

func ReadDiskStats

func ReadDiskStats(path string) ([]DiskStat, error)

ReadDiskStats reads and parses the file.

Note: * Assumes a well formed file and will panic if it isn't.

func (*DiskStat) GetIOTicks

func (ds *DiskStat) GetIOTicks() time.Duration

GetIOTicks returns the duration the disk has been active.

func (*DiskStat) GetReadBytes

func (ds *DiskStat) GetReadBytes() int64

GetReadBytes returns the number of bytes read.

func (*DiskStat) GetReadTicks

func (ds *DiskStat) GetReadTicks() time.Duration

GetReadTicks returns the duration waited for read requests.

func (*DiskStat) GetTimeInQueue

func (ds *DiskStat) GetTimeInQueue() time.Duration

GetTimeInQueue returns the duration waited for all requests.

func (*DiskStat) GetWriteBytes

func (ds *DiskStat) GetWriteBytes() int64

GetWriteBytes returns the number of bytes written.

func (*DiskStat) GetWriteTicks

func (ds *DiskStat) GetWriteTicks() time.Duration

GetWriteTicks returns the duration waited for write requests.

type Interrupt

type Interrupt struct {
	Name        string
	Counts      []uint64
	Description string
}

type Interrupts

type Interrupts struct {
	Interrupts []Interrupt
}

func ReadInterrupts

func ReadInterrupts(path string) (*Interrupts, error)

type LoadAvg

type LoadAvg struct {
	Last1Min       float64 `json:"last1min"`
	Last5Min       float64 `json:"last5min"`
	Last15Min      float64 `json:"last15min"`
	ProcessRunning uint64  `json:"process_running"`
	ProcessTotal   uint64  `json:"process_total"`
	LastPID        uint64  `json:"last_pid"`
}

func ReadLoadAvg

func ReadLoadAvg(path string) (*LoadAvg, error)

type MemInfo

type MemInfo struct {
	MemTotal          uint64 `json:"mem_total"`
	MemFree           uint64 `json:"mem_free"`
	MemAvailable      uint64 `json:"mem_available"`
	Buffers           uint64 `json:"buffers"`
	Cached            uint64 `json:"cached"`
	SwapCached        uint64 `json:"swap_cached"`
	Active            uint64 `json:"active"`
	Inactive          uint64 `json:"inactive"`
	ActiveAnon        uint64 `json:"active_anon" field:"Active(anon)"`
	InactiveAnon      uint64 `json:"inactive_anon" field:"Inactive(anon)"`
	ActiveFile        uint64 `json:"active_file" field:"Active(file)"`
	InactiveFile      uint64 `json:"inactive_file" field:"Inactive(file)"`
	Unevictable       uint64 `json:"unevictable"`
	Mlocked           uint64 `json:"mlocked"`
	SwapTotal         uint64 `json:"swap_total"`
	SwapFree          uint64 `json:"swap_free"`
	Dirty             uint64 `json:"dirty"`
	Writeback         uint64 `json:"write_back"`
	AnonPages         uint64 `json:"anon_pages"`
	Mapped            uint64 `json:"mapped"`
	Shmem             uint64 `json:"shmem"`
	Slab              uint64 `json:"slab"`
	SReclaimable      uint64 `json:"s_reclaimable"`
	SUnreclaim        uint64 `json:"s_unclaim"`
	KernelStack       uint64 `json:"kernel_stack"`
	PageTables        uint64 `json:"page_tables"`
	NFS_Unstable      uint64 `json:"nfs_unstable"`
	Bounce            uint64 `json:"bounce"`
	WritebackTmp      uint64 `json:"writeback_tmp"`
	CommitLimit       uint64 `json:"commit_limit"`
	Committed_AS      uint64 `json:"committed_as"`
	VmallocTotal      uint64 `json:"vmalloc_total"`
	VmallocUsed       uint64 `json:"vmalloc_used"`
	VmallocChunk      uint64 `json:"vmalloc_chunk"`
	HardwareCorrupted uint64 `json:"hardware_corrupted"`
	AnonHugePages     uint64 `json:"anon_huge_pages"`
	HugePages_Total   uint64 `json:"huge_pages_total"`
	HugePages_Free    uint64 `json:"huge_pages_free"`
	HugePages_Rsvd    uint64 `json:"huge_pages_rsvd"`
	HugePages_Surp    uint64 `json:"huge_pages_surp"`
	Hugepagesize      uint64 `json:"hugepagesize"`
	DirectMap4k       uint64 `json:"direct_map_4k"`
	DirectMap2M       uint64 `json:"direct_map_2M"`
	DirectMap1G       uint64 `json:"direct_map_1G"`
}

func ReadMemInfo

func ReadMemInfo(path string) (*MemInfo, error)

type Mount

type Mount struct {
	Device     string `json:"device"`
	MountPoint string `json:"mountpoint"`
	FSType     string `json:"fstype"`
	Options    string `json:"options"`
}

type Mounts

type Mounts struct {
	Mounts []Mount `json:"mounts"`
}

func ReadMounts

func ReadMounts(path string) (*Mounts, error)

type NetIPDecoder

type NetIPDecoder func(string) (string, error) // Either NetIPv4Decoder or NetIPv6Decoder

type NetSocket

type NetSocket struct {
	LocalAddress         string `json:"local_address"`
	RemoteAddress        string `json:"remote_address"`
	Status               uint8  `json:"st"`
	TxQueue              uint64 `json:"tx_queue"`
	RxQueue              uint64 `json:"rx_queue"`
	Uid                  uint32 `json:"uid"`
	Inode                uint64 `json:"inode"`
	SocketReferenceCount uint64 `json:"ref"`
}

type NetStat

type NetStat struct {
	// TcpExt
	SyncookiesSent            uint64 `json:"syncookie_sent"`
	SyncookiesRecv            uint64 `json:"syncookies_recv"`
	SyncookiesFailed          uint64 `json:"syncookies_failed"`
	EmbryonicRsts             uint64 `json:"embryonic_rsts"`
	PruneCalled               uint64 `json:"prune_called"`
	RcvPruned                 uint64 `json:"rcv_pruned"`
	OfoPruned                 uint64 `json:"ofo_pruned"`
	OutOfWindowIcmps          uint64 `json:"out_of_window_icmps"`
	LockDroppedIcmps          uint64 `json:"lock_dropped_icmps"`
	ArpFilter                 uint64 `json:"arp_filter"`
	TW                        uint64 `json:"tw"`
	TWRecycled                uint64 `json:"tw_recycled"`
	TWKilled                  uint64 `json:"tw_killed"`
	PAWSPassive               uint64 `json:"paws_passive"`
	PAWSActive                uint64 `json:"paws_active"`
	PAWSEstab                 uint64 `json:"paws_estab"`
	DelayedACKs               uint64 `json:"delayed_acks"`
	DelayedACKLocked          uint64 `json:"delayed_ack_locked"`
	DelayedACKLost            uint64 `json:"delayed_ack_lost"`
	ListenOverflows           uint64 `json:"listen_overflows"`
	ListenDrops               uint64 `json:"listen_drops"`
	TCPPrequeued              uint64 `json:"tcp_prequeued"`
	TCPDirectCopyFromBacklog  uint64 `json:"tcp_direct_copy_from_backlog"`
	TCPDirectCopyFromPrequeue uint64 `json:"tcp_direct_copy_from_prequeue"`
	TCPPrequeueDropped        uint64 `json:"tcp_prequeue_dropped"`
	TCPHPHits                 uint64 `json:"tcp_hp_hits"`
	TCPHPHitsToUser           uint64 `json:"tcp_hp_hits_to_user"`
	TCPPureAcks               uint64 `json:"tcp_pure_acks"`
	TCPHPAcks                 uint64 `json:"tcp_hp_acks"`
	TCPRenoRecovery           uint64 `json:"tcp_reno_recovery"`
	TCPSackRecovery           uint64 `json:"tcp_sack_recovery"`
	TCPSACKReneging           uint64 `json:"tcp_sack_reneging"`
	TCPFACKReorder            uint64 `json:"tcp_fack_reorder"`
	TCPSACKReorder            uint64 `json:"tcp_sack_reorder"`
	TCPRenoReorder            uint64 `json:"tcp_reno_reorder"`
	TCPTSReorder              uint64 `json:"tcp_ts_reorder"`
	TCPFullUndo               uint64 `json:"tcp_full_undo"`
	TCPPartialUndo            uint64 `json:"tcp_partial_undo"`
	TCPDSACKUndo              uint64 `json:"tcp_dsack_undo"`
	TCPLossUndo               uint64 `json:"tcp_loss_undo"`
	TCPLoss                   uint64 `json:"tcp_loss"`
	TCPLostRetransmit         uint64 `json:"tcp_lost_retransmit"`
	TCPRenoFailures           uint64 `json:"tcp_reno_failures"`
	TCPSackFailures           uint64 `json:"tcp_sack_failures"`
	TCPLossFailures           uint64 `json:"tcp_loss_failures"`
	TCPFastRetrans            uint64 `json:"tcp_fast_retrans"`
	TCPForwardRetrans         uint64 `json:"tcp_forward_retrans"`
	TCPSlowStartRetrans       uint64 `json:"tcp_slow_start_retrans"`
	TCPTimeouts               uint64 `json:"tcp_timeouts"`
	TCPLossProbes             uint64 `json:"tcp_loss_probes"`
	TCPLossProbeRecovery      uint64 `json:"tcp_loss_probe_recovery"`
	TCPRenoRecoveryFail       uint64 `json:"tcp_reno_recovery_fail"`
	TCPSackRecoveryFail       uint64 `json:"tcp_sack_recovery_fail"`
	TCPSchedulerFailed        uint64 `json:"tcp_scheduler_failed"`
	TCPRcvCollapsed           uint64 `json:"tcp_rcv_collapsed"`
	TCPDSACKOldSent           uint64 `json:"tcp_dsack_old_sent"`
	TCPDSACKOfoSent           uint64 `json:"tcp_dsack_ofo_sent"`
	TCPDSACKRecv              uint64 `json:"tcp_dsack_recv"`
	TCPDSACKOfoRecv           uint64 `json:"tcp_dsack_ofo_recv"`
	TCPAbortOnSyn             uint64 `json:"tcp_abort_on_syn"`
	TCPAbortOnData            uint64 `json:"tcp_abort_on_data"`
	TCPAbortOnClose           uint64 `json:"tcp_abort_on_close"`
	TCPAbortOnMemory          uint64 `json:"tcp_abort_on_memory"`
	TCPAbortOnTimeout         uint64 `json:"tcp_abort_on_timeout"`
	TCPAbortOnLinger          uint64 `json:"tcp_abort_on_linger"`
	TCPAbortFailed            uint64 `json:"tcp_abort_failed"`
	TCPMemoryPressures        uint64 `json:"tcp_memory_pressures"`
	TCPSACKDiscard            uint64 `json:"tcp_sack_discard"`
	TCPDSACKIgnoredOld        uint64 `json:"tcp_dsack_ignored_old"`
	TCPDSACKIgnoredNoUndo     uint64 `json:"tcp_dsack_ignored_no_undo"`
	TCPSpuriousRTOs           uint64 `json:"tcp_spurious_rtos"`
	TCPMD5NotFound            uint64 `json:"tcp_md5_not_found"`
	TCPMD5Unexpected          uint64 `json:"tcp_md5_unexpected"`
	TCPSackShifted            uint64 `json:"tcp_sack_shifted"`
	TCPSackMerged             uint64 `json:"tcp_sack_merged"`
	TCPSackShiftFallback      uint64 `json:"tcp_sack_shift_fallback"`
	TCPBacklogDrop            uint64 `json:"tcp_backlog_drop"`
	TCPMinTTLDrop             uint64 `json:"tcp_min_ttl_drop"`
	TCPDeferAcceptDrop        uint64 `json:"tcp_defer_accept_drop"`
	IPReversePathFilter       uint64 `json:"ip_reverse_path_filter"`
	TCPTimeWaitOverflow       uint64 `json:"tcp_time_wait_overflow"`
	TCPReqQFullDoCookies      uint64 `json:"tcp_req_q_full_do_cookies"`
	TCPReqQFullDrop           uint64 `json:"tcp_req_q_full_drop"`
	TCPRetransFail            uint64 `json:"tcp_retrans_fail"`
	TCPRcvCoalesce            uint64 `json:"tcp_rcv_coalesce"`
	TCPOFOQueue               uint64 `json:"tcp_ofo_queue"`
	TCPOFODrop                uint64 `json:"tcp_ofo_drop"`
	TCPOFOMerge               uint64 `json:"tcp_ofo_merge"`
	TCPChallengeACK           uint64 `json:"tcp_challenge_ack"`
	TCPSYNChallenge           uint64 `json:"tcp_syn_challenge"`
	TCPFastOpenActive         uint64 `json:"tcp_fast_open_active"`
	TCPFastOpenActiveFail     uint64 `json:"tcp_fast_open_active_fail"`
	TCPFastOpenPassive        uint64 `json:"tcp_fast_open_passive"`
	TCPFastOpenPassiveFail    uint64 `json:"tcp_fast_open_passive_fail"`
	TCPFastOpenListenOverflow uint64 `json:"tcp_fast_open_listen_overflow"`
	TCPFastOpenCookieReqd     uint64 `json:"tcp_fast_open_cookie_reqd"`
	TCPSpuriousRtxHostQueues  uint64 `json:"tcp_spurious_rtx_host_queues"`
	BusyPollRxPackets         uint64 `json:"busy_poll_rx_packets"`
	TCPAutoCorking            uint64 `json:"tcp_auto_corking"`
	TCPFromZeroWindowAdv      uint64 `json:"tcp_from_zero_window_adv"`
	TCPToZeroWindowAdv        uint64 `json:"tcp_to_zero_window_adv"`
	TCPWantZeroWindowAdv      uint64 `json:"tcp_want_zero_window_adv"`
	TCPSynRetrans             uint64 `json:"tcp_syn_retrans"`
	TCPOrigDataSent           uint64 `json:"tcp_orig_data_sent"`
	// IpExt
	InNoRoutes      uint64 `json:"in_no_routes"`
	InTruncatedPkts uint64 `json:"in_truncated_pkts"`
	InMcastPkts     uint64 `json:"in_mcast_pkts"`
	OutMcastPkts    uint64 `json:"out_mcast_pkts"`
	InBcastPkts     uint64 `json:"in_bcast_pkts"`
	OutBcastPkts    uint64 `json:"out_bcast_pkts"`
	InOctets        uint64 `json:"in_octets"`
	OutOctets       uint64 `json:"out_octets"`
	InMcastOctets   uint64 `json:"in_mcast_octets"`
	OutMcastOctets  uint64 `json:"out_mcast_octets"`
	InBcastOctets   uint64 `json:"in_bcast_octets"`
	OutBcastOctets  uint64 `json:"out_bcast_octets"`
	InCsumErrors    uint64 `json:"in_csum_errors"`
	InNoECTPkts     uint64 `json:"in_no_ect_pkts"`
	InECT1Pkts      uint64 `json:"in_ect1_pkts"`
	InECT0Pkts      uint64 `json:"in_ect0_pkts"`
	InCEPkts        uint64 `json:"in_ce_pkts"`
}

func ReadNetStat

func ReadNetStat(path string) (*NetStat, error)

type NetTCPSocket

type NetTCPSocket struct {
	NetSocket
	RetransmitTimeout       uint64 `json:"retransmit_timeout"`
	PredictedTick           uint64 `json:"predicted_tick"`
	AckQuick                uint8  `json:"ack_quick"`
	AckPingpong             bool   `json:"ack_pingpong"`
	SendingCongestionWindow uint64 `json:"sending_congestion_window"`
	SlowStartSizeThreshold  int64  `json:"slow_start_size_threshold"`
}

type NetTCPSockets

type NetTCPSockets struct {
	Sockets []NetTCPSocket `json:"sockets"`
}

func ReadNetTCPSockets

func ReadNetTCPSockets(path string, ip NetIPDecoder) (*NetTCPSockets, error)

type NetUDPSocket

type NetUDPSocket struct {
	NetSocket
	Drops uint64 `json:"drops"`
}

type NetUDPSockets

type NetUDPSockets struct {
	Sockets []NetUDPSocket `json:"sockets"`
}

func ReadNetUDPSockets

func ReadNetUDPSockets(path string, ip NetIPDecoder) (*NetUDPSockets, error)

type NetUnixDomainSocket

type NetUnixDomainSocket struct {
	Protocol uint64 `json:"protocol"`
	RefCount uint64 `json:"ref_count"`
	Flags    uint64 `json:"flags"`
	Type     uint64 `json:"type"`
	State    uint64 `json:"state"`
	Inode    uint64 `json:"inode"`
	Path     string `json:"path"`
}

type NetUnixDomainSockets

type NetUnixDomainSockets struct {
	Sockets []NetUnixDomainSocket `json:"sockets"`
}

func ReadNetUnixDomainSockets

func ReadNetUnixDomainSockets(fpath string) (*NetUnixDomainSockets, error)

ReadNetUnixDomainSockets parser to /proc/net/unix

type NetworkStat

type NetworkStat struct {
	Iface        string `json:"iface"`
	RxBytes      uint64 `json:"rxbytes"`
	RxPackets    uint64 `json:"rxpackets"`
	RxErrs       uint64 `json:"rxerrs"`
	RxDrop       uint64 `json:"rxdrop"`
	RxFifo       uint64 `json:"rxfifo"`
	RxFrame      uint64 `json:"rxframe"`
	RxCompressed uint64 `json:"rxcompressed"`
	RxMulticast  uint64 `json:"rxmulticast"`
	TxBytes      uint64 `json:"txbytes"`
	TxPackets    uint64 `json:"txpackets"`
	TxErrs       uint64 `json:"txerrs"`
	TxDrop       uint64 `json:"txdrop"`
	TxFifo       uint64 `json:"txfifo"`
	TxColls      uint64 `json:"txcolls"`
	TxCarrier    uint64 `json:"txcarrier"`
	TxCompressed uint64 `json:"txcompressed"`
}

func ReadNetworkStat

func ReadNetworkStat(path string) ([]NetworkStat, error)

type Process

type Process struct {
	Status  ProcessStatus `json:"status"`
	Statm   ProcessStatm  `json:"statm"`
	Stat    ProcessStat   `json:"stat"`
	IO      ProcessIO     `json:"io"`
	Cmdline string        `json:"cmdline"`
}

func ReadProcess

func ReadProcess(pid uint64, path string) (*Process, error)

type ProcessIO

type ProcessIO struct {
	RChar               uint64 `json:"rchar" field:"rchar"`                                 // chars read
	WChar               uint64 `json:"wchar" field:"wchar"`                                 // chars written
	Syscr               uint64 `json:"syscr" field:"syscr"`                                 // read syscalls
	Syscw               uint64 `json:"syscw" field:"syscw"`                                 // write syscalls
	ReadBytes           uint64 `json:"read_bytes" field:"read_bytes"`                       // bytes read
	WriteBytes          uint64 `json:"write_bytes" field:"write_bytes"`                     // bytes written
	CancelledWriteBytes uint64 `json:"cancelled_write_bytes" field:"cancelled_write_bytes"` // bytes truncated
}

I/O statistics for the process.

func ReadProcessIO

func ReadProcessIO(path string) (*ProcessIO, error)

type ProcessSchedStat

type ProcessSchedStat struct {
	RunTime      uint64 `json:"run_time"`      // time spent on the cpu
	RunqueueTime uint64 `json:"runqueue_time"` // time spent waiting on a runqueue
	RunPeriods   uint64 `json:"run_periods"`   // # of timeslices run on this cpu
}

https://www.kernel.org/doc/Documentation/scheduler/sched-stats.txt

func ReadProcessSchedStat

func ReadProcessSchedStat(path string) (*ProcessSchedStat, error)

type ProcessStat

type ProcessStat struct {
	Pid                 uint64 `json:"pid"`
	Comm                string `json:"comm"`
	State               string `json:"state"`
	Ppid                int64  `json:"ppid"`
	Pgrp                int64  `json:"pgrp"`
	Session             int64  `json:"session"`
	TtyNr               int64  `json:"tty_nr"`
	Tpgid               int64  `json:"tpgid"`
	Flags               uint64 `json:"flags"`
	Minflt              uint64 `json:"minflt"`
	Cminflt             uint64 `json:"cminflt"`
	Majflt              uint64 `json:"majflt"`
	Cmajflt             uint64 `json:"cmajflt"`
	Utime               uint64 `json:"utime"`
	Stime               uint64 `json:"stime"`
	Cutime              int64  `json:"cutime"`
	Cstime              int64  `json:"cstime"`
	Priority            int64  `json:"priority"`
	Nice                int64  `json:"nice"`
	NumThreads          int64  `json:"num_threads"`
	Itrealvalue         int64  `json:"itrealvalue"`
	Starttime           uint64 `json:"starttime"`
	Vsize               uint64 `json:"vsize"`
	Rss                 int64  `json:"rss"`
	Rsslim              uint64 `json:"rsslim"`
	Startcode           uint64 `json:"startcode"`
	Endcode             uint64 `json:"endcode"`
	Startstack          uint64 `json:"startstack"`
	Kstkesp             uint64 `json:"kstkesp"`
	Kstkeip             uint64 `json:"kstkeip"`
	Signal              uint64 `json:"signal"`
	Blocked             uint64 `json:"blocked"`
	Sigignore           uint64 `json:"sigignore"`
	Sigcatch            uint64 `json:"sigcatch"`
	Wchan               uint64 `json:"wchan"`
	Nswap               uint64 `json:"nswap"`
	Cnswap              uint64 `json:"cnswap"`
	ExitSignal          int64  `json:"exit_signal"`
	Processor           int64  `json:"processor"`
	RtPriority          uint64 `json:"rt_priority"`
	Policy              uint64 `json:"policy"`
	DelayacctBlkioTicks uint64 `json:"delayacct_blkio_ticks"`
	GuestTime           uint64 `json:"guest_time"`
	CguestTime          int64  `json:"cguest_time"`
	StartData           uint64 `json:"start_data"`
	EndData             uint64 `json:"end_data"`
	StartBrk            uint64 `json:"start_brk"`
	ArgStart            uint64 `json:"arg_start"`
	ArgEnd              uint64 `json:"arg_end"`
	EnvStart            uint64 `json:"env_start"`
	EnvEnd              uint64 `json:"env_end"`
	ExitCode            int64  `json:"exit_code"`
}

Status information about the process.

func ReadProcessStat

func ReadProcessStat(path string) (*ProcessStat, error)

type ProcessStatm

type ProcessStatm struct {
	Size     uint64 `json:"size"`     // total program size
	Resident uint64 `json:"resident"` // resident set size
	Share    uint64 `json:"share"`    // shared pages
	Text     uint64 `json:"text"`     // text (code)
	Lib      uint64 `json:"lib"`      // library (unused in Linux 2.6)
	Data     uint64 `json:"data"`     // data + stack
	Dirty    uint64 `json:"dirty"`    // dirty pages (unused in Linux 2.6)
}

Provides information about memory usage, measured in pages.

func ReadProcessStatm

func ReadProcessStatm(path string) (*ProcessStatm, error)

type ProcessStatus

type ProcessStatus struct {
	Name                     string
	State                    string
	Tgid                     uint64
	Pid                      uint64
	PPid                     int64
	TracerPid                uint64
	RealUid                  uint64
	EffectiveUid             uint64
	SavedSetUid              uint64
	FilesystemUid            uint64
	RealGid                  uint64
	EffectiveGid             uint64
	SavedSetGid              uint64
	FilesystemGid            uint64
	FDSize                   uint64
	Groups                   []int64
	VmPeak                   uint64
	VmSize                   uint64
	VmLck                    uint64
	VmHWM                    uint64
	VmRSS                    uint64
	VmData                   uint64
	VmStk                    uint64
	VmExe                    uint64
	VmLib                    uint64
	VmPTE                    uint64
	VmSwap                   uint64
	Threads                  uint64
	SigQLength               uint64
	SigQLimit                uint64
	SigPnd                   uint64
	ShdPnd                   uint64
	SigBlk                   uint64
	SigIgn                   uint64
	SigCgt                   uint64
	CapInh                   uint64
	CapPrm                   uint64
	CapEff                   uint64
	CapBnd                   uint64
	Seccomp                  uint8
	CpusAllowed              []uint32
	MemsAllowed              []uint32
	VoluntaryCtxtSwitches    uint64
	NonvoluntaryCtxtSwitches uint64
}

Provides much of the information from ProcessStatm and ProcessStat

func ReadProcessStatus

func ReadProcessStatus(path string) (*ProcessStatus, error)

type Processor

type Processor struct {
	Id         int64    `json:"id"`
	VendorId   string   `json:"vendor_id"`
	Model      int64    `json:"model"`
	ModelName  string   `json:"model_name"`
	Flags      []string `json:"flags"`
	Cores      int64    `json:"cores"`
	MHz        float64  `json:"mhz"`
	CacheSize  int64    `json:"cache_size"` // KB
	PhysicalId int64    `json:"physical_id"`
	CoreId     int64    `json:"core_id"`
}

type Snmp

type Snmp struct {
	// Ip
	IpForwarding      uint64 `json:"ip_forwarding"`
	IpDefaultTTL      uint64 `json:"ip_default_ttl"`
	IpInReceives      uint64 `json:"ip_in_receives"`
	IpInHdrErrors     uint64 `json:"ip_in_hdr_errors"`
	IpInAddrErrors    uint64 `json:"ip_in_addr_errors"`
	IpForwDatagrams   uint64 `json:"ip_forw_datagrams"`
	IpInUnknownProtos uint64 `json:"ip_in_unknown_protos"`
	IpInDiscards      uint64 `json:"ip_in_discards"`
	IpInDelivers      uint64 `json:"ip_in_delivers"`
	IpOutRequests     uint64 `json:"ip_out_requests"`
	IpOutDiscards     uint64 `json:"ip_out_discards"`
	IpOutNoRoutes     uint64 `json:"ip_out_no_routes"`
	IpReasmTimeout    uint64 `json:"ip_reasm_timeout"`
	IpReasmReqds      uint64 `json:"ip_reasm_reqds"`
	IpReasmOKs        uint64 `json:"ip_reasm_oks"`
	IpReasmFails      uint64 `json:"ip_reasm_fails"`
	IpFragOKs         uint64 `json:"ip_frag_oks"`
	IpFragFails       uint64 `json:"ip_frag_fails"`
	IpFragCreates     uint64 `json:"ip_frag_creates"`
	// Icmp
	IcmpInMsgs           uint64 `json:"icmp_in_msgs"`
	IcmpInErrors         uint64 `json:"icmp_in_errors"`
	IcmpInCsumErrors     uint64 `json:"icmp_in_csum_errors"`
	IcmpInDestUnreachs   uint64 `json:"icmp_in_dest_unreachs"`
	IcmpInTimeExcds      uint64 `json:"icmp_in_time_excds"`
	IcmpInParmProbs      uint64 `json:"icmp_in_parm_probs"`
	IcmpInSrcQuenchs     uint64 `json:"icmp_in_src_quenchs"`
	IcmpInRedirects      uint64 `json:"icmp_in_redirects"`
	IcmpInEchos          uint64 `json:"icmp_in_echos"`
	IcmpInEchoReps       uint64 `json:"icmp_in_echo_reps"`
	IcmpInTimestamps     uint64 `json:"icmp_in_timestamps"`
	IcmpInTimestampReps  uint64 `json:"icmp_in_timestamp_reps"`
	IcmpInAddrMasks      uint64 `json:"icmp_in_addr_masks"`
	IcmpInAddrMaskReps   uint64 `json:"icmp_in_addr_mask_reps"`
	IcmpOutMsgs          uint64 `json:"icmp_out_msgs"`
	IcmpOutErrors        uint64 `json:"icmp_out_errors"`
	IcmpOutDestUnreachs  uint64 `json:"icmp_out_dest_unreachs"`
	IcmpOutTimeExcds     uint64 `json:"icmp_out_time_excds"`
	IcmpOutParmProbs     uint64 `json:"icmp_out_parm_probs"`
	IcmpOutSrcQuenchs    uint64 `json:"icmp_out_src_quenchs"`
	IcmpOutRedirects     uint64 `json:"icmp_out_redirects"`
	IcmpOutEchos         uint64 `json:"icmp_out_echos"`
	IcmpOutEchoReps      uint64 `json:"icmp_out_echo_reps"`
	IcmpOutTimestamps    uint64 `json:"icmp_out_timestamps"`
	IcmpOutTimestampReps uint64 `json:"icmp_out_timestamp_reps"`
	IcmpOutAddrMasks     uint64 `json:"icmp_out_addr_masks"`
	IcmpOutAddrMaskReps  uint64 `json:"icmp_out_addr_mask_reps"`
	// IcmpMsg
	IcmpMsgInType0   uint64 `json:"icmpmsg_in_type0"`
	IcmpMsgInType3   uint64 `json:"icmpmsg_in_type3"`
	IcmpMsgInType5   uint64 `json:"icmpmsg_in_type5"`
	IcmpMsgInType8   uint64 `json:"icmpmsg_in_type8"`
	IcmpMsgInType11  uint64 `json:"icmpmsg_in_type11"`
	IcmpMsgInType13  uint64 `json:"icmpmsg_in_type13"`
	IcmpMsgOutType0  uint64 `json:"icmpmsg_out_type0"`
	IcmpMsgOutType3  uint64 `json:"icmpmsg_out_type3"`
	IcmpMsgOutType8  uint64 `json:"icmpmsg_out_type8"`
	IcmpMsgOutType14 uint64 `json:"icmpmsg_out_type14"`
	IcmpMsgOutType69 uint64 `json:"icmpmsg_out_type69"`
	// TCP
	TcpRtoAlgorithm uint64 `json:"tcp_rto_algorithm"`
	TcpRtoMin       uint64 `json:"tcp_rto_min"`
	TcpRtoMax       uint64 `json:"tcp_rto_max"`
	TcpMaxConn      uint64 `json:"tcp_max_conn"`
	TcpActiveOpens  uint64 `json:"tcp_active_opens"`
	TcpPassiveOpens uint64 `json:"tcp_passive_opens"`
	TcpAttemptFails uint64 `json:"tcp_attempt_fails"`
	TcpEstabResets  uint64 `json:"tcp_estab_resets"`
	TcpCurrEstab    uint64 `json:"tcp_curr_estab"`
	TcpInSegs       uint64 `json:"tcp_in_segs"`
	TcpOutSegs      uint64 `json:"tcp_out_segs"`
	TcpRetransSegs  uint64 `json:"tcp_retrans_segs"`
	TcpInErrs       uint64 `json:"tcp_in_errs"`
	TcpOutRsts      uint64 `json:"tcp_out_rsts"`
	TcpInCsumErrors uint64 `json:"tcp_in_csum_errors"`
	// UDP
	UdpInDatagrams  uint64 `json:"udp_in_datagrams"`
	UdpNoPorts      uint64 `json:"udp_no_ports"`
	UdpInErrors     uint64 `json:"udp_in_errors"`
	UdpOutDatagrams uint64 `json:"udp_out_datagrams"`
	UdpRcvbufErrors uint64 `json:"udp_rcvbuf_errors"`
	UdpSndbufErrors uint64 `json:"udp_sndbuf_errors"`
	UdpInCsumErrors uint64 `json:"udp_in_csum_errors"`
	// UDPLite
	UdpLiteInDatagrams  uint64 `json:"udp_lite_in_datagrams"`
	UdpLiteNoPorts      uint64 `json:"udp_lite_no_ports"`
	UdpLiteInErrors     uint64 `json:"udp_lite_in_errors"`
	UdpLiteOutDatagrams uint64 `json:"udp_lite_out_datagrams"`
	UdpLiteRcvbufErrors uint64 `json:"udp_lite_rcvbuf_errors"`
	UdpLiteSndbufErrors uint64 `json:"udp_lite_sndbuf_errors"`
	UdpLiteInCsumErrors uint64 `json:"udp_lite_in_csum_errors"`
}

func ReadSnmp

func ReadSnmp(path string) (*Snmp, error)

type SockStat

type SockStat struct {
	// sockets:
	SocketsUsed uint64 `json:"sockets_used" field:"sockets.used"`

	// TCP:
	TCPInUse     uint64 `json:"tcp_in_use" field:"TCP.inuse"`
	TCPOrphan    uint64 `json:"tcp_orphan" field:"TCP.orphan"`
	TCPTimeWait  uint64 `json:"tcp_time_wait" field:"TCP.tw"`
	TCPAllocated uint64 `json:"tcp_allocated" field:"TCP.alloc"`
	TCPMemory    uint64 `json:"tcp_memory" field:"TCP.mem"`

	//TCP6:
	TCP6InUse uint64 `json:"tcp6_in_use" field:"TCP6.inuse"`

	// UDP:
	UDPInUse  uint64 `json:"udp_in_use" field:"UDP.inuse"`
	UDPMemory uint64 `json:"udp_memory" field:"UDP.mem"`

	// UDP6:
	UDP6InUse uint64 `json:"udp6_in_use" field:"UDP6.inuse"`

	// UDPLITE:
	UDPLITEInUse uint64 `json:"udplite_in_use" field:"UDPLITE.inuse"`

	// UDPLITE6:
	UDPLITE6InUse uint64 `json:"udplite6_in_use" field:"UDPLITE6.inuse"`

	// RAW:
	RAWInUse uint64 `json:"raw_in_use" field:"RAW.inuse"`

	// RAW6:
	RAW6InUse uint64 `json:"raw6_in_use" field:"RAW6.inuse"`

	// FRAG:
	FRAGInUse  uint64 `json:"frag_in_use" field:"FRAG.inuse"`
	FRAGMemory uint64 `json:"frag_memory" field:"FRAG.memory"`

	// FRAG6:
	FRAG6InUse  uint64 `json:"frag6_in_use" field:"FRAG6.inuse"`
	FRAG6Memory uint64 `json:"frag6_memory" field:"FRAG6.memory"`
}

func ReadSockStat

func ReadSockStat(path string) (*SockStat, error)

type Stat

type Stat struct {
	CPUStatAll      CPUStat   `json:"cpu_all"`
	CPUStats        []CPUStat `json:"cpus"`
	Interrupts      uint64    `json:"intr"`
	ContextSwitches uint64    `json:"ctxt"`
	BootTime        time.Time `json:"btime"`
	Processes       uint64    `json:"processes"`
	ProcsRunning    uint64    `json:"procs_running"`
	ProcsBlocked    uint64    `json:"procs_blocked"`
}

func ReadStat

func ReadStat(path string) (*Stat, error)

type Uptime

type Uptime struct {
	Total float64 `json:"total"`
	Idle  float64 `json:"idle"`
}

func ReadUptime

func ReadUptime(path string) (*Uptime, error)

func (*Uptime) CalculateIdle

func (self *Uptime) CalculateIdle() float64

func (*Uptime) GetIdleDuration

func (self *Uptime) GetIdleDuration() time.Duration

func (*Uptime) GetTotalDuration

func (self *Uptime) GetTotalDuration() time.Duration

type VMStat

type VMStat struct {
	NrFreePages                   uint64 `json:"nr_free_pages"`
	NrAllocBatch                  uint64 `json:"nr_alloc_batch"`
	NrInactiveAnon                uint64 `json:"nr_inactive_anon"`
	NrActiveAnon                  uint64 `json:"nr_active_anon"`
	NrInactiveFile                uint64 `json:"nr_inactive_file"`
	NrActiveFile                  uint64 `json:"nr_active_file"`
	NrUnevictable                 uint64 `json:"nr_unevictable"`
	NrMlock                       uint64 `json:"nr_mlock"`
	NrAnonPages                   uint64 `json:"nr_anon_pages"`
	NrMapped                      uint64 `json:"nr_mapped"`
	NrFilePages                   uint64 `json:"nr_file_pages"`
	NrDirty                       uint64 `json:"nr_dirty"`
	NrWriteback                   uint64 `json:"nr_writeback"`
	NrSlabReclaimable             uint64 `json:"nr_slab_reclaimable"`
	NrSlabUnreclaimable           uint64 `json:"nr_slab_unreclaimable"`
	NrPageTablePages              uint64 `json:"nr_page_table_pages"`
	NrKernelStack                 uint64 `json:"nr_kernel_stack"`
	NrUnstable                    uint64 `json:"nr_unstable"`
	NrBounce                      uint64 `json:"nr_bounce"`
	NrVmscanWrite                 uint64 `json:"nr_vmscan_write"`
	NrVmscanImmediateReclaim      uint64 `json:"nr_vmscan_immediate_reclaim"`
	NrWritebackTemp               uint64 `json:"nr_writeback_temp"`
	NrIsolatedAnon                uint64 `json:"nr_isolated_anon"`
	NrIsolatedFile                uint64 `json:"nr_isolated_file"`
	NrShmem                       uint64 `json:"nr_shmem"`
	NrDirtied                     uint64 `json:"nr_dirtied"`
	NrWritten                     uint64 `json:"nr_written"`
	NumaHit                       uint64 `json:"numa_hit"`
	NumaMiss                      uint64 `json:"numa_miss"`
	NumaForeign                   uint64 `json:"numa_foreign"`
	NumaInterleave                uint64 `json:"numa_interleave"`
	NumaLocal                     uint64 `json:"numa_local"`
	NumaOther                     uint64 `json:"numa_other"`
	WorkingsetRefault             uint64 `json:"workingset_refault"`
	WorkingsetActivate            uint64 `json:"workingset_activate"`
	WorkingsetNodereclaim         uint64 `json:"workingset_nodereclaim"`
	NrAnonTransparentHugepages    uint64 `json:"nr_anon_transparent_hugepages"`
	NrFreeCma                     uint64 `json:"nr_free_cma"`
	NrDirtyThreshold              uint64 `json:"nr_dirty_threshold"`
	NrDirtyBackgroundThreshold    uint64 `json:"nr_dirty_background_threshold"`
	PagePagein                    uint64 `json:"pgpgin"`
	PagePageout                   uint64 `json:"pgpgout"`
	PageSwapin                    uint64 `json:"pswpin"`
	PageSwapout                   uint64 `json:"pswpout"`
	PageAllocDMA                  uint64 `json:"pgalloc_dma"`
	PageAllocDMA32                uint64 `json:"pgalloc_dma32"`
	PageAllocNormal               uint64 `json:"pgalloc_normal"`
	PageAllocMovable              uint64 `json:"pgalloc_movable"`
	PageFree                      uint64 `json:"pgfree"`
	PageActivate                  uint64 `json:"pgactivate"`
	PageDeactivate                uint64 `json:"pgdeactivate"`
	PageFault                     uint64 `json:"pgfault"`
	PageMajorFault                uint64 `json:"pgmajfault"`
	PageRefillDMA                 uint64 `json:"pgrefill_dma"`
	PageRefillDMA32               uint64 `json:"pgrefill_dma32"`
	PageRefillMormal              uint64 `json:"pgrefill_normal"`
	PageRefillMovable             uint64 `json:"pgrefill_movable"`
	PageStealKswapdDMA            uint64 `json:"pgsteal_kswapd_dma"`
	PageStealKswapdDMA32          uint64 `json:"pgsteal_kswapd_dma32"`
	PageStealKswapdNormal         uint64 `json:"pgsteal_kswapd_normal"`
	PageStealKswapdMovable        uint64 `json:"pgsteal_kswapd_movable"`
	PageStealDirectDMA            uint64 `json:"pgsteal_direct_dma"`
	PageStealDirectDMA32          uint64 `json:"pgsteal_direct_dma32"`
	PageStealDirectNormal         uint64 `json:"pgsteal_direct_normal"`
	PageStealDirectMovable        uint64 `json:"pgsteal_direct_movable"`
	PageScanKswapdDMA             uint64 `json:"pgscan_kswapd_dma"`
	PageScanKswapdDMA32           uint64 `json:"pgscan_kswapd_dma32"`
	PageScanKswapdNormal          uint64 `json:"pgscan_kswapd_normal"`
	PageScanKswapdMovable         uint64 `json:"pgscan_kswapd_movable"`
	PageScanDirectDMA             uint64 `json:"pgscan_direct_dma"`
	PageScanDirectDMA32           uint64 `json:"pgscan_direct_dma32"`
	PageScanDirectNormal          uint64 `json:"pgscan_direct_normal"`
	PageScanDirectMovable         uint64 `json:"pgscan_direct_movable"`
	PageScanDirectThrottle        uint64 `json:"pgscan_direct_throttle"`
	ZoneReclaimFailed             uint64 `json:"zone_reclaim_failed"`
	PageInodeSteal                uint64 `json:"pginodesteal"`
	SlabsScanned                  uint64 `json:"slabs_scanned"`
	KswapdInodesteal              uint64 `json:"kswapd_inodesteal"`
	KswapdLowWatermarkHitQuickly  uint64 `json:"kswapd_low_wmark_hit_quickly"`
	KswapdHighWatermarkHitQuickly uint64 `json:"kswapd_high_wmark_hit_quickly"`
	PageoutRun                    uint64 `json:"pageoutrun"`
	AllocStall                    uint64 `json:"allocstall"`
	PageRotated                   uint64 `json:"pgrotated"`
	DropPagecache                 uint64 `json:"drop_pagecache"`
	DropSlab                      uint64 `json:"drop_slab"`
	NumaPteUpdates                uint64 `json:"numa_pte_updates"`
	NumaHugePteUpdates            uint64 `json:"numa_huge_pte_updates"`
	NumaHintFaults                uint64 `json:"numa_hint_faults"`
	NumaHintFaults_local          uint64 `json:"numa_hint_faults_local"`
	NumaPagesMigrated             uint64 `json:"numa_pages_migrated"`
	PageMigrateSuccess            uint64 `json:"pgmigrate_success"`
	PageMigrateFail               uint64 `json:"pgmigrate_fail"`
	CompactMigrateScanned         uint64 `json:"compact_migrate_scanned"`
	CompactFreeScanned            uint64 `json:"compact_free_scanned"`
	CompactIsolated               uint64 `json:"compact_isolated"`
	CompactStall                  uint64 `json:"compact_stall"`
	CompactFail                   uint64 `json:"compact_fail"`
	CompactSuccess                uint64 `json:"compact_success"`
	HtlbBuddyAllocSuccess         uint64 `json:"htlb_buddy_alloc_success"`
	HtlbBuddyAllocFail            uint64 `json:"htlb_buddy_alloc_fail"`
	UnevictablePagesCulled        uint64 `json:"unevictable_pgs_culled"`
	UnevictablePagesScanned       uint64 `json:"unevictable_pgs_scanned"`
	UnevictablePagesRescued       uint64 `json:"unevictable_pgs_rescued"`
	UnevictablePagesMlocked       uint64 `json:"unevictable_pgs_mlocked"`
	UnevictablePagesMunlocked     uint64 `json:"unevictable_pgs_munlocked"`
	UnevictablePagesCleared       uint64 `json:"unevictable_pgs_cleared"`
	UnevictablePagesStranded      uint64 `json:"unevictable_pgs_stranded"`
	THPFaultAlloc                 uint64 `json:"thp_fault_alloc"`
	THPFaultFallback              uint64 `json:"thp_fault_fallback"`
	THPCollapseAlloc              uint64 `json:"thp_collapse_alloc"`
	THPCollapseAllocFailed        uint64 `json:"thp_collapse_alloc_failed"`
	THPSplit                      uint64 `json:"thp_split"`
	THPZeroPageAlloc              uint64 `json:"thp_zero_page_alloc"`
	THPZeroPageAllocFailed        uint64 `json:"thp_zero_page_alloc_failed"`
}

func ReadVMStat

func ReadVMStat(path string) (*VMStat, error)

Jump to

Keyboard shortcuts

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