[agent-go] [status] - start to unit
This commit is contained in:
@@ -14,7 +14,8 @@ type DiskStatus struct {
|
||||
}
|
||||
|
||||
func GetDiskStatus() *DiskStatus {
|
||||
var ds *DiskStatus
|
||||
|
||||
ds := &DiskStatus{}
|
||||
|
||||
// Get disk usage
|
||||
du, _ := disk.Usage("/")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package status
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
@@ -11,4 +12,11 @@ func TestGetDiskStatus(t *testing.T) {
|
||||
fmt.Printf("Total: %v, Used: %v\n", ds.Total, ds.Used)
|
||||
fmt.Printf("Logical Disks: %v\n", ds.LogicalDisk)
|
||||
|
||||
marshalIndent, err := json.MarshalIndent(ds, "", " ")
|
||||
if err != nil {
|
||||
fmt.Printf("error")
|
||||
}
|
||||
|
||||
fmt.Println(string(marshalIndent))
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ type MemoryStatus struct {
|
||||
}
|
||||
|
||||
func GetMemoryStatus() (*MemoryStatus, error) {
|
||||
var memoryStatus *MemoryStatus
|
||||
memoryStatus := &MemoryStatus{}
|
||||
|
||||
virtualMemoryStat, err := mem.VirtualMemory()
|
||||
if err != nil {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package status
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
@@ -17,4 +18,11 @@ func TestGetMemoryStatus(t *testing.T) {
|
||||
fmt.Printf("Available Memory: %s\n", FormatMemorySize(memoryStatus.AvailableMemory))
|
||||
fmt.Printf("Total Virtual Memory: %s\n", FormatMemorySize(memoryStatus.TotalVirtualMemory))
|
||||
fmt.Printf("Used Virtual Memory: %s\n", FormatMemorySize(memoryStatus.UsedVirtualMemory))
|
||||
|
||||
marshalIndent, err := json.MarshalIndent(memoryStatus, "", " ")
|
||||
if err != nil {
|
||||
fmt.Printf("error")
|
||||
}
|
||||
|
||||
fmt.Println(string(marshalIndent))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user