@@ -222,7 +222,7 @@ func (p *Process) IsRunning() (bool, error) {
222
222
func (p * Process ) MemoryMaps (grouped bool ) (* []MemoryMapsStat , error ) {
223
223
pid := p .Pid
224
224
var ret []MemoryMapsStat
225
- smapsPath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "smaps" )
225
+ smapsPath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "smaps" )
226
226
contents , err := ioutil .ReadFile (smapsPath )
227
227
if err != nil {
228
228
return nil , err
@@ -303,7 +303,7 @@ func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
303
303
// Get num_fds from /proc/(pid)/fd
304
304
func (p * Process ) fillFromfd () (int32 , []* OpenFilesStat , error ) {
305
305
pid := p .Pid
306
- statPath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "fd" )
306
+ statPath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "fd" )
307
307
d , err := os .Open (statPath )
308
308
if err != nil {
309
309
return 0 , nil , err
@@ -336,7 +336,7 @@ func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) {
336
336
// Get cwd from /proc/(pid)/cwd
337
337
func (p * Process ) fillFromCwd () (string , error ) {
338
338
pid := p .Pid
339
- cwdPath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "cwd" )
339
+ cwdPath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "cwd" )
340
340
cwd , err := os .Readlink (cwdPath )
341
341
if err != nil {
342
342
return "" , err
@@ -347,7 +347,7 @@ func (p *Process) fillFromCwd() (string, error) {
347
347
// Get exe from /proc/(pid)/exe
348
348
func (p * Process ) fillFromExe () (string , error ) {
349
349
pid := p .Pid
350
- exePath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "exe" )
350
+ exePath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "exe" )
351
351
exe , err := os .Readlink (exePath )
352
352
if err != nil {
353
353
return "" , err
@@ -358,7 +358,7 @@ func (p *Process) fillFromExe() (string, error) {
358
358
// Get cmdline from /proc/(pid)/cmdline
359
359
func (p * Process ) fillFromCmdline () (string , error ) {
360
360
pid := p .Pid
361
- cmdPath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "cmdline" )
361
+ cmdPath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "cmdline" )
362
362
cmdline , err := ioutil .ReadFile (cmdPath )
363
363
if err != nil {
364
364
return "" , err
@@ -376,7 +376,7 @@ func (p *Process) fillFromCmdline() (string, error) {
376
376
// Get IO status from /proc/(pid)/io
377
377
func (p * Process ) fillFromIO () (* IOCountersStat , error ) {
378
378
pid := p .Pid
379
- ioPath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "io" )
379
+ ioPath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "io" )
380
380
ioline , err := ioutil .ReadFile (ioPath )
381
381
if err != nil {
382
382
return nil , err
@@ -415,7 +415,7 @@ func (p *Process) fillFromIO() (*IOCountersStat, error) {
415
415
// Get memory info from /proc/(pid)/statm
416
416
func (p * Process ) fillFromStatm () (* MemoryInfoStat , * MemoryInfoExStat , error ) {
417
417
pid := p .Pid
418
- memPath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "statm" )
418
+ memPath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "statm" )
419
419
contents , err := ioutil .ReadFile (memPath )
420
420
if err != nil {
421
421
return nil , nil , err
@@ -467,7 +467,7 @@ func (p *Process) fillFromStatm() (*MemoryInfoStat, *MemoryInfoExStat, error) {
467
467
// Get various status from /proc/(pid)/status
468
468
func (p * Process ) fillFromStatus () error {
469
469
pid := p .Pid
470
- statPath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "status" )
470
+ statPath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "status" )
471
471
contents , err := ioutil .ReadFile (statPath )
472
472
if err != nil {
473
473
return err
@@ -554,7 +554,7 @@ func (p *Process) fillFromStatus() error {
554
554
555
555
func (p * Process ) fillFromStat () (string , int32 , * cpu.CPUTimesStat , int64 , int32 , error ) {
556
556
pid := p .Pid
557
- statPath := filepath .Join ("/ " , "proc" , strconv .Itoa (int (pid )), "stat" )
557
+ statPath := filepath .Join (common . GetEnv ( "HOST_PROC " , "/ proc" ) , strconv .Itoa (int (pid )), "stat" )
558
558
contents , err := ioutil .ReadFile (statPath )
559
559
if err != nil {
560
560
return "" , 0 , nil , 0 , 0 , err
@@ -610,7 +610,7 @@ func (p *Process) fillFromStat() (string, int32, *cpu.CPUTimesStat, int64, int32
610
610
func Pids () ([]int32 , error ) {
611
611
var ret []int32
612
612
613
- d , err := os .Open (" /proc" )
613
+ d , err := os .Open (common . GetEnv ( "HOST_PROC" , " /proc") )
614
614
if err != nil {
615
615
return nil , err
616
616
}
0 commit comments