update procfs to v0.0.2 (#1376)

Signed-off-by: Paul Gier <pgier@redhat.com>
This commit is contained in:
Paul Gier 2019-06-12 13:47:16 -05:00 committed by Ben Kochie
commit 2bc133cd48
33 changed files with 167 additions and 172 deletions

View file

@ -102,18 +102,8 @@ type PowerSupply struct {
// The map keys are the names of the power supplies.
type PowerSupplyClass map[string]PowerSupply
// NewPowerSupplyClass returns info for all power supplies read from /sys/class/power_supply/.
func NewPowerSupplyClass() (PowerSupplyClass, error) {
fs, err := NewFS(DefaultMountPoint)
if err != nil {
return nil, err
}
return fs.NewPowerSupplyClass()
}
// NewPowerSupplyClass returns info for all power supplies read from /sys/class/power_supply/.
func (fs FS) NewPowerSupplyClass() (PowerSupplyClass, error) {
// PowerSupplyClass returns info for all power supplies read from /sys/class/power_supply/.
func (fs FS) PowerSupplyClass() (PowerSupplyClass, error) {
path := fs.sys.Path("class/power_supply")
powerSupplyDirs, err := ioutil.ReadDir(path)

View file

@ -35,8 +35,8 @@ type ClassThermalZoneStats struct {
Passive *uint64 // Optional: millidegrees Celsius. (0 for disabled, > 1000 for enabled+value)
}
// NewClassThermalZoneStats returns Thermal Zone metrics for all zones.
func (fs FS) NewClassThermalZoneStats() ([]ClassThermalZoneStats, error) {
// ClassThermalZoneStats returns Thermal Zone metrics for all zones.
func (fs FS) ClassThermalZoneStats() ([]ClassThermalZoneStats, error) {
zones, err := filepath.Glob(fs.sys.Path("class/thermal/thermal_zone[0-9]*"))
if err != nil {
return []ClassThermalZoneStats{}, err

View file

@ -26,6 +26,12 @@ type FS struct {
// DefaultMountPoint is the common mount point of the sys filesystem.
const DefaultMountPoint = fs.DefaultSysMountPoint
// NewDefaultFS returns a new FS mounted under the default mountPoint. It will error
// if the mount point can't be read.
func NewDefaultFS() (FS, error) {
return NewFS(DefaultMountPoint)
}
// NewFS returns a new FS mounted under the given mountPoint. It will error
// if the mount point can't be read.
func NewFS(mountPoint string) (FS, error) {

View file

@ -65,16 +65,6 @@ type NetClassIface struct {
// are interface (iface) names.
type NetClass map[string]NetClassIface
// NewNetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
func NewNetClass() (NetClass, error) {
fs, err := NewFS(DefaultMountPoint)
if err != nil {
return nil, err
}
return fs.NewNetClass()
}
// NetClassDevices scans /sys/class/net for devices and returns them as a list of names.
func (fs FS) NetClassDevices() ([]string, error) {
var res []string
@ -95,8 +85,8 @@ func (fs FS) NetClassDevices() ([]string, error) {
return res, nil
}
// NewNetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
func (fs FS) NewNetClass() (NetClass, error) {
// NetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
func (fs FS) NetClass() (NetClass, error) {
devices, err := fs.NetClassDevices()
if err != nil {
return nil, err

View file

@ -46,18 +46,8 @@ type SystemCPUCpufreqStats struct {
// TODO: Add thermal_throttle support.
// NewSystemCpufreq returns CPU frequency metrics for all CPUs.
func NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) {
fs, err := NewFS(DefaultMountPoint)
if err != nil {
return []SystemCPUCpufreqStats{}, err
}
return fs.NewSystemCpufreq()
}
// NewSystemCpufreq returns CPU frequency metrics for all CPUs.
func (fs FS) NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) {
// SystemCpufreq returns CPU frequency metrics for all CPUs.
func (fs FS) SystemCpufreq() ([]SystemCPUCpufreqStats, error) {
var g errgroup.Group
cpus, err := filepath.Glob(fs.sys.Path("devices/system/cpu/cpu[0-9]*"))