Documentation ¶
Index ¶
- Constants
- Variables
- func AddrLengthInit()
- func BwToStr(bw float64) string
- func CleanGlobalProcFds()
- func GenericInetRead(protocal, af int) (sis map[uint32]SocketInfo, err error)
- func GenericReadSockstat() (summary map[string]map[string]int, err error)
- func GenericUnixRead() (sis map[uint32]SocketInfo, err error)
- func GetProcInfo(nameSet map[string]bool, fdFlag bool) map[string]map[int]*ProcInfo
- func GetSocketCount(fields []string) (int, error)
- func IPv4HexToString(ipHex string) (ip string, err error)
- func IPv6HexToString(ipHex string) (ip string, err error)
- func RecvInetDiagMsgAll(skfd int)
- func RecvInetDiagMsgMulti(skfd int) (err error)
- func RecvUnixDiagMsgAll(skfd int)
- func RecvUnixDiagMsgMulti(skfd int) (err error)
- func ScanProcFS(fdFlag bool)
- func SendInetDiagMsg(af uint8, protocal uint8, exts uint8, states uint32) (skfd int, err error)
- func SendUnixDiagMsg(states uint32, show uint32) (skfd int, err error)
- type CPUJiffies
- type Dirent
- type DirentReader
- type DiskStat
- type DiskStats
- type Fd
- type FileInfo
- type IP
- type InetDiagMeminfo
- type InetDiagMessage
- type InetDiagReq
- type InetDiagRequest
- type InetDiagSockID
- type KernelVersion
- type MemoryInfo
- type MountInfo
- type MountInfos
- type NetDev
- type NetDevs
- type ProcInfo
- type ProcStat
- type SocketInfo
- type SystemStat
- type TCPInfo
- type TCPVegasInfo
- type UnixDiagMessage
- type UnixDiagRQlen
- type UnixDiagReq
- type UnixDiagRequest
- type UnixDiagVFS
- type Uptime
Constants ¶
View Source
const ( DT_UNKNOWN = 0 DT_FIFO = 1 DT_CHR = 2 DT_DIR = 4 DT_BLK = 6 DT_REG = 8 DT_LNK = 10 DT_SOCK = 12 DT_WHT = 14 )
View Source
const ( SsUNKNOWN uint8 = iota SsESTAB SsSYNSENT SsSYNRECV SsFINWAIT1 SsFINWAIT2 SsTIMEWAIT SsUNCONN SsCLOSEWAIT SsLASTACK SsLISTEN SsCLOSING SsMAX )
View Source
const ( SOCK_STREAM = 1 SOCK_DGRAM = 2 SOCK_RAW = 3 SOCK_RDM = 4 SOCK_SEQPACKET = 5 SOCK_DCCP = 6 SOCK_PACKET = 10 )
View Source
const ( SK_MEMINFO_RMEM_ALLOC = iota SK_MEMINFO_RCVBUF SK_MEMINFO_WMEM_ALLOC SK_MEMINFO_SNDBUF SK_MEMINFO_FWD_ALLOC SK_MEMINFO_WMEM_QUEUED SK_MEMINFO_OPTMEM SK_MEMINFO_BACKLOG SK_MEMINFO_DROPS SK_MEMINFO_VARS )
View Source
const ( IPv4String = "IPv4" IPv6String = "IPv6" )
View Source
const ( ProtocalUnknown = 1 << iota ProtocalDCCP ProtocalNetlink ProtocalPacket ProtocalRAW ProtocalSCTP ProtocalTCP ProtocalUDP ProtocalUnix ProtocalMax )
View Source
const ( SOCK_DIAG_BY_FAMILY = 20 SizeOfUnixDiagRequest = 40 SizeOfUnixDiagMsg = 16 SizeOfInetDiagRequest = 72 SizeOfInetDiagMsg = 72 )
View Source
const ( INET_DIAG_NONE = iota INET_DIAG_MEMINFO INET_DIAG_INFO INET_DIAG_VEGASINFO INET_DIAG_CONG INET_DIAG_TOS INET_DIAG_TCLASS INET_DIAG_SKMEMINFO INET_DIAG_SHUTDOWN INET_DIAG_DCTCPINFO INET_DIAG_PROTOCOL /* response attribute only */ INET_DIAG_SKV6ONLY INET_DIAG_LOCALS INET_DIAG_PEERS INET_DIAG_PAD INET_DIAG_MARK INET_DIAG_BBRINFO INET_DIAG_MAX )
View Source
const ( TCPI_OPT_TIMESTAMPS = 1 TCPI_OPT_SACK = 2 TCPI_OPT_WSCALE = 4 TCPI_OPT_ECN = 8 /* ECN was negociated at TCP session init */ TCPI_OPT_ECN_SEEN = 16 /* we received at least one packet with ECT */ TCPI_OPT_SYN_DATA = 32 /* SYN-ACK acked data in SYN sent or rcvd */ )
View Source
const ( UDIAG_SHOW_NAME = 0x00000001 /* show name (not path) */ UDIAG_SHOW_VFS = 0x00000002 /* show VFS inode info */ UDIAG_SHOW_PEER = 0x00000004 /* show peer socket info */ UDIAG_SHOW_ICONS = 0x00000008 /* show pending connections */ UDIAG_SHOW_RQLEN = 0x00000010 /* show skb receive queue len */ UDIAG_SHOW_MEMINFO = 0x00000020 /* show memory info of a socket */ )
View Source
const ( UNIX_DIAG_NAME = iota UNIX_DIAG_VFS UNIX_DIAG_PEER UNIX_DIAG_ICONS UNIX_DIAG_RQLEN UNIX_DIAG_MEMINFO UNIX_DIAG_SHUTDOWN UNIX_DIAG_MAX )
View Source
const ProcRoot = "/proc"
Variables ¶
View Source
var ( AfFilter uint64 ProtocalFilter uint64 SsFilter uint32 FlagProcess bool FlagInfo bool FlagMemory bool MaxLocalAddrLength int MaxRemoteAddrLength int )
View Source
var ( OSPageSize = os.Getpagesize() SC_CLK_TCK = uint64(C.sysconf(C._SC_CLK_TCK)) )
View Source
var ( // channel SocketInfoChan chan SocketInfo ProcInfoChan chan *ProcInfo GlobalProcFds map[string]map[int]map[uint32]Fd )
View Source
var ( Sstate = []string{ "UNKNOWN", "ESTAB", "SYN-SENT", "SYN-RECV", "FIN-WAIT-1", "FIN-WAIT-2", "TIME-WAIT", "UNCONN", "CLOSE-WAIT", "LAST-ACK", "LISTEN", "CLOSING", "MAX", } SocketType = map[uint8]string{ SOCK_STREAM: "str", SOCK_DGRAM: "dgr", SOCK_RAW: "raw", SOCK_RDM: "rdm", SOCK_SEQPACKET: "seq", SOCK_DCCP: "dccp", SOCK_PACKET: "pack", } TimerState = []string{ "OFF", "ON", "KEEPALIVE", "TIMEWAIT", "PERSIST", "UNKNOWN", } SummaryPF = []string{ "TCP", "UDP", "UDPLITE", "RAW", "FRAG", } Colons = []string{ ":::::::", "::::::", ":::::", "::::", ":::", } )
View Source
var (
ErrorDone = fmt.Errorf("Done")
)
View Source
var KVer = new(KernelVersion)
View Source
var ProcState = map[byte]string{
'R': "Running",
'S': "Sleeping",
'D': "Waiting",
'Z': "Zombie",
'T': "Stopped",
't': "Tracing",
'X': "Dead",
'x': "Dead",
'K': "Wakekill",
'W': "Waking",
'P': "Parked",
}
View Source
var (
SlimSpaceRegExp *regexp.Regexp
)
Functions ¶
func AddrLengthInit ¶
func AddrLengthInit()
func CleanGlobalProcFds ¶
func CleanGlobalProcFds()
func GenericInetRead ¶
func GenericInetRead(protocal, af int) (sis map[uint32]SocketInfo, err error)
func GenericReadSockstat ¶
IPv6:versionFlag = true; IPv4:versionFlag = false
func GenericUnixRead ¶
func GenericUnixRead() (sis map[uint32]SocketInfo, err error)
func GetProcInfo ¶
func GetSocketCount ¶
func IPv4HexToString ¶
func IPv6HexToString ¶
func RecvInetDiagMsgAll ¶
func RecvInetDiagMsgAll(skfd int)
func RecvInetDiagMsgMulti ¶
func RecvUnixDiagMsgAll ¶
func RecvUnixDiagMsgAll(skfd int)
func RecvUnixDiagMsgMulti ¶
func ScanProcFS ¶
func ScanProcFS(fdFlag bool)
func SendInetDiagMsg ¶
Types ¶
type CPUJiffies ¶
type CPUJiffies struct { User uint64 // Time spent in user mode. Nice uint64 // Time spent in user mode with low priority (nice). System uint64 // Time spent in system mode. Idle uint64 // Time spent in the idle task. This value should be USER_HZ times the second entry in the /proc/uptime pseudo-file. Iowait uint64 // Time waiting for I/O to complete. Irq uint64 // Time servicing interrupts. Softirq uint64 // Time servicing softirqs. Steal uint64 // Stolen time, which is the time spent in other operating systems when running in a virtualized environment Guest uint64 // Time spent running a virtual CPU for guest operating systems under the control of the Linux kernel. GuestNice uint64 // Time spent running a niced guest (virtual CPU for guest operating ystems under the control of the Linux kernel). Total uint64 // not specified in /proc/stat }
type DirentReader ¶
type DirentReader struct { DataChan chan Dirent Buffer []byte Bufferx []byte NameBuffer []byte InternalDirent Dirent ExternalDirent Dirent BytesCounter int IndexBuffer int Cursor int }
func NewDirentReader ¶
func NewDirentReader() *DirentReader
func (*DirentReader) Scan ¶
func (d *DirentReader) Scan(fd *os.File)
type DiskStat ¶
type DiskStat struct { MajorNumber uint64 MinorNumber uint64 Name string ReadCompleted uint64 // reads completed ReadMerged uint64 // reads merged, field 6 -- # of writes merged SectorsRead uint64 // sectors read ReadingSpent uint64 // milliseconds spent reading WriteCompleted uint64 // writes completed WriteMerged uint64 // writes merged SectorsWritten uint64 // sectors written WritingSpent uint64 // milliseconds spent writing IOProgressing uint64 // I/Os currently in progress IOSpent uint64 // milliseconds spent doing I/Os WeightedIOSpent uint64 // milliseconds spent doing I/Os (weighted) DiscardCompleted uint64 // discards completed DiscardMerged uint64 // discards merged SectorDiscarded uint64 // sectors discarded DiscardSpending uint64 // milliseconds spent discarding }
definition comes from Linux kernel /Documentation/iostats.txt
type FileInfo ¶
func GetFileInfo ¶
type InetDiagMeminfo ¶
type InetDiagMessage ¶
type InetDiagReq ¶
type InetDiagRequest ¶
type InetDiagRequest struct { Header unix.NlMsghdr Request InetDiagReq }
type InetDiagSockID ¶
type KernelVersion ¶
type KernelVersion struct { Origin string UTSSysName string UTSRelease string CompileBy string CompileHost string Compiler string UTSVersion string }
definition comes from Linux kernel /fs/proc/version.c
func (*KernelVersion) Get ¶
func (kv *KernelVersion) Get() error
type MemoryInfo ¶
type MemoryInfo struct { MemTotal uint64 MemFree uint64 MemAvailable uint64 Buffers uint64 Cached uint64 SwapCached uint64 Active uint64 Inactive uint64 ActiveAnon uint64 InactiveAnon uint64 ActiveFile uint64 InactiveFile uint64 Unevictable uint64 Mlocked uint64 HighTotal uint64 HighFree uint64 LowTotal uint64 LowFree uint64 MmapCopy uint64 SwapTotal uint64 SwapFree uint64 Dirty uint64 Writeback uint64 AnonPages uint64 Mapped uint64 Shmem uint64 KReclaimable uint64 Slab uint64 SReclaimable uint64 SUnreclaim uint64 KernelStack uint64 PageTables uint64 Quicklists uint64 NFSUnstable uint64 Bounce uint64 WritebackTmp uint64 CommitLimit uint64 CommittedAS uint64 VmallocTotal uint64 VmallocUsed uint64 VmallocChunk uint64 Percpu uint64 HardwareCorrupted uint64 AnonHugePages uint64 ShmemHugePages uint64 ShmemPmdMapped uint64 CmaTotal uint64 CmaFree uint64 HugePagesTotal uint64 HugePagesFree uint64 HugePagesRsvd uint64 HugePagesSurp uint64 Hugepagesize uint64 DirectMap4k uint64 DirectMap2M uint64 DirectMap4M uint64 DirectMap1G uint64 }
definition comes from Linux kernel /fs/proc/meminfo.c
func (*MemoryInfo) Get ¶
func (mi *MemoryInfo) Get() error
type MountInfo ¶
type MountInfo struct { ID uint64 // a unique ID for the mount (may be reused after umount(2)). ParentID uint64 // the ID of the parent mount (or of self for the root of this mount namespace's mount tree). If a new mount is stacked on top of a previous existing mount (so that it hides the existing mount) at pathname P, then the parent of the new mount is the previous mount at that location. Thus, when looking at all the mounts stacked at a particular location, the top-most mount is the one that is not the parent of any other mount at the same location. (Note, however, that this top-most mount will be accessible only if the longest path subprefix of P that is a mount point is not itself hidden by a stacked mount.) If the parent mount point lies outside the process's root directory (see chroot(2)), the ID shown here won't have a corresponding record in mountinfo whose mount ID (field 1) matches this parent mount ID (because mount points that lie outside the process's root directory are not shown in mountinfo). As a special case of this point, the process's root mount point may have a parent mount (for the initramfs filesystem) that lies outside the process's root directory, and an entry for that mount point will not appear in mountinfo. DiskMajorNum uint64 // the value of st_dev for files on this filesystem (see stat(2)). DiskMinorNum uint64 FileSystemRoot string // the pathname of the directory in the filesystem which forms the root of this mount. MountPoint string // the pathname of the mount point relative to the process's root directory. MountOptions string // per-mount options (see mount(2)). OptionalFields string // zero or more fields of the form "tag[:value]"; see below. FilesystemType string // the filesystem type in the form "type[.subtype]". MountSource string // filesystem-specific information or "none". SuperOptions string // per-superblock options (see mount(2)). }
definition comes from http://man7.org/linux/man-pages/man5/proc.5.html
type MountInfos ¶
type MountInfos []*MountInfo
func NewMountInfos ¶
func NewMountInfos() MountInfos
func (*MountInfos) Get ¶
func (mis *MountInfos) Get() error
type NetDev ¶
type NetDev struct { Interface string ReceiveBytes uint64 ReceivePackets uint64 ReceiveErrs uint64 ReceiveDrop uint64 ReceiveFifo uint64 ReceiveFrame uint64 ReceiveCompressed uint64 ReceiveMulticast uint64 TransmitBytes uint64 TransmitPackets uint64 TransmitErrs uint64 TransmitDrop uint64 TransmitFifo uint64 TransmitColls uint64 TransmitCarrier uint64 TransmitCompressed uint64 }
type NetDevs ¶
func NewNetDevs ¶
func NewNetDevs() NetDevs
type ProcStat ¶
type ProcStat struct { Pid int Name string // The filename of the executable, in parentheses. This is visible whether or not the executable is swapped out. State byte // single-char code for process state Ppid int // The PID of the parent of this process. Pgrp int // The process group ID of the process. Session int // The session ID of the process. TtyNr int // The controlling terminal of the process. (The minor device number is contained in the combination of bits 31 to 20 and 7 to 0; the major device number is in bits 15 to 8) Tpgid int // The ID of the foreground process group of the controlling terminal of the process. Flags uint32 // The kernel flags word of the process. For bit meanings, see the PF_* defines in the Linux kernel source file include/linux/sched.h. Details depend on the kernel version. Minflt uint64 // The number of minor faults the process has made which have not required loading a memory page from disk Cminflt uint64 // The number of minor faults that the process's waited-for children have made Majflt uint64 // The number of major faults the process has made which have required loading a memory page from disk Cmajflt uint64 // The number of major faults that the process's waited-for children have made Utime uint64 // Amount of time that this process has been scheduled in user mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). This includes guest time, so that applications that are not aware of the guest time field do not lose that time from their calculations. Stime uint64 // Amount of time that this process has been scheduled in kernel mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). Cutime uint64 // Amount of time that this process's waited-for children have been scheduled in user mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). This includes guest time, cguest_time. Cstime uint64 // Amount of time that this process's waited-for children have been scheduled in kernel mode, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). Priority int64 // For processes running a real-time scheduling policy, this is the negated scheduling priority, minus one; that is, a number in the range -2 to -100, corresponding to real-time priorities 1 to 99. For processes running under a non-real-time scheduling policy, this is the raw nice value as represented in the kernel. The kernel stores nice values as numbers in the range 0 (high) to 39 (low), corresponding to the user-visible nice range of -20 to 19. Nice int64 // The nice value, a value in the range 19 (low priority) to -20 (high priority). NumThreads int64 // Number of threads in this process (since Linux 2.6). Itrealvalue int64 // Obsolete Starttime uint64 // The time the process started after system boot. In kernels before Linux 2.6, this value was expressed in jiffies. Since Linux 2.6, the value is expressed in clock ticks (divide by sysconf(_SC_CLK_TCK)). Vsize uint64 // Virtual memory size in bytes. Rss int64 // Resident Set Size: number of pages the process has in real memory. This is just the pages which count toward text, data, or stack space. This does not include pages which have not been demand-loaded in, or which are swapped out. Rsslim uint64 // Current soft limit in bytes on the rss of the process Startcode uint64 // The address above which program text can run. Endcode uint64 // The address below which program text can run. Startstack uint64 // The address of the start (i.e., bottom) of the stack. Kstkesp uint64 // The current value of ESP (stack pointer), as found in the kernel stack page for the process. Kstkeip uint64 // The current EIP (instruction pointer). Signal uint64 // Obsolete Blocked uint64 // Obsolete Sigignore uint64 // Obsolete Sigcatch uint64 // Obsolete Wchan uint64 // This is the "channel" in which the process is waiting. It is the address of a location in the kernel where the process is sleeping. The corresponding symbolic name can be found in /proc/[pid]/wchan. Nswap uint64 // Obsolete Cnswap uint64 // Obsolete ExitSignal int // Signal to be sent to parent when we die Processor int // CPU number last executed on RtPriority uint64 // Real-time scheduling priority, a number in the range 1 to 99 for processes scheduled under a real-time policy, or 0, for non-real-time processes . Policy uint32 // Scheduling policy. Decode using the SCHED_* constants in linux/sched.h. DelayacctBlkioTicks uint64 // Aggregated block I/O delays, measured in clock ticks (centiseconds). GuestTime uint64 // Guest time of the process (time spent running a virtual CPU for a guest operating system), measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). CguestTime int64 // Guest time of the process's children, measured in clock ticks (divide by sysconf(_SC_CLK_TCK)). StartData uint64 // Address above which program initialized and uninitialized (BSS) data are placed. EndData uint64 // Address below which program initialized and uninitialized (BSS) data are placed. StartBrk uint64 // Address above which program heap can be expanded with brk(2). ArgStart uint64 // Address above which program command-line arguments (argv) are placed. ArgEnd uint64 // Address below program command-line arguments (argv) are placed. EnvStart uint64 // Address above which program environment is placed. EnvEnd uint64 // Address below which program environment is placed. ExitCode int // The thread's exit status. }
type SocketInfo ¶
type SocketInfo struct { // Generic LocalAddr IP RemoteAddr IP Status uint8 TxQueue uint32 RxQueue uint32 Timer int Timeout int Retransmit int UID uint64 Probes int // unanswered 0-window probes Inode uint32 RefCount int SK uint64 // /proc/net/tcp or /proc/net/tcp6 specific RTO float64 // RetransmitTimeout ATO float64 // Predicted tick of soft clock (delayed ACK control data) QACK int // (ack.quick<<1)|ack.pingpong CongestionWindow int // sending congestion window SlowStartThreshold int // slow start size threshold, or -1 if the threshold is >= 0xFFFF Opt []string // Option Info // Internal TCP information TCPInfo *TCPInfo VegasInfo *TCPVegasInfo CONG []byte // Extended Info Drops int // Generic like UDP, RAW specific Type uint8 // socket type Meminfo []uint32 // Related processes UserName string // Flag IsEnd bool }
func NewSocketInfo ¶
func NewSocketInfo() *SocketInfo
func (*SocketInfo) ExtendInfoPrint ¶
func (si *SocketInfo) ExtendInfoPrint()
func (*SocketInfo) GenericInfoPrint ¶
func (si *SocketInfo) GenericInfoPrint()
func (*SocketInfo) MeminfoPrint ¶
func (si *SocketInfo) MeminfoPrint()
func (*SocketInfo) ProcInfoPrint ¶
func (si *SocketInfo) ProcInfoPrint()
func (*SocketInfo) Reset ¶
func (si *SocketInfo) Reset()
func (*SocketInfo) SetUpRelation ¶
func (si *SocketInfo) SetUpRelation()
func (*SocketInfo) TCPInfoPrint ¶
func (si *SocketInfo) TCPInfoPrint()
func (*SocketInfo) TimerInfoPrint ¶
func (si *SocketInfo) TimerInfoPrint()
type SystemStat ¶
type SystemStat struct { CPUTotal *CPUJiffies PageIn, PageOut uint64 // The number of pages the system paged in and the number that were paged out (from disk). SwapIn, SwapOut uint64 // The number of swap pages that have been brought in and out. Intr uint64 // This line shows counts of interrupts serviced since boot time, for each of the possible system interrupts. The first column is the total of all interrupts serviced including unnumbered architecture specific interrupts; each subsequent column is the total for that particular numbered interrupt. Unnumbered interrupts are not shown, only summed into the total. Ctxt uint64 // The number of context switches that the system underwent. Btime uint64 // boot time, in seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). Processes uint64 // Number of forks since boot. ProcsRunning uint64 // Number of processes in runnable state. (Linux 2.5.45 onward.) ProcsBlocked uint64 // Number of processes blocked waiting for I/O to complete. (Linux 2.5.45 onward.) }
definition comes from Linux kernel /fs/proc/stat.c
func (*SystemStat) Get ¶
func (ss *SystemStat) Get() (err error)
type TCPInfo ¶
type TCPInfo struct { State uint8 Ca_state uint8 Retransmits uint8 Probes uint8 Backoff uint8 Options uint8 Pad_cgo_0 [2]byte Rto uint32 Ato uint32 Snd_mss uint32 Rcv_mss uint32 Unacked uint32 Sacked uint32 Lost uint32 Retrans uint32 Fackets uint32 Last_data_sent uint32 Last_ack_sent uint32 Last_data_recv uint32 Last_ack_recv uint32 Pmtu uint32 Rcv_ssthresh uint32 Rtt uint32 Rttvar uint32 Snd_ssthresh uint32 Snd_cwnd uint32 Advmss uint32 Reordering uint32 Rcv_rtt uint32 Rcv_space uint32 Total_retrans uint32 Pacing_rate uint64 Max_pacing_rate uint64 Bytes_acked uint64 /* RFC4898 tcpEStatsAppHCThruOctetsAcked */ Bytes_received uint64 /* RFC4898 tcpEStatsAppHCThruOctetsReceived */ Segs_out uint32 /* RFC4898 tcpEStatsPerfSegsOut */ Segs_in uint32 /* RFC4898 tcpEStatsPerfSegsIn */ Notsent_bytes uint32 Min_rtt uint32 Data_segs_in uint32 /* RFC4898 tcpEStatsDataSegsIn */ Data_segs_out uint32 /* RFC4898 tcpEStatsDataSegsOut */ Delivery_rate uint64 Busy_time uint64 /* Time (usec) busy sending data */ Rwnd_limited uint64 /* Time (usec) limited by receive window */ Sndbuf_limited uint64 /* Time (usec) limited by send buffer */ }
type TCPVegasInfo ¶
type UnixDiagMessage ¶
type UnixDiagRQlen ¶
type UnixDiagReq ¶
type UnixDiagRequest ¶
type UnixDiagRequest struct { Header unix.NlMsghdr Request UnixDiagReq }
type UnixDiagVFS ¶
Click to show internal directories.
Click to hide internal directories.