Source File
meminfo.go
Belonging Package
github.com/prometheus/procfs
package procfs
import (
)
VmallocChunk 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
DirectMap1G uint64
}
func ( FS) () (Meminfo, error) {
, := util.ReadFileNoStat(.proc.Path("meminfo"))
if != nil {
return Meminfo{},
}
, := parseMemInfo(bytes.NewReader())
if != nil {
return Meminfo{}, fmt.Errorf("failed to parse meminfo: %v", )
}
return *, nil
}
func ( io.Reader) (*Meminfo, error) {
var Meminfo
:= bufio.NewScanner()
:= strings.Fields(.Text())
if len() < 2 {
return nil, fmt.Errorf("malformed meminfo line: %q", .Text())
}
, := strconv.ParseUint([1], 0, 64)
if != nil {
return nil,
}
switch [0] {
case "MemTotal:":
.MemTotal =
case "MemFree:":
.MemFree =
case "MemAvailable:":
.MemAvailable =
case "Buffers:":
.Buffers =
case "Cached:":
.Cached =
case "SwapCached:":
.SwapCached =
case "Active:":
.Active =
case "Inactive:":
.Inactive =
case "Active(anon):":
.ActiveAnon =
case "Inactive(anon):":
.InactiveAnon =
case "Active(file):":
.ActiveFile =
case "Inactive(file):":
.InactiveFile =
case "Unevictable:":
.Unevictable =
case "Mlocked:":
.Mlocked =
case "SwapTotal:":
.SwapTotal =
case "SwapFree:":
.SwapFree =
case "Dirty:":
.Dirty =
case "Writeback:":
.Writeback =
case "AnonPages:":
.AnonPages =
case "Mapped:":
.Mapped =
case "Shmem:":
.Shmem =
case "Slab:":
.Slab =
case "SReclaimable:":
.SReclaimable =
case "SUnreclaim:":
.SUnreclaim =
case "KernelStack:":
.KernelStack =
case "PageTables:":
.PageTables =
case "NFS_Unstable:":
.NFSUnstable =
case "Bounce:":
.Bounce =
case "WritebackTmp:":
.WritebackTmp =
case "CommitLimit:":
.CommitLimit =
case "Committed_AS:":
.CommittedAS =
case "VmallocTotal:":
.VmallocTotal =
case "VmallocUsed:":
.VmallocUsed =
case "VmallocChunk:":
.VmallocChunk =
case "HardwareCorrupted:":
.HardwareCorrupted =
case "AnonHugePages:":
.AnonHugePages =
case "ShmemHugePages:":
.ShmemHugePages =
case "ShmemPmdMapped:":
.ShmemPmdMapped =
case "CmaTotal:":
.CmaTotal =
case "CmaFree:":
.CmaFree =
case "HugePages_Total:":
.HugePagesTotal =
case "HugePages_Free:":
.HugePagesFree =
case "HugePages_Rsvd:":
.HugePagesRsvd =
case "HugePages_Surp:":
.HugePagesSurp =
case "Hugepagesize:":
.Hugepagesize =
case "DirectMap4k:":
.DirectMap4k =
case "DirectMap2M:":
.DirectMap2M =
case "DirectMap1G:":
.DirectMap1G =
}
}
return &, nil
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |