@@ -25,13 +25,13 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
25
25
func VirtualMemoryWithContext (ctx context.Context ) (* VirtualMemoryStat , error ) {
26
26
result := & VirtualMemoryStat {}
27
27
28
- zoneName , err := zoneName () //nolint:contextcheck //FIXME
28
+ zoneName , err := zoneName (ctx )
29
29
if err != nil {
30
30
return nil , err
31
31
}
32
32
33
33
if zoneName == "global" {
34
- capacity , err := globalZoneMemoryCapacity () //nolint:contextcheck //FIXME
34
+ capacity , err := globalZoneMemoryCapacity (ctx )
35
35
if err != nil {
36
36
return nil , err
37
37
}
@@ -44,7 +44,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
44
44
result .Free = freemem
45
45
result .Used = result .Total - result .Free
46
46
} else {
47
- capacity , err := nonGlobalZoneMemoryCapacity () //nolint:contextcheck //FIXME
47
+ capacity , err := nonGlobalZoneMemoryCapacity (ctx )
48
48
if err != nil {
49
49
return nil , err
50
50
}
@@ -62,8 +62,7 @@ func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
62
62
return nil , common .ErrNotImplementedError
63
63
}
64
64
65
- func zoneName () (string , error ) {
66
- ctx := context .Background ()
65
+ func zoneName (ctx context.Context ) (string , error ) {
67
66
out , err := invoke .CommandWithContext (ctx , "zonename" )
68
67
if err != nil {
69
68
return "" , err
@@ -74,8 +73,7 @@ func zoneName() (string, error) {
74
73
75
74
var globalZoneMemoryCapacityMatch = regexp .MustCompile (`[Mm]emory size: (\d+) Megabytes` )
76
75
77
- func globalZoneMemoryCapacity () (uint64 , error ) {
78
- ctx := context .Background ()
76
+ func globalZoneMemoryCapacity (ctx context.Context ) (uint64 , error ) {
79
77
out , err := invoke .CommandWithContext (ctx , "prtconf" )
80
78
if err != nil {
81
79
return 0 , err
@@ -115,8 +113,7 @@ func globalZoneFreeMemory(ctx context.Context) (uint64, error) {
115
113
116
114
var kstatMatch = regexp .MustCompile (`(\S+)\s+(\S*)` )
117
115
118
- func nonGlobalZoneMemoryCapacity () (uint64 , error ) {
119
- ctx := context .Background ()
116
+ func nonGlobalZoneMemoryCapacity (ctx context.Context ) (uint64 , error ) {
120
117
out , err := invoke .CommandWithContext (ctx , "kstat" , "-p" , "-c" , "zone_memory_cap" , "memory_cap:*:*:physcap" )
121
118
if err != nil {
122
119
return 0 , err
0 commit comments