Add some documentation to pkg/system
Partially addresses #11581 Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
This commit is contained in:
parent
dce6f8ba76
commit
eea8abd59e
10 changed files with 24 additions and 2 deletions
|
@ -15,8 +15,8 @@ var (
|
|||
ErrMalformed = errors.New("malformed file")
|
||||
)
|
||||
|
||||
// Retrieve memory statistics of the host system and parse them into a MemInfo
|
||||
// type.
|
||||
// ReadMemInfo retrieves memory statistics of the host system and returns a
|
||||
// MemInfo type.
|
||||
func ReadMemInfo() (*MemInfo, error) {
|
||||
file, err := os.Open("/proc/meminfo")
|
||||
if err != nil {
|
||||
|
@ -26,6 +26,10 @@ func ReadMemInfo() (*MemInfo, error) {
|
|||
return parseMemInfo(file)
|
||||
}
|
||||
|
||||
// parseMemInfo parses the /proc/meminfo file into
|
||||
// a MemInfo object given a io.Reader to the file.
|
||||
//
|
||||
// Throws error if there are problems reading from the file
|
||||
func parseMemInfo(reader io.Reader) (*MemInfo, error) {
|
||||
meminfo := &MemInfo{}
|
||||
scanner := bufio.NewScanner(reader)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue