File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ import (
2525 "strings"
2626)
2727
28+ var (
29+ reParens = regexp .MustCompile (`\((.*)\)` )
30+ )
31+
2832func (c * meminfoCollector ) getMemInfo () (map [string ]float64 , error ) {
2933 file , err := os .Open (procFilePath ("meminfo" ))
3034 if err != nil {
@@ -39,7 +43,6 @@ func parseMemInfo(r io.Reader) (map[string]float64, error) {
3943 var (
4044 memInfo = map [string ]float64 {}
4145 scanner = bufio .NewScanner (r )
42- re = regexp .MustCompile (`\((.*)\)` )
4346 )
4447
4548 for scanner .Scan () {
@@ -55,7 +58,7 @@ func parseMemInfo(r io.Reader) (map[string]float64, error) {
5558 }
5659 key := parts [0 ][:len (parts [0 ])- 1 ] // remove trailing : from key
5760 // Active(anon) -> Active_anon
58- key = re .ReplaceAllString (key , "_${1}" )
61+ key = reParens .ReplaceAllString (key , "_${1}" )
5962 switch len (parts ) {
6063 case 2 : // no unit
6164 case 3 : // has unit, we presume kB
You can’t perform that action at this time.
0 commit comments