@@ -39,9 +39,9 @@ def __init__(self, namespace='', pid=lambda: 'self', proc='/proc', registry=core
3939 registry .register (self )
4040
4141 def _boot_time (self ):
42- with open (os .path .join (self ._proc , 'stat' )) as stat :
42+ with open (os .path .join (self ._proc , 'stat' ), 'rb' ) as stat :
4343 for line in stat :
44- if line .startswith ('btime ' ):
44+ if line .startswith (b 'btime ' ):
4545 return float (line .split ()[1 ])
4646
4747 def collect (self ):
@@ -52,8 +52,9 @@ def collect(self):
5252
5353 result = []
5454 try :
55- with open (os .path .join (pid , 'stat' )) as stat :
56- parts = (stat .read ().split (')' )[- 1 ].split ())
55+ with open (os .path .join (pid , 'stat' ), 'rb' ) as stat :
56+ parts = (stat .read ().split (b')' )[- 1 ].split ())
57+
5758 vmem = core .GaugeMetricFamily (self ._prefix + 'virtual_memory_bytes' ,
5859 'Virtual memory size in bytes.' , value = float (parts [20 ]))
5960 rss = core .GaugeMetricFamily (self ._prefix + 'resident_memory_bytes' , 'Resident memory size in bytes.' ,
@@ -72,9 +73,9 @@ def collect(self):
7273 pass
7374
7475 try :
75- with open (os .path .join (pid , 'limits' )) as limits :
76+ with open (os .path .join (pid , 'limits' ), 'rb' ) as limits :
7677 for line in limits :
77- if line .startswith ('Max open file' ):
78+ if line .startswith (b 'Max open file' ):
7879 max_fds = core .GaugeMetricFamily (self ._prefix + 'max_fds' ,
7980 'Maximum number of open file descriptors.' ,
8081 value = float (line .split ()[3 ]))
0 commit comments