diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-19 03:49:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 03:49:17 -0700 |
commit | c4a551373004219fd2d50e5b055dbc5e233e4e32 (patch) | |
tree | deeb60c8d13ba55ff32512b29a183748ced677cc /vendor/github.com/prometheus/procfs/proc_psi.go | |
parent | 5d9b07096b49877608250c7d51e0ee35b9d502c7 (diff) | |
parent | ec1651fbf11c4d3d1c792e7f46139ebd96f7ffb2 (diff) | |
download | podman-c4a551373004219fd2d50e5b055dbc5e233e4e32.tar.gz podman-c4a551373004219fd2d50e5b055dbc5e233e4e32.tar.bz2 podman-c4a551373004219fd2d50e5b055dbc5e233e4e32.zip |
Merge pull request #9734 from containers/dependabot/go_modules/github.com/containers/storage-1.28.0
Bump github.com/containers/storage from 1.25.0 to 1.28.0
Diffstat (limited to 'vendor/github.com/prometheus/procfs/proc_psi.go')
-rw-r--r-- | vendor/github.com/prometheus/procfs/proc_psi.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/vendor/github.com/prometheus/procfs/proc_psi.go b/vendor/github.com/prometheus/procfs/proc_psi.go index 46fe26626..0d7bee54c 100644 --- a/vendor/github.com/prometheus/procfs/proc_psi.go +++ b/vendor/github.com/prometheus/procfs/proc_psi.go @@ -24,11 +24,13 @@ package procfs // > full avg10=0.00 avg60=0.13 avg300=0.96 total=8183134 import ( + "bufio" + "bytes" "fmt" "io" - "io/ioutil" - "os" "strings" + + "github.com/prometheus/procfs/internal/util" ) const lineFormat = "avg10=%f avg60=%f avg300=%f total=%d" @@ -55,24 +57,21 @@ type PSIStats struct { // resource from /proc/pressure/<resource>. At time of writing this can be // either "cpu", "memory" or "io". func (fs FS) PSIStatsForResource(resource string) (PSIStats, error) { - file, err := os.Open(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource))) + data, err := util.ReadFileNoStat(fs.proc.Path(fmt.Sprintf("%s/%s", "pressure", resource))) if err != nil { return PSIStats{}, fmt.Errorf("psi_stats: unavailable for %s", resource) } - defer file.Close() - return parsePSIStats(resource, file) + return parsePSIStats(resource, bytes.NewReader(data)) } // parsePSIStats parses the specified file for pressure stall information -func parsePSIStats(resource string, file io.Reader) (PSIStats, error) { +func parsePSIStats(resource string, r io.Reader) (PSIStats, error) { psiStats := PSIStats{} - stats, err := ioutil.ReadAll(file) - if err != nil { - return psiStats, fmt.Errorf("psi_stats: unable to read data for %s", resource) - } - for _, l := range strings.Split(string(stats), "\n") { + scanner := bufio.NewScanner(r) + for scanner.Scan() { + l := scanner.Text() prefix := strings.Split(l, " ")[0] switch prefix { case "some": |