diff options
author | Paul Gier <pgier@redhat.com> | 2019-06-12 13:47:16 -0500 |
---|---|---|
committer | Ben Kochie <superq@gmail.com> | 2019-06-12 20:47:16 +0200 |
commit | 2bc133cd486e3af2cc8cb6f8c53a67a82f82a02b (patch) | |
tree | 0a0d5eea739b5463d9ebd7ae2440e7766d557920 /vendor | |
parent | 0759c0ac019f0f5c3c17370f99c5e09fd6d73f07 (diff) | |
download | prometheus_node_collector-2bc133cd486e3af2cc8cb6f8c53a67a82f82a02b.tar.bz2 prometheus_node_collector-2bc133cd486e3af2cc8cb6f8c53a67a82f82a02b.tar.xz prometheus_node_collector-2bc133cd486e3af2cc8cb6f8c53a67a82f82a02b.zip |
update procfs to v0.0.2 (#1376)
Signed-off-by: Paul Gier <pgier@redhat.com>
Diffstat (limited to 'vendor')
22 files changed, 150 insertions, 159 deletions
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 |
21 | fs, err := procfs.NewFS("/proc") | 21 | fs, err := procfs.NewFS("/proc") |
22 | stats, err := fs.NewStat() | 22 | stats, err := fs.Stat() |
23 | ``` | ||
24 | |||
25 | Some 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 | ||
32 | The procfs library includes a set of test fixtures which include many example files from | 39 | The procfs library includes a set of test fixtures which include many example files from |
33 | the `/proc` and `/sys` filesystems. These fixtures are included as a ttar (text tar) file | 40 | the `/proc` and `/sys` filesystems. These fixtures are included as a [ttar](https://github.com/ideaship/ttar) file |
34 | which is extracted automatically during testing. To add/update the test fixtures, first | 41 | which is extracted automatically during testing. To add/update the test fixtures, first |
35 | ensure the `fixtures` directory is up to date by removing the existing directory and then | 42 | ensure the `fixtures` directory is up to date by removing the existing directory and then |
36 | extracting the ttar file using `make fixtures/.unpacked` or just `make test`. | 43 | extracting 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. | ||
37 | func 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. |
37 | func NewFS(mountPoint string) (FS, error) { | 43 | func 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. | ||
35 | func 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. |
45 | func (fs FS) NewBuddyInfo() ([]BuddyInfo, error) { | 35 | func (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. |
27 | const DefaultMountPoint = fs.DefaultProcMountPoint | 27 | const 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. | ||
31 | func 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. |
31 | func NewFS(mountPoint string) (FS, error) { | 37 | func 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. |
66 | func NewIPVSStats() (IPVSStats, error) { | 66 | func (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. | ||
76 | func (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. |
135 | func NewIPVSBackendStatus() ([]IPVSBackendStatus, error) { | 125 | func (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. | ||
145 | func (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 |
46 | func (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) | 48 | func (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. |
62 | func 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 | ||
115 | func evalStatusline(statusline string) (active, total, size int64, err error) { | 115 | func 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 | ||
139 | func evalBuildline(buildline string) (syncedBlocks int64, err error) { | 139 | func 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. |
48 | type NetDev map[string]NetDevLine | 48 | type 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. |
51 | func NewNetDev() (NetDev, error) { | 51 | func (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. | ||
61 | func (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. |
66 | func (p Proc) NewNetDev() (NetDev, error) { | 56 | func (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. | ||
280 | func 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. |
280 | func NewFS(mountPoint string) (FS, error) { | 286 | func 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 | ||
83 | func (fs FS) NewProc(pid int) (Proc, error) { | 85 | func (fs FS) NewProc(pid int) (Proc, error) { |
86 | return fs.Proc(pid) | ||
87 | } | ||
88 | |||
89 | // Proc returns a process for the given pid. | ||
90 | func (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. |
43 | func (p Proc) NewIO() (ProcIO, error) { | 43 | func (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 | ||
81 | func (p Proc) NewLimits() (ProcLimits, error) { | 83 | func (p Proc) NewLimits() (ProcLimits, error) { |
84 | return p.Limits() | ||
85 | } | ||
86 | |||
87 | // Limits returns the current soft limits of the process. | ||
88 | func (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. |
30 | type Namespaces map[string]Namespace | 30 | type 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. |
34 | func (p Proc) NewNamespaces() (Namespaces, error) { | 34 | func (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 |
56 | func NewPSIStatsForResource(resource string) (PSIStats, error) { | 56 | // either "cpu", "memory" or "io". |
57 | fs, err := NewFS(DefaultMountPoint) | 57 | func (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> | ||
66 | func (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 | ||
108 | func (p Proc) NewStat() (ProcStat, error) { | 110 | func (p Proc) NewStat() (ProcStat, error) { |
111 | return p.Stat() | ||
112 | } | ||
113 | |||
114 | // Stat returns the current status information of the process. | ||
115 | func (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. |
179 | func (s ProcStat) StartTime() (float64, error) { | 186 | func (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. | ||
82 | func 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). |
92 | func parseCPUStat(line string) (CPUStat, int64, error) { | 84 | func 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 | ||
148 | func 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 | ||
153 | func (fs FS) NewStat() (Stat, error) { | 160 | func (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 | ||
166 | func (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. |
103 | type PowerSupplyClass map[string]PowerSupply | 103 | type 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/. |
106 | func NewPowerSupplyClass() (PowerSupplyClass, error) { | 106 | func (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/. | ||
116 | func (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. |
39 | func (fs FS) NewClassThermalZoneStats() ([]ClassThermalZoneStats, error) { | 39 | func (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. |
27 | const DefaultMountPoint = fs.DefaultSysMountPoint | 27 | const 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. | ||
31 | func 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. |
31 | func NewFS(mountPoint string) (FS, error) { | 37 | func 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. |
66 | type NetClass map[string]NetClassIface | 66 | type NetClass map[string]NetClassIface |
67 | 67 | ||
68 | // NewNetClass returns info for all net interfaces (iface) read from /sys/class/net/<iface>. | ||
69 | func 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. |
79 | func (fs FS) NetClassDevices() ([]string, error) { | 69 | func (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>. |
99 | func (fs FS) NewNetClass() (NetClass, error) { | 89 | func (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. |
50 | func NewSystemCpufreq() ([]SystemCPUCpufreqStats, error) { | 50 | func (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. | ||
60 | func (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. | ||
182 | func 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. |
182 | func NewFS(procMountPoint string, sysMountPoint string) (FS, error) { | 188 | func 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 | |||
45 | github.com/prometheus/common/expfmt | 45 | github.com/prometheus/common/expfmt |
46 | github.com/prometheus/common/model | 46 | github.com/prometheus/common/model |
47 | github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg | 47 | github.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 |
49 | github.com/prometheus/procfs | 49 | github.com/prometheus/procfs |
50 | github.com/prometheus/procfs/bcache | 50 | github.com/prometheus/procfs/bcache |
51 | github.com/prometheus/procfs/nfs | 51 | github.com/prometheus/procfs/nfs |