55 lines
981 B
Go
55 lines
981 B
Go
package system
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"skapp/backend/utils"
|
|
"testing"
|
|
)
|
|
|
|
func TestCpu(t *testing.T) {
|
|
fmt.Println(GetCpuInfo())
|
|
}
|
|
|
|
func TestMemory(t *testing.T) {
|
|
fmt.Println(GetVirtualMemory())
|
|
fmt.Println(GetSwapMemory())
|
|
}
|
|
|
|
func TestDisk(t *testing.T) {
|
|
partitions := GetDiskPartitions()
|
|
fmt.Println(partitions)
|
|
for _, partition := range partitions {
|
|
fmt.Println(GetDiskUsage(partition.Device))
|
|
}
|
|
fmt.Println(GetIOCounters())
|
|
}
|
|
|
|
func TestNetwork(t *testing.T) {
|
|
fmt.Println(GetNetWorkConnection())
|
|
}
|
|
|
|
func TestProcess(t *testing.T) {
|
|
processList := GetAllProcessPid()
|
|
for _, pid := range processList {
|
|
fmt.Println(GetProcessInfo(pid))
|
|
}
|
|
}
|
|
|
|
func TestScanDir(t *testing.T) {
|
|
fmt.Println(filepath.IsAbs("E:"), filepath.IsAbs("E:/"))
|
|
path, err := filepath.Abs("E:/")
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
|
|
data, err := ScanDir(path)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
|
|
for _, entry := range data {
|
|
fmt.Printf("%+v\n", utils.Json(entry))
|
|
}
|
|
}
|