update procfs to v0.0.5
- Fixes (#1465) failure in netclass collector - Adds parsing of CPU information Signed-off-by: Paul Gier <pgier@redhat.com>
This commit is contained in:
parent
eb19c5c20b
commit
cbfb496629
12 changed files with 1038 additions and 131 deletions
10
vendor/github.com/prometheus/procfs/sysfs/class_infiniband.go
generated
vendored
10
vendor/github.com/prometheus/procfs/sysfs/class_infiniband.go
generated
vendored
|
|
@ -244,13 +244,16 @@ func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) {
|
|||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
if !f.Mode().IsRegular() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := filepath.Join(path, f.Name())
|
||||
value, err := util.SysReadFile(name)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" {
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("failed to read file %q: %v", name, err)
|
||||
}
|
||||
|
||||
|
|
@ -324,13 +327,16 @@ func parseInfiniBandCounters(portPath string) (*InfiniBandCounters, error) {
|
|||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
if !f.Mode().IsRegular() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := filepath.Join(path, f.Name())
|
||||
value, err := util.SysReadFile(name)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" {
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("failed to read file %q: %v", name, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
6
vendor/github.com/prometheus/procfs/sysfs/class_power_supply.go
generated
vendored
6
vendor/github.com/prometheus/procfs/sysfs/class_power_supply.go
generated
vendored
|
|
@ -18,6 +18,7 @@ package sysfs
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
|
|
@ -134,13 +135,16 @@ func parsePowerSupply(path string) (*PowerSupply, error) {
|
|||
|
||||
var ps PowerSupply
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
if !f.Mode().IsRegular() {
|
||||
continue
|
||||
}
|
||||
|
||||
name := filepath.Join(path, f.Name())
|
||||
value, err := util.SysReadFile(name)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" {
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("failed to read file %q: %v", name, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
6
vendor/github.com/prometheus/procfs/sysfs/net_class.go
generated
vendored
6
vendor/github.com/prometheus/procfs/sysfs/net_class.go
generated
vendored
|
|
@ -18,6 +18,7 @@ package sysfs
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/prometheus/procfs/internal/util"
|
||||
|
|
@ -112,12 +113,15 @@ func (nc NetClass) parseNetClassIface(devicePath string) (*NetClassIface, error)
|
|||
}
|
||||
|
||||
for _, f := range files {
|
||||
if f.IsDir() {
|
||||
if !f.Mode().IsRegular() {
|
||||
continue
|
||||
}
|
||||
name := filepath.Join(devicePath, f.Name())
|
||||
value, err := util.SysReadFile(name)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) || err.Error() == "operation not supported" || err.Error() == "invalid argument" {
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("failed to read file %q: %v", name, err)
|
||||
}
|
||||
vp := util.NewValueParser(value)
|
||||
|
|
|
|||
97
vendor/github.com/prometheus/procfs/sysfs/system_cpu.go
generated
vendored
97
vendor/github.com/prometheus/procfs/sysfs/system_cpu.go
generated
vendored
|
|
@ -25,6 +25,28 @@ import (
|
|||
"github.com/prometheus/procfs/internal/util"
|
||||
)
|
||||
|
||||
// CPU represents a path to a CPU located in /sys/devices/system/cpu/cpu[0-9]*
|
||||
type CPU string
|
||||
|
||||
// Number returns the ID number of the given CPU
|
||||
func (c CPU) Number() string {
|
||||
return strings.TrimPrefix(filepath.Base(string(c)), "cpu")
|
||||
}
|
||||
|
||||
// CPUTopology contains data located in /sys/devices/system/cpu/cpu[0-9]*/topology
|
||||
type CPUTopology struct {
|
||||
CoreID string
|
||||
CoreSiblingsList string
|
||||
PhysicalPackageID string
|
||||
ThreadSiblingsList string
|
||||
}
|
||||
|
||||
// CPUThermalThrottle contains data from /sys/devices/system/cpu/cpu[0-9]*/thermal_throttle
|
||||
type CPUThermalThrottle struct {
|
||||
CoreThrottleCount uint64
|
||||
PackageThrottleCount uint64
|
||||
}
|
||||
|
||||
// SystemCPUCpufreqStats contains stats from devices/system/cpu/cpu[0-9]*/cpufreq/...
|
||||
type SystemCPUCpufreqStats struct {
|
||||
Name string
|
||||
|
|
@ -42,9 +64,80 @@ type SystemCPUCpufreqStats struct {
|
|||
SetSpeed string
|
||||
}
|
||||
|
||||
// TODO: Add topology support.
|
||||
// CPUs returns a slice of all CPUs in /sys/devices/system/cpu
|
||||
func (fs FS) CPUs() ([]CPU, error) {
|
||||
cpuPaths, err := filepath.Glob(fs.sys.Path("devices/system/cpu/cpu[0-9]*"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cpus := make([]CPU, len(cpuPaths))
|
||||
for i, cpu := range cpuPaths {
|
||||
cpus[i] = CPU(cpu)
|
||||
}
|
||||
return cpus, nil
|
||||
}
|
||||
|
||||
// TODO: Add thermal_throttle support.
|
||||
// Topology gets the topology information for a single CPU from /sys/devices/system/cpu/cpuN/topology
|
||||
func (c CPU) Topology() (*CPUTopology, error) {
|
||||
cpuTopologyPath := filepath.Join(string(c), "topology")
|
||||
if _, err := os.Stat(cpuTopologyPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t, err := parseCPUTopology(cpuTopologyPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func parseCPUTopology(cpuPath string) (*CPUTopology, error) {
|
||||
t := CPUTopology{}
|
||||
var err error
|
||||
t.CoreID, err = util.SysReadFile(filepath.Join(cpuPath, "core_id"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t.PhysicalPackageID, err = util.SysReadFile(filepath.Join(cpuPath, "physical_package_id"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t.CoreSiblingsList, err = util.SysReadFile(filepath.Join(cpuPath, "core_siblings_list"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t.ThreadSiblingsList, err = util.SysReadFile(filepath.Join(cpuPath, "thread_siblings_list"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
// ThermalThrottle gets the cpu throttle count information for a single CPU from /sys/devices/system/cpu/cpuN/thermal_throttle
|
||||
func (c CPU) ThermalThrottle() (*CPUThermalThrottle, error) {
|
||||
cpuPath := filepath.Join(string(c), "thermal_throttle")
|
||||
if _, err := os.Stat(cpuPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t, err := parseCPUThermalThrottle(cpuPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func parseCPUThermalThrottle(cpuPath string) (*CPUThermalThrottle, error) {
|
||||
t := CPUThermalThrottle{}
|
||||
var err error
|
||||
t.PackageThrottleCount, err = util.ReadUintFromFile(filepath.Join(cpuPath, "package_throttle_count"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t.CoreThrottleCount, err = util.ReadUintFromFile(filepath.Join(cpuPath, "core_throttle_count"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
// SystemCpufreq returns CPU frequency metrics for all CPUs.
|
||||
func (fs FS) SystemCpufreq() ([]SystemCPUCpufreqStats, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue