[ Cmii ] [ Octopus ] - reformat agent-go - 1
This commit is contained in:
49
agent-go/a_status/Memory_test.go
Normal file
49
agent-go/a_status/Memory_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package a_status
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetMemoryStatus(t *testing.T) {
|
||||
|
||||
memoryStatus, err := GetMemoryMetric()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Total Memory: %s\n", FormatMemorySize(memoryStatus.TotalMemory))
|
||||
fmt.Printf("Available Memory: %s\n", FormatMemorySize(memoryStatus.AvailableMemory))
|
||||
fmt.Printf("Used Memory: %s\n ", FormatMemorySize(memoryStatus.UsedMemory))
|
||||
fmt.Printf("UsedPercent: %.2f %%\n", memoryStatus.UsedPercent)
|
||||
fmt.Printf("Free Memory: %s\n", FormatMemorySize(memoryStatus.FreeMemory))
|
||||
|
||||
marshalIndent, err := json.MarshalIndent(memoryStatus, "", " ")
|
||||
if err != nil {
|
||||
fmt.Printf("error")
|
||||
}
|
||||
|
||||
fmt.Println(string(marshalIndent))
|
||||
}
|
||||
|
||||
func TestGetMemoryInfo(t *testing.T) {
|
||||
|
||||
memoryStatus, err := GetMemoryInfo()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Total Memory: %s\n", FormatMemorySize(memoryStatus.TotalMemory))
|
||||
fmt.Printf("Used Memory: %s\n", FormatMemorySize(memoryStatus.UsedMemory))
|
||||
fmt.Printf("Available Memory: %s\n", FormatMemorySize(memoryStatus.AvailableMemory))
|
||||
fmt.Printf("UsedPercent: %.2f %%\n", memoryStatus.UsedPercent)
|
||||
fmt.Printf("Free Memory: %s\n", FormatMemorySize(memoryStatus.FreeMemory))
|
||||
|
||||
marshalIndent, err := json.MarshalIndent(memoryStatus, "", " ")
|
||||
if err != nil {
|
||||
fmt.Printf("error")
|
||||
}
|
||||
|
||||
fmt.Println(string(marshalIndent))
|
||||
}
|
||||
Reference in New Issue
Block a user