github.com/xmidt-org/webpa-common@v1.11.9/health/memInfoReader.go (about) 1 package health 2 3 import ( 4 "github.com/c9s/goprocinfo/linux" 5 ) 6 7 const ( 8 // DefaultMemoryReaderLocation is the default location for meminfo 9 // under Linux 10 DefaultMemoryReaderLocation string = "/proc/meminfo" 11 ) 12 13 // MemInfoReader handles extracting the linux memory information from 14 // the enclosing environment. 15 type MemInfoReader struct { 16 Location string 17 } 18 19 // Read parses the configured Location as if it were a linux meminfo file. 20 func (reader *MemInfoReader) Read() (memInfo *linux.MemInfo, err error) { 21 location := reader.Location 22 if len(location) == 0 { 23 location = DefaultMemoryReaderLocation 24 } 25 26 return linux.ReadMemInfo(location) 27 }