github.com/newrelic/go-agent@v3.26.0+incompatible/internal/sysinfo/memtotal_linux.go (about)

     1  // Copyright 2020 New Relic Corporation. All rights reserved.
     2  // SPDX-License-Identifier: Apache-2.0
     3  
     4  package sysinfo
     5  
     6  import "os"
     7  
     8  // PhysicalMemoryBytes returns the total amount of host memory.
     9  func PhysicalMemoryBytes() (uint64, error) {
    10  	f, err := os.Open("/proc/meminfo")
    11  	if err != nil {
    12  		return 0, err
    13  	}
    14  	defer f.Close()
    15  
    16  	return parseProcMeminfo(f)
    17  }