aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--collector/buddyinfo.go2
-rw-r--r--collector/cpu_linux.go2
-rw-r--r--collector/cpufreq_linux.go2
-rw-r--r--collector/ipvs_linux.go4
-rw-r--r--collector/netclass_linux.go2
-rw-r--r--collector/pressure_linux.go2
-rw-r--r--collector/processes_linux.go2
-rw-r--r--collector/stat_linux.go2
-rw-r--r--go.mod2
-rw-r--r--go.sum4
-rw-r--r--node_exporter_test.go6
-rw-r--r--vendor/github.com/prometheus/procfs/README.md11
-rw-r--r--vendor/github.com/prometheus/procfs/bcache/get.go6
-rw-r--r--vendor/github.com/prometheus/procfs/buddyinfo.go12
-rw-r--r--vendor/github.com/prometheus/procfs/fs.go6
-rw-r--r--vendor/github.com/prometheus/procfs/ipvs.go28
-rw-r--r--vendor/github.com/prometheus/procfs/mdstat.go74
-rw-r--r--vendor/github.com/prometheus/procfs/net_dev.go18
-rw-r--r--vendor/github.com/prometheus/procfs/nfs/nfs.go6
-rw-r--r--vendor/github.com/prometheus/procfs/proc.go11
-rw-r--r--vendor/github.com/prometheus/procfs/proc_io.go4
-rw-r--r--vendor/github.com/prometheus/procfs/proc_limits.go7
-rw-r--r--vendor/github.com/prometheus/procfs/proc_ns.go4
-rw-r--r--vendor/github.com/prometheus/procfs/proc_psi.go17
-rw-r--r--vendor/github.com/prometheus/procfs/proc_stat.go9
-rw-r--r--vendor/github.com/prometheus/procfs/stat.go36
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/class_power_supply.go14
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/class_thermal.go4
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/fs.go6
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/net_class.go14
-rw-r--r--vendor/github.com/prometheus/procfs/sysfs/system_cpu.go14
-rw-r--r--vendor/github.com/prometheus/procfs/xfs/xfs.go6
-rw-r--r--vendor/modules.txt2
33 files changed, 167 insertions, 172 deletions
diff --git a/collector/buddyinfo.go b/collector/buddyinfo.go
index 9ac790f..f6dd5db 100644
--- a/collector/buddyinfo.go
+++ b/collector/buddyinfo.go
@@ -55,7 +55,7 @@ func NewBuddyinfoCollector() (Collector, error) {
55// Update calls (*buddyinfoCollector).getBuddyInfo to get the platform specific 55// Update calls (*buddyinfoCollector).getBuddyInfo to get the platform specific
56// buddyinfo metrics. 56// buddyinfo metrics.
57func (c *buddyinfoCollector) Update(ch chan<- prometheus.Metric) error { 57func (c *buddyinfoCollector) Update(ch chan<- prometheus.Metric) error {
58 buddyInfo, err := c.fs.NewBuddyInfo() 58 buddyInfo, err := c.fs.BuddyInfo()
59 if err != nil { 59 if err != nil {
60 return fmt.Errorf("couldn't get buddyinfo: %s", err) 60 return fmt.Errorf("couldn't get buddyinfo: %s", err)
61 } 61 }
diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go
index a8b34db..f915d62 100644
--- a/collector/cpu_linux.go
+++ b/collector/cpu_linux.go
@@ -155,7 +155,7 @@ func (c *cpuCollector) updateThermalThrottle(ch chan<- prometheus.Metric) error
155 155
156// updateStat reads /proc/stat through procfs and exports cpu related metrics. 156// updateStat reads /proc/stat through procfs and exports cpu related metrics.
157func (c *cpuCollector) updateStat(ch chan<- prometheus.Metric) error { 157func (c *cpuCollector) updateStat(ch chan<- prometheus.Metric) error {
158 stats, err := c.fs.NewStat() 158 stats, err := c.fs.Stat()
159 if err != nil { 159 if err != nil {
160 return err 160 return err
161 } 161 }
diff --git a/collector/cpufreq_linux.go b/collector/cpufreq_linux.go
index badc16f..d2560dc 100644
--- a/collector/cpufreq_linux.go
+++ b/collector/cpufreq_linux.go
@@ -80,7 +80,7 @@ func NewCPUFreqCollector() (Collector, error) {
80 80
81// Update implements Collector and exposes cpu related metrics from /proc/stat and /sys/.../cpu/. 81// Update implements Collector and exposes cpu related metrics from /proc/stat and /sys/.../cpu/.
82func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error { 82func (c *cpuFreqCollector) Update(ch chan<- prometheus.Metric) error {
83 cpuFreqs, err := c.fs.NewSystemCpufreq() 83 cpuFreqs, err := c.fs.SystemCpufreq()
84 if err != nil { 84 if err != nil {
85 return err 85 return err
86 } 86 }
diff --git a/collector/ipvs_linux.go b/collector/ipvs_linux.go
index 524bac4..34c687a 100644
--- a/collector/ipvs_linux.go
+++ b/collector/ipvs_linux.go
@@ -106,7 +106,7 @@ func newIPVSCollector() (*ipvsCollector, error) {
106} 106}
107 107
108func (c *ipvsCollector) Update(ch chan<- prometheus.Metric) error { 108func (c *ipvsCollector) Update(ch chan<- prometheus.Metric) error {
109 ipvsStats, err := c.fs.NewIPVSStats() 109 ipvsStats, err := c.fs.IPVSStats()
110 if err != nil { 110 if err != nil {
111 // Cannot access ipvs metrics, report no error. 111 // Cannot access ipvs metrics, report no error.
112 if os.IsNotExist(err) { 112 if os.IsNotExist(err) {
@@ -121,7 +121,7 @@ func (c *ipvsCollector) Update(ch chan<- prometheus.Metric) error {
121 ch <- c.incomingBytes.mustNewConstMetric(float64(ipvsStats.IncomingBytes)) 121 ch <- c.incomingBytes.mustNewConstMetric(float64(ipvsStats.IncomingBytes))
122 ch <- c.outgoingBytes.mustNewConstMetric(float64(ipvsStats.OutgoingBytes)) 122 ch <- c.outgoingBytes.mustNewConstMetric(float64(ipvsStats.OutgoingBytes))
123 123
124 backendStats, err := c.fs.NewIPVSBackendStatus() 124 backendStats, err := c.fs.IPVSBackendStatus()
125 if err != nil { 125 if err != nil {
126 return fmt.Errorf("could not get backend status: %s", err) 126 return fmt.Errorf("could not get backend status: %s", err)
127 } 127 }
diff --git a/collector/netclass_linux.go b/collector/netclass_linux.go
index d02ead6..040ded3 100644
--- a/collector/netclass_linux.go
+++ b/collector/netclass_linux.go
@@ -169,7 +169,7 @@ func pushMetric(ch chan<- prometheus.Metric, subsystem string, name string, valu
169} 169}
170 170
171func (c *netClassCollector) getNetClassInfo() (sysfs.NetClass, error) { 171func (c *netClassCollector) getNetClassInfo() (sysfs.NetClass, error) {
172 netClass, err := c.fs.NewNetClass() 172 netClass, err := c.fs.NetClass()
173 173
174 if err != nil { 174 if err != nil {
175 return netClass, fmt.Errorf("error obtaining net class info: %s", err) 175 return netClass, fmt.Errorf("error obtaining net class info: %s", err)
diff --git a/collector/pressure_linux.go b/collector/pressure_linux.go
index 90b20f8..df8c266 100644
--- a/collector/pressure_linux.go
+++ b/collector/pressure_linux.go
@@ -82,7 +82,7 @@ func NewPressureStatsCollector() (Collector, error) {
82func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error { 82func (c *pressureStatsCollector) Update(ch chan<- prometheus.Metric) error {
83 for _, res := range psiResources { 83 for _, res := range psiResources {
84 log.Debugf("collecting statistics for resource: %s", res) 84 log.Debugf("collecting statistics for resource: %s", res)
85 vals, err := c.fs.NewPSIStatsForResource(res) 85 vals, err := c.fs.PSIStatsForResource(res)
86 if err != nil { 86 if err != nil {
87 log.Debug("pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel") 87 log.Debug("pressure information is unavailable, you need a Linux kernel >= 4.20 and/or CONFIG_PSI enabled for your kernel")
88 return nil 88 return nil
diff --git a/collector/processes_linux.go b/collector/processes_linux.go
index 9b171ac..52a47df 100644
--- a/collector/processes_linux.go
+++ b/collector/processes_linux.go
@@ -105,7 +105,7 @@ func (c *processCollector) getAllocatedThreads() (int, map[string]int32, int, er
105 thread := 0 105 thread := 0
106 procStates := make(map[string]int32) 106 procStates := make(map[string]int32)
107 for _, pid := range p { 107 for _, pid := range p {
108 stat, err := pid.NewStat() 108 stat, err := pid.Stat()
109 // PIDs can vanish between getting the list and getting stats. 109 // PIDs can vanish between getting the list and getting stats.
110 if os.IsNotExist(err) { 110 if os.IsNotExist(err) {
111 log.Debugf("file not found when retrieving stats for pid %v: %q", pid, err) 111 log.Debugf("file not found when retrieving stats for pid %v: %q", pid, err)
diff --git a/collector/stat_linux.go b/collector/stat_linux.go
index 13a4b01..cd79e38 100644
--- a/collector/stat_linux.go
+++ b/collector/stat_linux.go
@@ -80,7 +80,7 @@ func NewStatCollector() (Collector, error) {
80 80
81// Update implements Collector and exposes kernel and system statistics. 81// Update implements Collector and exposes kernel and system statistics.
82func (c *statCollector) Update(ch chan<- prometheus.Metric) error { 82func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
83 stats, err := c.fs.NewStat() 83 stats, err := c.fs.Stat()
84 if err != nil { 84 if err != nil {
85 return err 85 return err
86 } 86 }
diff --git a/go.mod b/go.mod
index cda7bdb..717ee8e 100644
--- a/go.mod
+++ b/go.mod
@@ -18,7 +18,7 @@ require (
18 github.com/prometheus/client_golang v0.9.2 18 github.com/prometheus/client_golang v0.9.2
19 github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 19 github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
20 github.com/prometheus/common v0.3.0 20 github.com/prometheus/common v0.3.0
21 github.com/prometheus/procfs v0.0.0-20190529155944-65bdadfa96ae 21 github.com/prometheus/procfs v0.0.2
22 github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 22 github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745
23 github.com/sirupsen/logrus v1.4.2 // indirect 23 github.com/sirupsen/logrus v1.4.2 // indirect
24 github.com/soundcloud/go-runit v0.0.0-20150630195641-06ad41a06c4a 24 github.com/soundcloud/go-runit v0.0.0-20150630195641-06ad41a06c4a
diff --git a/go.sum b/go.sum
index dbd4c61..e96c2ec 100644
--- a/go.sum
+++ b/go.sum
@@ -65,8 +65,8 @@ github.com/prometheus/common v0.3.0 h1:taZ4h8Tkxv2kNyoSctBvfXEHmBmxrwmIidZTIaHon
65github.com/prometheus/common v0.3.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 65github.com/prometheus/common v0.3.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
66github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 66github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
67github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 67github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
68github.com/prometheus/procfs v0.0.0-20190529155944-65bdadfa96ae h1:kF6Y/ES9NQmW3t400V0XH+lO1jqvCpXBC1XoLDkvuMM= 68github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
69github.com/prometheus/procfs v0.0.0-20190529155944-65bdadfa96ae/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 69github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
70github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 h1:IuH7WumZNax0D+rEqmy2TyhKCzrtMGqbZO0b8rO00JA= 70github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745 h1:IuH7WumZNax0D+rEqmy2TyhKCzrtMGqbZO0b8rO00JA=
71github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745/go.mod h1:G81aIFAMS9ECrwBYR9YxhlPjWgrItd+Kje78O6+uqm8= 71github.com/siebenmann/go-kstat v0.0.0-20160321171754-d34789b79745/go.mod h1:G81aIFAMS9ECrwBYR9YxhlPjWgrItd+Kje78O6+uqm8=
72github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 72github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
diff --git a/node_exporter_test.go b/node_exporter_test.go
index a0881e9..f10db7c 100644
--- a/node_exporter_test.go
+++ b/node_exporter_test.go
@@ -38,9 +38,13 @@ func TestFileDescriptorLeak(t *testing.T) {
38 if _, err := os.Stat(binary); err != nil { 38 if _, err := os.Stat(binary); err != nil {
39 t.Skipf("node_exporter binary not available, try to run `make build` first: %s", err) 39 t.Skipf("node_exporter binary not available, try to run `make build` first: %s", err)
40 } 40 }
41 if _, err := procfs.NewStat(); err != nil { 41 fs, err := procfs.NewDefaultFS()
42 if err != nil {
42 t.Skipf("proc filesystem is not available, but currently required to read number of open file descriptors: %s", err) 43 t.Skipf("proc filesystem is not available, but currently required to read number of open file descriptors: %s", err)
43 } 44 }
45 if _, err := fs.Stat(); err != nil {
46 t.Errorf("unable to read process stats: %s", err)
47 }
44 48
45 exporter := exec.Command(binary, "--web.listen-address", address) 49 exporter := exec.Command(binary, "--web.listen-address", address)
46 test := func(pid int) error { 50 test := func(pid int) error {
diff --git a/vendor/github.com/prometheus/procfs/README.md b/vendor/github.com/prometheus/procfs/README.md
index 951c043..6f8850f 100644
--- a/vendor/github.com/prometheus/procfs/README.md
+++ b/vendor/github.com/prometheus/procfs/README.md
@@ -19,7 +19,14 @@ point is initialized, and then the stat information is read.
19 19
20```go 20```go
21fs, err := procfs.NewFS("/proc") 21fs, err := procfs.NewFS("/proc")
22stats, err := fs.NewStat() 22stats, err := fs.Stat()
23```
24
25Some sub-packages such as `blockdevice`, require access to both the proc and sys filesystems.
26
27```go
28 fs, err := blockdevice.NewFS("/proc", "/sys")
29 stats, err := fs.ProcDiskstats()
23``` 30```
24 31
25## Building and Testing 32## Building and Testing
@@ -30,7 +37,7 @@ changes to the library, the `make test` command can be used to run the API test
30### Updating Test Fixtures 37### Updating Test Fixtures
31 38
32The procfs library includes a set of test fixtures which include many example files from 39The procfs library includes a set of test fixtures which include many example files from
33the `/proc` and `/sys` filesystems. These fixtures are included as a ttar (text tar) file 40the `/proc` and `/sys` filesystems. These fixtures are included as a [ttar](https://github.com/ideaship/ttar) file
34which is extracted automatically during testing. To add/update the test fixtures, first 41which is extracted automatically during testing. To add/update the test fixtures, first
35ensure the `fixtures` directory is up to date by removing the existing directory and then 42ensure the `fixtures` directory is up to date by removing the existing directory and then
36extracting the ttar file using `make fixtures/.unpacked` or just `make test`. 43extracting the ttar file using `make fixtures/.unpacked` or just `make test`.
diff --git a/vendor/github.com/prometheus/procfs/bcache/get.go b/vendor/github.com/prometheus/procfs/bcache/get.go
index 8d404bd..a8896bd 100644
--- a/vendor/github.com/prometheus/procfs/bcache/get.go
+++ b/vendor/github.com/prometheus/procfs/bcache/get.go
@@ -32,6 +32,12 @@ type FS struct {
32 sys *fs.FS 32 sys *fs.FS
33} 33}
34 34
35// NewDefaultFS returns a new Bcache using the default sys fs mount point. It will error
36// if the mount point can't be read.
37func NewDefaultFS() (FS, error) {
38 return NewFS(fs.DefaultSysMountPoint)
39}
40
35// NewFS returns a new Bcache using the given sys fs mount point. It will error 41// NewFS returns a new Bcache using the given sys fs mount point. It will error
36// if the mount point can't be read. 42// if the mount point can't be read.
37func NewFS(mountPoint string) (FS, error) { 43func NewFS(mountPoint string) (FS, error) {
diff --git a/vendor/github.com/prometheus/procfs/buddyinfo.go b/vendor/github.com/prometheus/procfs/buddyinfo.go
index 5cd22a8..63d4229 100644
--- a/vendor/github.com/prometheus/procfs/buddyinfo.go
+++ b/vendor/github.com/prometheus/procfs/buddyinfo.go
@@ -31,18 +31,8 @@ type BuddyInfo struct {
31 Sizes []float64 31 Sizes []float64
32} 32}
33 33
34// NewBuddyInfo reads the buddyinfo statistics.
35func NewBuddyInfo() ([]BuddyInfo, error) {
36 fs, err := NewFS(DefaultMountPoint)
37 if err != nil {
38 return nil, err
39 }
40
41 return fs.NewBuddyInfo()
42}
43
44// NewBuddyInfo reads the buddyinfo statistics from the specified `proc` filesystem. 34// NewBuddyInfo reads the buddyinfo statistics from the specified `proc` filesystem.
45func (fs FS) NewBuddyInfo() ([]BuddyInfo, error) { 35func (fs FS) BuddyInfo() ([]BuddyInfo, error) {
46 file, err := os.Open(fs.proc.Path("buddyinfo")) 36 file, err := os.Open(fs.proc.Path("buddyinfo"))
47 if err != nil { 37 if err != nil {
48 return nil, err 38 return nil, err
diff --git a/vendor/github.com/prometheus/procfs/fs.go b/vendor/github.com/prometheus/procfs/fs.go
index 5b4a1f0..0102ab0 100644
--- a/vendor/github.com/prometheus/procfs/fs.go
+++ b/vendor/github.com/prometheus/procfs/fs.go
@@ -26,6 +26,12 @@ type FS struct {
26// DefaultMountPoint is the common mount point of the proc filesystem. 26// DefaultMountPoint is the common mount point of the proc filesystem.
27const DefaultMountPoint = fs.DefaultProcMountPoint 27const DefaultMountPoint = fs.DefaultProcMountPoint
28 28
29// NewDefaultFS returns a new proc FS mounted under the default proc mountPoint.
30// It will error if the mount point directory can't be read or is a file.
31func NewDefaultFS() (FS, error) {
32 return NewFS(DefaultMountPoint)
33}
34
29// NewFS returns a new proc FS mounted under the given proc mountPoint. It will error 35// NewFS returns a new proc FS mounted under the given proc mountPoint. It will error
30// if the mount point directory can't be read or is a file. 36// if the mount point directory can't be read or is a file.
31func NewFS(mountPoint string) (FS, error) { 37func NewFS(mountPoint string) (FS, error) {
diff --git a/vendor/github.com/prometheus/procfs/ipvs.go b/vendor/github.com/prometheus/procfs/ipvs.go
index 41e645d..2d6cb8d 100644
--- a/vendor/github.com/prometheus/procfs/ipvs.go
+++ b/vendor/github.com/prometheus/procfs/ipvs.go
@@ -62,18 +62,8 @@ type IPVSBackendStatus struct {
62 Weight uint64 62 Weight uint64
63} 63}
64 64
65// NewIPVSStats reads the IPVS statistics. 65// IPVSStats reads the IPVS statistics from the specified `proc` filesystem.
66func NewIPVSStats() (IPVSStats, error) { 66func (fs FS) IPVSStats() (IPVSStats, error) {
67 fs, err := NewFS(DefaultMountPoint)
68 if err != nil {
69 return IPVSStats{}, err
70 }
71
72 return fs.NewIPVSStats()
73}
74
75// NewIPVSStats reads the IPVS statistics from the specified `proc` filesystem.
76func (fs FS) NewIPVSStats() (IPVSStats, error) {
77 file, err := os.Open(fs.proc.Path("net/ip_vs_stats")) 67 file, err := os.Open(fs.proc.Path("net/ip_vs_stats"))
78 if err != nil { 68 if err != nil {
79 return IPVSStats{}, err 69 return IPVSStats{}, err
@@ -131,18 +121,8 @@ func parseIPVSStats(file io.Reader) (IPVSStats, error) {
131 return stats, nil 121 return stats, nil
132} 122}
133 123
134// NewIPVSBackendStatus reads and returns the status of all (virtual,real) server pairs. 124// IPVSBackendStatus reads and returns the status of all (virtual,real) server pairs from the specified `proc` filesystem.
135func NewIPVSBackendStatus() ([]IPVSBackendStatus, error) { 125func (fs FS) IPVSBackendStatus() ([]IPVSBackendStatus, error) {
136 fs, err := NewFS(DefaultMountPoint)
137 if err != nil {
138 return []IPVSBackendStatus{}, err
139 }
140
141 return fs.NewIPVSBackendStatus()
142}
143
144// NewIPVSBackendStatus reads and returns the status of all (virtual,real) server pairs from the specified `proc` filesystem.
145func (fs FS) NewIPVSBackendStatus() ([]IPVSBackendStatus, error) {
146 file, err := os.Open(fs.proc.Path("net/ip_vs")) 126 file, err := os.Open(fs.proc.Path("net/ip_vs"))
147 if err != nil { 127 if err != nil {
148 return nil, err 128 return nil, err
diff --git a/vendor/github.com/prometheus/procfs/mdstat.go b/vendor/github.com/prometheus/procfs/mdstat.go
index 6ac7a12..71c1067 100644
--- a/vendor/github.com/prometheus/procfs/mdstat.go
+++ b/vendor/github.com/prometheus/procfs/mdstat.go
@@ -42,64 +42,64 @@ type MDStat struct {
42 BlocksSynced int64 42 BlocksSynced int64
43} 43}
44 44
45// ParseMDStat parses an mdstat-file and returns a struct with the relevant infos. 45// MDStat parses an mdstat-file (/proc/mdstat) and returns a slice of
46func (fs FS) ParseMDStat() (mdstates []MDStat, err error) { 46// structs containing the relevant info. More information available here:
47 mdStatusFilePath := fs.proc.Path("mdstat") 47// https://raid.wiki.kernel.org/index.php/Mdstat
48 content, err := ioutil.ReadFile(mdStatusFilePath) 48func (fs FS) MDStat() ([]MDStat, error) {
49 data, err := ioutil.ReadFile(fs.proc.Path("mdstat"))
49 if err != nil { 50 if err != nil {
50 return []MDStat{}, fmt.Errorf("error parsing %s: %s", mdStatusFilePath, err) 51 return nil, fmt.Errorf("error parsing mdstat %s: %s", fs.proc.Path("mdstat"), err)
51 } 52 }
53 mdstat, err := parseMDStat(data)
54 if err != nil {
55 return nil, fmt.Errorf("error parsing mdstat %s: %s", fs.proc.Path("mdstat"), err)
56 }
57 return mdstat, nil
58}
52 59
53 mdStates := []MDStat{} 60// parseMDStat parses data from mdstat file (/proc/mdstat) and returns a slice of
54 lines := strings.Split(string(content), "\n") 61// structs containing the relevant info.
62func parseMDStat(mdstatData []byte) ([]MDStat, error) {
63 mdStats := []MDStat{}
64 lines := strings.Split(string(mdstatData), "\n")
55 for i, l := range lines { 65 for i, l := range lines {
56 if l == "" { 66 if strings.TrimSpace(l) == "" || l[0] == ' ' ||
57 continue 67 strings.HasPrefix(l, "Personalities") || strings.HasPrefix(l, "unused") {
58 }
59 if l[0] == ' ' {
60 continue
61 }
62 if strings.HasPrefix(l, "Personalities") || strings.HasPrefix(l, "unused") {
63 continue 68 continue
64 } 69 }
65 70
66 mainLine := strings.Split(l, " ") 71 deviceFields := strings.Fields(l)
67 if len(mainLine) < 3 { 72 if len(deviceFields) < 3 {
68 return mdStates, fmt.Errorf("error parsing mdline: %s", l) 73 return nil, fmt.Errorf("not enough fields in mdline (expected at least 3): %s", l)
69 } 74 }
70 mdName := mainLine[0] 75 mdName := deviceFields[0]
71 activityState := mainLine[2] 76 activityState := deviceFields[2]
72 77
73 if len(lines) <= i+3 { 78 if len(lines) <= i+3 {
74 return mdStates, fmt.Errorf( 79 return mdStats, fmt.Errorf("missing lines for md device %s", mdName)
75 "error parsing %s: too few lines for md device %s",
76 mdStatusFilePath,
77 mdName,
78 )
79 } 80 }
80 81
81 active, total, size, err := evalStatusline(lines[i+1]) 82 active, total, size, err := evalStatusLine(lines[i+1])
82 if err != nil { 83 if err != nil {
83 return mdStates, fmt.Errorf("error parsing %s: %s", mdStatusFilePath, err) 84 return nil, err
84 } 85 }
85 86
86 // j is the line number of the syncing-line. 87 syncLineIdx := i + 2
87 j := i + 2
88 if strings.Contains(lines[i+2], "bitmap") { // skip bitmap line 88 if strings.Contains(lines[i+2], "bitmap") { // skip bitmap line
89 j = i + 3 89 syncLineIdx++
90 } 90 }
91 91
92 // If device is syncing at the moment, get the number of currently 92 // If device is recovering/syncing at the moment, get the number of currently
93 // synced bytes, otherwise that number equals the size of the device. 93 // synced bytes, otherwise that number equals the size of the device.
94 syncedBlocks := size 94 syncedBlocks := size
95 if strings.Contains(lines[j], "recovery") || strings.Contains(lines[j], "resync") { 95 if strings.Contains(lines[syncLineIdx], "recovery") || strings.Contains(lines[syncLineIdx], "resync") {
96 syncedBlocks, err = evalBuildline(lines[j]) 96 syncedBlocks, err = evalRecoveryLine(lines[syncLineIdx])
97 if err != nil { 97 if err != nil {
98 return mdStates, fmt.Errorf("error parsing %s: %s", mdStatusFilePath, err) 98 return nil, err
99 } 99 }
100 } 100 }
101 101
102 mdStates = append(mdStates, MDStat{ 102 mdStats = append(mdStats, MDStat{
103 Name: mdName, 103 Name: mdName,
104 ActivityState: activityState, 104 ActivityState: activityState,
105 DisksActive: active, 105 DisksActive: active,
@@ -109,10 +109,10 @@ func (fs FS) ParseMDStat() (mdstates []MDStat, err error) {
109 }) 109 })
110 } 110 }
111 111
112 return mdStates, nil 112 return mdStats, nil
113} 113}
114 114
115func evalStatusline(statusline string) (active, total, size int64, err error) { 115func evalStatusLine(statusline string) (active, total, size int64, err error) {
116 matches := statuslineRE.FindStringSubmatch(statusline) 116 matches := statuslineRE.FindStringSubmatch(statusline)
117 if len(matches) != 4 { 117 if len(matches) != 4 {
118 return 0, 0, 0, fmt.Errorf("unexpected statusline: %s", statusline) 118 return 0, 0, 0, fmt.Errorf("unexpected statusline: %s", statusline)
@@ -136,7 +136,7 @@ func evalStatusline(statusline string) (active, total, size int64, err error) {
136 return active, total, size, nil 136 return active, total, size, nil
137} 137}
138 138
139func evalBuildline(buildline string) (syncedBlocks int64, err error) { 139func evalRecoveryLine(buildline string) (syncedBlocks int64, err error) {
140 matches := buildlineRE.FindStringSubmatch(buildline) 140 matches := buildlineRE.FindStringSubmatch(buildline)
141 if len(matches) != 2 { 141 if len(matches) != 2 {
142 return 0, fmt.Errorf("unexpected buildline: %s", buildline) 142 return 0, fmt.Errorf("unexpected buildline: %s", buildline)
diff --git a/vendor/github.com/prometheus/procfs/net_dev.go b/vendor/github.com/prometheus/procfs/net_dev.go
index 8249c98..a0b7a01 100644
--- a/vendor/github.com/prometheus/procfs/net_dev.go
+++ b/vendor/github.com/prometheus/procfs/net_dev.go
@@ -47,23 +47,13 @@ type NetDevLine struct {
47// are interface names. 47// are interface names.
48type NetDev map[string]NetDevLine 48type NetDev map[string]NetDevLine
49 49
50// NewNetDev returns kernel/system statistics read from /proc/net/dev. 50// NetDev returns kernel/system statistics read from /proc/net/dev.
51func NewNetDev() (NetDev, error) { 51func (fs FS) NetDev() (NetDev, error) {
52 fs, err := NewFS(DefaultMountPoint)
53 if err != nil {
54 return nil, err
55 }
56
57 return fs.NewNetDev()
58}
59
60// NewNetDev returns kernel/system statistics read from /proc/net/dev.
61func (fs FS) NewNetDev() (NetDev, error) {
62 return newNetDev(fs.proc.Path("net/dev")) 52 return newNetDev(fs.proc.Path("net/dev"))
63} 53}
64 54
65// NewNetDev returns kernel/system statistics read from /proc/[pid]/net/dev. 55// NetDev returns kernel/system statistics read from /proc/[pid]/net/dev.
66func (p Proc) NewNetDev() (NetDev, error) { 56func (p Proc) NetDev() (NetDev, error) {
67 return newNetDev(p.path("net/dev")) 57 return newNetDev(p.path("net/dev"))
68} 58}
69 59
diff --git a/vendor/github.com/prometheus/procfs/nfs/nfs.go b/vendor/github.com/prometheus/procfs/nfs/nfs.go
index 7ee262f..96e69ca 100644
--- a/vendor/github.com/prometheus/procfs/nfs/nfs.go
+++ b/vendor/github.com/prometheus/procfs/nfs/nfs.go
@@ -275,6 +275,12 @@ type FS struct {
275 proc *fs.FS 275 proc *fs.FS
276} 276}
277 277
278// NewDefaultFS returns a new FS mounted under the default mountPoint. It will error
279// if the mount point can't be read.
280func NewDefaultFS() (FS, error) {
281 return NewFS(fs.DefaultProcMountPoint)
282}
283
278// NewFS returns a new FS mounted under the given mountPoint. It will error 284// NewFS returns a new FS mounted under the given mountPoint. It will error
279// if the mount point can't be read. 285// if the mount point can't be read.
280func NewFS(mountPoint string) (FS, error) { 286func NewFS(mountPoint string) (FS, error) {
diff --git a/vendor/github.com/prometheus/procfs/proc.go b/vendor/github.com/prometheus/procfs/proc.go
index 8e38493..8a84301 100644
--- a/vendor/github.com/prometheus/procfs/proc.go
+++ b/vendor/github.com/prometheus/procfs/proc.go
@@ -54,7 +54,7 @@ func NewProc(pid int) (Proc, error) {
54 if err != nil { 54 if err != nil {
55 return Proc{}, err 55 return Proc{}, err
56 } 56 }
57 return fs.NewProc(pid) 57 return fs.Proc(pid)
58} 58}
59 59
60// AllProcs returns a list of all currently available processes under /proc. 60// AllProcs returns a list of all currently available processes under /proc.
@@ -76,11 +76,18 @@ func (fs FS) Self() (Proc, error) {
76 if err != nil { 76 if err != nil {
77 return Proc{}, err 77 return Proc{}, err
78 } 78 }
79 return fs.NewProc(pid) 79 return fs.Proc(pid)
80} 80}
81 81
82// NewProc returns a process for the given pid. 82// NewProc returns a process for the given pid.
83//
84// Deprecated: use fs.Proc() instead
83func (fs FS) NewProc(pid int) (Proc, error) { 85func (fs FS) NewProc(pid int) (Proc, error) {
86 return fs.Proc(pid)
87}
88
89// Proc returns a process for the given pid.
90func (fs FS) Proc(pid int) (Proc, error) {
84 if _, err := os.Stat(fs.proc.Path(strconv.Itoa(pid))); err != nil { 91 if _, err := os.Stat(fs.proc.Path(strconv.Itoa(pid))); err != nil {
85 return Proc{}, err 92 return Proc{}, err
86 } 93 }
diff --git a/vendor/github.com/prometheus/procfs/proc_io.go b/vendor/github.com/prometheus/procfs/proc_io.go
index 0251c83..0ff89b1 100644
--- a/vendor/github.com/prometheus/procfs/proc_io.go
+++ b/vendor/github.com/prometheus/procfs/proc_io.go
@@ -39,8 +39,8 @@ type ProcIO struct {
39 CancelledWriteBytes int64 39 CancelledWriteBytes int64
40} 40}
41 41
42// NewIO creates a new ProcIO instance from a given Proc instance. 42// IO creates a new ProcIO instance from a given Proc instance.
43func (p Proc) NewIO() (ProcIO, error) { 43func (p Proc) IO() (ProcIO, error) {
44 pio := ProcIO{} 44 pio := ProcIO{}
45 45
46 f, err := os.Open(p.path("io")) 46 f, err := os.Open(p.path("io"))
diff --git a/vendor/github.com/prometheus/procfs/proc_limits.go b/vendor/github.com/prometheus/procfs/proc_limits.go
index f04ba6f..91ee24d 100644
--- a/vendor/github.com/prometheus/procfs/proc_limits.go
+++ b/vendor/github.com/prometheus/procfs/proc_limits.go
@@ -78,7 +78,14 @@ var (
78) 78)
79 79
80// NewLimits returns the current soft limits of the process. 80// NewLimits returns the current soft limits of the process.
81//
82// Deprecated: use p.Limits() instead
81func (p Proc) NewLimits() (ProcLimits, error) { 83func (p Proc) NewLimits() (ProcLimits, error) {
84 return p.Limits()
85}
86
87// Limits returns the current soft limits of the process.
88func (p Proc) Limits() (ProcLimits, error) {
82 f, err := os.Open(p.path("limits")) 89 f, err := os.Open(p.path("limits"))
83 if err != nil { 90 if err != nil {
84 return ProcLimits{}, err 91 return ProcLimits{}, err
diff --git a/vendor/github.com/prometheus/procfs/proc_ns.go b/vendor/github.com/prometheus/procfs/proc_ns.go
index 3f8d6d6..c66740f 100644
--- a/vendor/github.com/prometheus/procfs/proc_ns.go
+++ b/vendor/github.com/prometheus/procfs/proc_ns.go
@@ -29,9 +29,9 @@ type Namespace struct {
29// Namespaces contains all of the namespaces that the process is contained in. 29// Namespaces contains all of the namespaces that the process is contained in.
30type Namespaces map[string]Namespace 30type Namespaces map[string]Namespace
31 31
32// NewNamespaces reads from /proc/<pid>/ns/* to get the namespaces of which the 32// Namespaces reads from /proc/<pid>/ns/* to get the namespaces of which the
33// process is a member. 33// process is a member.
34func (p Proc) NewNamespaces() (Namespaces, error) { 34func (p Proc) Namespaces() (Namespaces, error) {
35 d, err := os.Open(p.path("ns")) 35 d, err := os.Open(p.path("ns"))
36 if err != nil { 36 if err != nil {
37 return nil, err 37 return nil, err
diff --git a/vendor/github.com/prometheus/procfs/proc_psi.go b/vendor/github.com/prometheus/procfs/proc_psi.go
index a23d4c0..46fe266 100644
--- a/vendor/github.com/prometheus/procfs/proc_psi.go
+++ b/vendor/github.com/prometheus/procfs/proc_psi.go
@@ -51,19 +51,10 @@ type PSIStats struct {
51 Full *PSILine 51 Full *PSILine
52} 52}
53 53
54// NewPSIStatsForResource reads pressure stall information for the specified 54// PSIStatsForResource reads pressure stall information for the specified
55// resource. At time of writing this can be either "cpu", "memory" or "io". 55// resource from /proc/pressure/<resource>. At time of writing this can be
56func NewPSIStatsForResource(resource string) (PSIStats, error) { 56// either "cpu", "memory" or "io".
57 fs, err := NewFS(DefaultMountPoint) 57func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) {
58 if err != nil {
59 return PSIStats{}, err
60 }
61
62 return fs.NewPSIStatsForResource(resource)
63}
64
65// NewPSIStatsForResource reads pressure stall information from /proc/pressure/<resource>
66func (fs FS) NewPSIStatsForResource(resource string) (PSIStats, error) {
67 file, err := os.Open(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource))) 58 file, err := os.Open(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource)))
68 if err != nil { 59 if err != nil {
69 return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %s", resource) 60 return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %s", resource)
diff --git a/vendor/github.com/prometheus/procfs/proc_stat.go b/vendor/github.com/prometheus/procfs/proc_stat.go
index 4c8b03c..6ed98a8 100644
--- a/vendor/github.com/prometheus/procfs/proc_stat.go
+++ b/vendor/github.com/prometheus/procfs/proc_stat.go
@@ -105,7 +105,14 @@ type ProcStat struct {
105} 105}
106 106
107// NewStat returns the current status information of the process. 107// NewStat returns the current status information of the process.
108//
109// Deprecated: use NewStat() instead
108func (p Proc) NewStat() (ProcStat, error) { 110func (p Proc) NewStat() (ProcStat, error) {
111 return p.Stat()
112}
113
114// Stat returns the current status information of the process.
115func (p Proc) Stat() (ProcStat, error) {
109 f, err := os.Open(p.path("stat")) 116 f, err := os.Open(p.path("stat"))
110 if err != nil { 117 if err != nil {
111 return ProcStat{}, err 118 return ProcStat{}, err
@@ -178,7 +185,7 @@ func (s ProcStat) ResidentMemory() int {
178// StartTime returns the unix timestamp of the process in seconds. 185// StartTime returns the unix timestamp of the process in seconds.
179func (s ProcStat) StartTime() (float64, error) { 186func (s ProcStat) StartTime() (float64, error) {
180 fs := FS{proc: s.proc} 187 fs := FS{proc: s.proc}
181 stat, err := fs.NewStat() 188 stat, err := fs.Stat()
182 if err != nil { 189 if err != nil {
183 return 0, err 190 return 0, err
184 } 191 }
diff --git a/vendor/github.com/prometheus/procfs/stat.go b/vendor/github.com/prometheus/procfs/stat.go
index 44c9af1..6661ee0 100644
--- a/vendor/github.com/prometheus/procfs/stat.go
+++ b/vendor/github.com/prometheus/procfs/stat.go
@@ -20,6 +20,8 @@ import (
20 "os" 20 "os"
21 "strconv" 21 "strconv"
22 "strings" 22 "strings"
23
24 "github.com/prometheus/procfs/internal/fs"
23) 25)
24 26
25// CPUStat shows how much time the cpu spend in various stages. 27// CPUStat shows how much time the cpu spend in various stages.
@@ -78,16 +80,6 @@ type Stat struct {
78 SoftIRQ SoftIRQStat 80 SoftIRQ SoftIRQStat
79} 81}
80 82
81// NewStat returns kernel/system statistics read from /proc/stat.
82func NewStat() (Stat, error) {
83 fs, err := NewFS(DefaultMountPoint)
84 if err != nil {
85 return Stat{}, err
86 }
87
88 return fs.NewStat()
89}
90
91// Parse a cpu statistics line and returns the CPUStat struct plus the cpu id (or -1 for the overall sum). 83// Parse a cpu statistics line and returns the CPUStat struct plus the cpu id (or -1 for the overall sum).
92func parseCPUStat(line string) (CPUStat, int64, error) { 84func parseCPUStat(line string) (CPUStat, int64, error) {
93 cpuStat := CPUStat{} 85 cpuStat := CPUStat{}
@@ -149,9 +141,29 @@ func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error) {
149 return softIRQStat, total, nil 141 return softIRQStat, total, nil
150} 142}
151 143
152// NewStat returns an information about current kernel/system statistics. 144// NewStat returns information about current cpu/process statistics.
145// See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
146//
147// Deprecated: use fs.Stat() instead
148func NewStat() (Stat, error) {
149 fs, err := NewFS(fs.DefaultProcMountPoint)
150 if err != nil {
151 return Stat{}, err
152 }
153 return fs.Stat()
154}
155
156// NewStat returns information about current cpu/process statistics.
157// See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
158//
159// Deprecated: use fs.Stat() instead
153func (fs FS) NewStat() (Stat, error) { 160func (fs FS) NewStat() (Stat, error) {
154 // See https://www.kernel.org/doc/Documentation/filesystems/proc.txt 161 return fs.Stat()
162}
163
164// Stat returns information about current cpu/process statistics.
165// See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
166func (fs FS) Stat() (Stat, error) {
155 167
156 f, err := os.Open(fs.proc.Path("stat")) 168 f, err := os.Open(fs.proc.Path("stat"))
157 if err != nil { 169 if err != nil {
diff --git a/vendor/github.com/prometheus/procfs/sysfs/class_power_supply.go b/vendor/github.com/prometheus/procfs/sysfs/class_power_supply.go
index 64720ef..90c32e5 100644
--- a/vendor/github.com/prometheus/procfs/sysfs/class_power_supply.go
+++ b/vendor/github.com/prometheus/procfs/sysfs/class_power_supply.go
@@ -102,18 +102,8 @@ type PowerSupply struct {
102// The map keys are the names of the power supplies. 102// The map keys are the names of the power supplies.
103type PowerSupplyClass map[string]PowerSupply 103type PowerSupplyClass map[string]PowerSupply
104 104
105// NewPowerSupplyClass returns info for all power supplies read from /sys/class/power_supply/. 105// PowerSupplyClass returns info for all power supplies read from /sys/class/power_supply/.
106func NewPowerSupplyClass() (PowerSupplyClass, error) { 106func (fs FS) PowerSupplyClass() (PowerSupplyClass, error) {
107 fs, err := NewFS(DefaultMountPoint)
108 if err != nil {
109 return nil, err
110 }
111
112 return fs.NewPowerSupplyClass()
113}
114
115// NewPowerSupplyClass returns info for all power supplies read from /sys/class/power_supply/.
116func (fs FS) NewPowerSupplyClass() (PowerSupplyClass, error) {
117 path := fs.sys.Path("class/power_supply") 107 path := fs.sys.Path("class/power_supply")
118 108
119 powerSupplyDirs, err := ioutil.ReadDir(path) 109 powerSupplyDirs, err := ioutil.ReadDir(path)
diff --git a/vendor/github.com/prometheus/procfs/sysfs/class_thermal.go b/vendor/github.com/prometheus/procfs/sysfs/class_thermal.go
index 2d70795..cfe11ad 100644
--- a/vendor/github.com/prometheus/procfs/sysfs/class_thermal.go
+++ b/vendor/github.com/prometheus/procfs/sysfs/class_thermal.go
@@ -35,8 +35,8 @@ type ClassThermalZoneStats struct {
35 Passive *uint64 // Optional: millidegrees Celsius. (0 for disabled, > 1000 for enabled+value) 35 Passive *uint64 // Optional: millidegrees Celsius. (0 for disabled, > 1000 for enabled+value)
36} 36}
37 37
38// NewClassThermalZoneStats returns Thermal Zone metrics for all zones. 38// ClassThermalZoneStats returns Thermal Zone metrics for all zones.
39func (fs FS) NewClassThermalZoneStats() ([]ClassThermalZoneStats, error) { 39func (fs FS) ClassThermalZoneStats() ([]ClassThermalZoneStats, error) {
40 zones, err := filepath.Glob(fs.sys.Path("class/thermal/thermal_zone[0-9]*")) 40 zones, err := filepath.Glob(fs.sys.Path("class/thermal/thermal_zone[0-9]*"))
41 if err != nil { 41 if err != nil {
42 return []ClassThermalZoneStats{}, err 42 return []ClassThermalZoneStats{}, err
diff --git a/vendor/github.com/prometheus/procfs/sysfs/fs.go b/vendor/github.com/prometheus/procfs/sysfs/fs.go
index c0cb9b6..b3354f3 100644
--- a/vendor/github.com/prometheus/procfs/sysfs/fs.go
+++ b/vendor/github.com/prometheus/procfs/sysfs/fs.go
@@ -26,6 +26,12 @@ type FS struct {
26// DefaultMountPoint is the common mount point of the sys filesystem. 26// DefaultMountPoint is the common mount point of the sys filesystem.
27const DefaultMountPoint = fs.DefaultSysMountPoint 27const DefaultMountPoint = fs.DefaultSysMountPoint
28 28
29// NewDefaultFS returns a new FS mounted under the default mountPoint. It will error
30// if the mount point can't be read.
31func NewDefaultFS() (FS, error) {
32 return NewFS(DefaultMountPoint)
33}
34
29// NewFS returns a new FS mounted under the given mountPoint. It will error 35// NewFS returns a new FS mounted under the given mountPoint. It will error
30// if the mount point can't be read. 36// if the mount point can't be read.
31func NewFS(mountPoint string) (FS, error) { 37func NewFS(mountPoint string) (FS, error) {
diff --git a/vendor/github.com/prometheus/procfs/sysfs/net_class.go b/vendor/github.com/prometheus/procfs/sysfs/net_class.go
index c28051e..909f7fb 100644
--- a/vendor/github.com/prometheus/procfs/sysfs/net_class.go
+++ b/vendor/github.com/prometheus/procfs/sysfs/net_class.go
@@ -65,16 +65,6 @@ type NetClassIface struct {
65// are interface (iface) names. 65// are interface (iface) names.
66type NetClass map[string]NetClassIface 66type NetClass map[string]NetClassIface
67 67
68// NewNetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
69func NewNetClass() (NetClass, error) {
70 fs, err := NewFS(DefaultMountPoint)
71 if err != nil {
72 return nil, err
73 }
74
75 return fs.NewNetClass()
76}
77
78// NetClassDevices scans /sys/class/net for devices and returns them as a list of names. 68// NetClassDevices scans /sys/class/net for devices and returns them as a list of names.
79func (fs FS) NetClassDevices() ([]string, error) { 69func (fs FS) NetClassDevices() ([]string, error) {
80 var res []string 70 var res []string
@@ -95,8 +85,8 @@ func (fs FS) NetClassDevices() ([]string, error) {
95 return res, nil 85 return res, nil
96} 86}
97 87
98// NewNetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>. 88// NetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>.
99func (fs FS) NewNetClass() (NetClass, error) { 89func (fs FS) NetClass() (NetClass, error) {
100 devices, err := fs.NetClassDevices() 90 devices, err := fs.NetClassDevices()
101 if err != nil { 91 if err != nil {
102 return nil, err 92 return nil, err
diff --git a/vendor/github.com/prometheus/procfs/sysfs/system_cpu.go b/vendor/github.com/prometheus/procfs/sysfs/system_cpu.go
index 4bcf86b..001039c 100644
--- a/vendor/github.com/prometheus/procfs/sysfs/system_cpu.go
+++ b/vendor/github.com/prometheus/procfs/sysfs/system_cpu.go
@@ -46,18 +46,8 @@ type SystemCPUCpufreqStats struct {
46 46
47// TODO: Add thermal_throttle support. 47// TODO: Add thermal_throttle support.
48 48
49// NewSystemCpufreq returns CPU frequency metrics for all CPUs. 49// SystemCpufreq returns CPU frequency metrics for all CPUs.
50func NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) { 50func (fs FS) SystemCpufreq() ([]SystemCPUCpufreqStats, error) {
51 fs, err := NewFS(DefaultMountPoint)
52 if err != nil {
53 return []SystemCPUCpufreqStats{}, err
54 }
55
56 return fs.NewSystemCpufreq()
57}
58
59// NewSystemCpufreq returns CPU frequency metrics for all CPUs.
60func (fs FS) NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) {
61 var g errgroup.Group 51 var g errgroup.Group
62 52
63 cpus, err := filepath.Glob(fs.sys.Path("devices/system/cpu/cpu[0-9]*")) 53 cpus, err := filepath.Glob(fs.sys.Path("devices/system/cpu/cpu[0-9]*"))
diff --git a/vendor/github.com/prometheus/procfs/xfs/xfs.go b/vendor/github.com/prometheus/procfs/xfs/xfs.go
index 8a7288f..3aad661 100644
--- a/vendor/github.com/prometheus/procfs/xfs/xfs.go
+++ b/vendor/github.com/prometheus/procfs/xfs/xfs.go
@@ -177,6 +177,12 @@ type FS struct {
177 sys *fs.FS 177 sys *fs.FS
178} 178}
179 179
180// NewDefaultFS returns a new XFS handle using the default proc and sys mountPoints.
181// It will error if either of the mounts point can't be read.
182func NewDefaultFS() (FS, error) {
183 return NewFS(fs.DefaultProcMountPoint, fs.DefaultSysMountPoint)
184}
185
180// NewFS returns a new XFS handle using the given proc and sys mountPoints. It will error 186// NewFS returns a new XFS handle using the given proc and sys mountPoints. It will error
181// if either of the mounts point can't be read. 187// if either of the mounts point can't be read.
182func NewFS(procMountPoint string, sysMountPoint string) (FS, error) { 188func NewFS(procMountPoint string, sysMountPoint string) (FS, error) {
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 86bf4f2..0227700 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -45,7 +45,7 @@ github.com/prometheus/common/version
45github.com/prometheus/common/expfmt 45github.com/prometheus/common/expfmt
46github.com/prometheus/common/model 46github.com/prometheus/common/model
47github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg 47github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
48# github.com/prometheus/procfs v0.0.0-20190529155944-65bdadfa96ae 48# github.com/prometheus/procfs v0.0.2
49github.com/prometheus/procfs 49github.com/prometheus/procfs
50github.com/prometheus/procfs/bcache 50github.com/prometheus/procfs/bcache
51github.com/prometheus/procfs/nfs 51github.com/prometheus/procfs/nfs