@@ -238,14 +238,14 @@ func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
238
238
}
239
239
stats := make ([]FilterStat , 0 , 1 )
240
240
241
- max , err := common .ReadInts (maxfile )
241
+ maxConn , err := common .ReadInts (maxfile )
242
242
if err != nil {
243
243
return nil , err
244
244
}
245
245
246
246
payload := FilterStat {
247
247
ConnTrackCount : count [0 ],
248
- ConnTrackMax : max [0 ],
248
+ ConnTrackMax : maxConn [0 ],
249
249
}
250
250
251
251
stats = append (stats , payload )
@@ -396,12 +396,12 @@ func ConnectionsWithContext(ctx context.Context, kind string) ([]ConnectionStat,
396
396
397
397
// Return a list of network connections opened returning at most `max`
398
398
// connections for each running process.
399
- func ConnectionsMax (kind string , max int ) ([]ConnectionStat , error ) {
400
- return ConnectionsMaxWithContext (context .Background (), kind , max )
399
+ func ConnectionsMax (kind string , maxConn int ) ([]ConnectionStat , error ) {
400
+ return ConnectionsMaxWithContext (context .Background (), kind , maxConn )
401
401
}
402
402
403
- func ConnectionsMaxWithContext (ctx context.Context , kind string , max int ) ([]ConnectionStat , error ) {
404
- return ConnectionsPidMaxWithContext (ctx , kind , 0 , max )
403
+ func ConnectionsMaxWithContext (ctx context.Context , kind string , maxConn int ) ([]ConnectionStat , error ) {
404
+ return ConnectionsPidMaxWithContext (ctx , kind , 0 , maxConn )
405
405
}
406
406
407
407
// Return a list of network connections opened, omitting `Uids`.
@@ -415,8 +415,8 @@ func ConnectionsWithoutUidsWithContext(ctx context.Context, kind string) ([]Conn
415
415
return ConnectionsMaxWithoutUidsWithContext (ctx , kind , 0 )
416
416
}
417
417
418
- func ConnectionsMaxWithoutUidsWithContext (ctx context.Context , kind string , max int ) ([]ConnectionStat , error ) {
419
- return ConnectionsPidMaxWithoutUidsWithContext (ctx , kind , 0 , max )
418
+ func ConnectionsMaxWithoutUidsWithContext (ctx context.Context , kind string , maxConn int ) ([]ConnectionStat , error ) {
419
+ return ConnectionsPidMaxWithoutUidsWithContext (ctx , kind , 0 , maxConn )
420
420
}
421
421
422
422
// Return a list of network connections opened by a process.
@@ -437,23 +437,23 @@ func ConnectionsPidWithoutUidsWithContext(ctx context.Context, kind string, pid
437
437
}
438
438
439
439
// Return up to `max` network connections opened by a process.
440
- func ConnectionsPidMax (kind string , pid int32 , max int ) ([]ConnectionStat , error ) {
441
- return ConnectionsPidMaxWithContext (context .Background (), kind , pid , max )
440
+ func ConnectionsPidMax (kind string , pid int32 , maxConn int ) ([]ConnectionStat , error ) {
441
+ return ConnectionsPidMaxWithContext (context .Background (), kind , pid , maxConn )
442
442
}
443
443
444
- func ConnectionsPidMaxWithoutUids (kind string , pid int32 , max int ) ([]ConnectionStat , error ) {
445
- return ConnectionsPidMaxWithoutUidsWithContext (context .Background (), kind , pid , max )
444
+ func ConnectionsPidMaxWithoutUids (kind string , pid int32 , maxConn int ) ([]ConnectionStat , error ) {
445
+ return ConnectionsPidMaxWithoutUidsWithContext (context .Background (), kind , pid , maxConn )
446
446
}
447
447
448
- func ConnectionsPidMaxWithContext (ctx context.Context , kind string , pid int32 , max int ) ([]ConnectionStat , error ) {
449
- return connectionsPidMaxWithoutUidsWithContext (ctx , kind , pid , max , false )
448
+ func ConnectionsPidMaxWithContext (ctx context.Context , kind string , pid int32 , maxConn int ) ([]ConnectionStat , error ) {
449
+ return connectionsPidMaxWithoutUidsWithContext (ctx , kind , pid , maxConn , false )
450
450
}
451
451
452
- func ConnectionsPidMaxWithoutUidsWithContext (ctx context.Context , kind string , pid int32 , max int ) ([]ConnectionStat , error ) {
453
- return connectionsPidMaxWithoutUidsWithContext (ctx , kind , pid , max , true )
452
+ func ConnectionsPidMaxWithoutUidsWithContext (ctx context.Context , kind string , pid int32 , maxConn int ) ([]ConnectionStat , error ) {
453
+ return connectionsPidMaxWithoutUidsWithContext (ctx , kind , pid , maxConn , true )
454
454
}
455
455
456
- func connectionsPidMaxWithoutUidsWithContext (ctx context.Context , kind string , pid int32 , max int , skipUids bool ) ([]ConnectionStat , error ) {
456
+ func connectionsPidMaxWithoutUidsWithContext (ctx context.Context , kind string , pid int32 , maxConn int , skipUids bool ) ([]ConnectionStat , error ) {
457
457
tmap , ok := netConnectionKindMap [kind ]
458
458
if ! ok {
459
459
return nil , fmt .Errorf ("invalid kind, %s" , kind )
@@ -462,9 +462,9 @@ func connectionsPidMaxWithoutUidsWithContext(ctx context.Context, kind string, p
462
462
var err error
463
463
var inodes map [string ][]inodeMap
464
464
if pid == 0 {
465
- inodes , err = getProcInodesAllWithContext (ctx , root , max )
465
+ inodes , err = getProcInodesAllWithContext (ctx , root , maxConn )
466
466
} else {
467
- inodes , err = getProcInodes (root , pid , max )
467
+ inodes , err = getProcInodes (root , pid , maxConn )
468
468
if len (inodes ) == 0 {
469
469
// no connection for the pid
470
470
return []ConnectionStat {}, nil
@@ -543,7 +543,7 @@ func statsFromInodesWithContext(ctx context.Context, root string, pid int32, tma
543
543
}
544
544
545
545
// getProcInodes returns fd of the pid.
546
- func getProcInodes (root string , pid int32 , max int ) (map [string ][]inodeMap , error ) {
546
+ func getProcInodes (root string , pid int32 , maxConn int ) (map [string ][]inodeMap , error ) {
547
547
ret := make (map [string ][]inodeMap )
548
548
549
549
dir := fmt .Sprintf ("%s/%d/fd" , root , pid )
@@ -552,7 +552,7 @@ func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, erro
552
552
return ret , err
553
553
}
554
554
defer f .Close ()
555
- dirEntries , err := f .ReadDir (max )
555
+ dirEntries , err := f .ReadDir (maxConn )
556
556
if err != nil {
557
557
return ret , err
558
558
}
@@ -668,19 +668,19 @@ func (p *process) fillFromStatus(ctx context.Context) error {
668
668
return nil
669
669
}
670
670
671
- func getProcInodesAll (root string , max int ) (map [string ][]inodeMap , error ) {
672
- return getProcInodesAllWithContext (context .Background (), root , max )
671
+ func getProcInodesAll (root string , maxConn int ) (map [string ][]inodeMap , error ) {
672
+ return getProcInodesAllWithContext (context .Background (), root , maxConn )
673
673
}
674
674
675
- func getProcInodesAllWithContext (ctx context.Context , root string , max int ) (map [string ][]inodeMap , error ) {
675
+ func getProcInodesAllWithContext (ctx context.Context , root string , maxConn int ) (map [string ][]inodeMap , error ) {
676
676
pids , err := PidsWithContext (ctx )
677
677
if err != nil {
678
678
return nil , err
679
679
}
680
680
ret := make (map [string ][]inodeMap )
681
681
682
682
for _ , pid := range pids {
683
- t , err := getProcInodes (root , pid , max )
683
+ t , err := getProcInodes (root , pid , maxConn )
684
684
if err != nil {
685
685
// skip if permission error or no longer exists
686
686
if os .IsPermission (err ) || os .IsNotExist (err ) || errors .Is (err , io .EOF ) {
0 commit comments