@@ -39,9 +39,9 @@ def __init__(self, namespace='', pid=lambda: 'self', proc='/proc', registry=core
39
39
registry .register (self )
40
40
41
41
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 :
43
43
for line in stat :
44
- if line .startswith ('btime ' ):
44
+ if line .startswith (b 'btime ' ):
45
45
return float (line .split ()[1 ])
46
46
47
47
def collect (self ):
@@ -52,8 +52,9 @@ def collect(self):
52
52
53
53
result = []
54
54
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
+
57
58
vmem = core .GaugeMetricFamily (self ._prefix + 'virtual_memory_bytes' ,
58
59
'Virtual memory size in bytes.' , value = float (parts [20 ]))
59
60
rss = core .GaugeMetricFamily (self ._prefix + 'resident_memory_bytes' , 'Resident memory size in bytes.' ,
@@ -72,9 +73,9 @@ def collect(self):
72
73
pass
73
74
74
75
try :
75
- with open (os .path .join (pid , 'limits' )) as limits :
76
+ with open (os .path .join (pid , 'limits' ), 'rb' ) as limits :
76
77
for line in limits :
77
- if line .startswith ('Max open file' ):
78
+ if line .startswith (b 'Max open file' ):
78
79
max_fds = core .GaugeMetricFamily (self ._prefix + 'max_fds' ,
79
80
'Maximum number of open file descriptors.' ,
80
81
value = float (line .split ()[3 ]))
0 commit comments