@@ -12,7 +12,7 @@ import (
12
12
)
13
13
14
14
func VirtualMemoryWithContext (ctx context.Context ) (* VirtualMemoryStat , error ) {
15
- vmem , swap , err := callSVMon (ctx )
15
+ vmem , swap , err := callSVMon (ctx , true )
16
16
if err != nil {
17
17
return nil , err
18
18
}
@@ -25,7 +25,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
25
25
}
26
26
27
27
func SwapMemoryWithContext (ctx context.Context ) (* SwapMemoryStat , error ) {
28
- _ , swap , err := callSVMon (ctx )
28
+ _ , swap , err := callSVMon (ctx , false )
29
29
if err != nil {
30
30
return nil , err
31
31
}
@@ -35,7 +35,7 @@ func SwapMemoryWithContext(ctx context.Context) (*SwapMemoryStat, error) {
35
35
return swap , nil
36
36
}
37
37
38
- func callSVMon (ctx context.Context ) (* VirtualMemoryStat , * SwapMemoryStat , error ) {
38
+ func callSVMon (ctx context.Context , virt bool ) (* VirtualMemoryStat , * SwapMemoryStat , error ) {
39
39
out , err := invoke .CommandWithContext (ctx , "svmon" , "-G" )
40
40
if err != nil {
41
41
return nil , nil , err
@@ -45,7 +45,7 @@ func callSVMon(ctx context.Context) (*VirtualMemoryStat, *SwapMemoryStat, error)
45
45
vmem := & VirtualMemoryStat {}
46
46
swap := & SwapMemoryStat {}
47
47
for _ , line := range strings .Split (string (out ), "\n " ) {
48
- if strings .HasPrefix (line , "memory" ) {
48
+ if virt && strings .HasPrefix (line , "memory" ) {
49
49
p := strings .Fields (line )
50
50
if len (p ) > 2 {
51
51
if t , err := strconv .ParseUint (p [1 ], 10 , 64 ); err == nil {
0 commit comments