Documentation
¶
Overview ¶
Package proc scrapes information from the /proc pseudo-filesystem on Linux.
The functions do a minimal amount of parsing before returning the data. See `man proc` and other documentation indicated by the API functions for more information on how to use them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadAverages ¶
LoadAverages returns the 1, 5, and 15 minute load averages as reported by /proc/loadavg.
func MemInfo ¶
MemInfo returns the memory information fields from /proc/meminfo, such as "MemTotal" and "MemFree". Byte values are returned in bytes, not kB.
func NetDevStats ¶
NetDevStats returns the data in /proc/net/dev. Example: eth0 -> bytes -> 12345
func NetProtoStats ¶
NetProtoStats parses the files /proc/net/netstat, and /proc/net/snmp. It returns the table of values as a 2-dimensional array from category -> key -> value. For example:
{
"Tcp": {
"ActiveOpens": 11023,
"PassiveOpens": 64,
...
},
"Udp": {...},
...
}
Types ¶
type CPUStatInfo ¶
type CPUStatInfo struct {
User uint64
Nice uint64
System uint64
Idle uint64
Iowait uint64
Irq uint64
Softirq uint64
Steal uint64
Guest uint64
Guest_nice uint64
}
A CPUStatInfo is a CPU entry in /proc/stat. All values are in USER_HZ.
type FSTabEntry ¶
type FSTabEntry struct {
Spec string // /dev/sda1
File string // /mnt/data
Vfstype string // ext4
Mntops []string // [rw, relatime]
Freq int // 0
Passno int // 0
}
FSTabEntry describes a line from /proc/mounts, which is the fstab format. See 'man fstab' for the meaning of these fields. The field comments are examples of what might be found there (but see the man page for details).
func Mounts ¶
func Mounts() ([]*FSTabEntry, error)
Read mount information from /proc/mounts for the current process. BUG(caleb): This doesn't handle spaces in mount points, even though fstab specifies an encoding for them.
type IOStatEntry ¶
type IOStatEntry struct {
// Partition info
Major int
Minor int
Name string
// The rest of the fields are described in Linux's Documentation/iostats.txt.
ReadsCompleted uint64
ReadsMerged uint64
SectorsRead uint64
ReadMillis uint64
WritesCompleted uint64
WritesMerged uint64
SectorsWritten uint64
WriteMillis uint64
NumInProgressIOs uint64
IOMillis uint64
WeightedIOMillis uint64
}
IOStatEntry represents a line in /proc/diskstats.
func DiskStats ¶
func DiskStats() ([]*IOStatEntry, error)
DiskStats reports disk information from /proc/diskstats.
Notes ¶
Bugs ¶
This doesn't handle spaces in mount points, even though fstab specifies an encoding for them.