diff --git a/cmd/playground/main.go b/cmd/playground/main.go
index b00df4c..fec56ab 100644
--- a/cmd/playground/main.go
+++ b/cmd/playground/main.go
@@ -3,10 +3,17 @@ package main
import (
"log"
"os/exec"
+
+ "github.com/shirou/gopsutil/disk"
)
func main() {
-
+ dparts, _ := disk.Partitions(false)
+ for _, part := range dparts {
+ u, _ := disk.Usage(part.Mountpoint)
+ log.Printf("Part:%v", part)
+ log.Printf("Usage:%v", u)
+ }
}
func cmdExec() {
diff --git a/model/monitor.go b/model/monitor.go
index fb0dd24..f2e7a94 100644
--- a/model/monitor.go
+++ b/model/monitor.go
@@ -11,11 +11,8 @@ const (
// State ..
type State struct {
CPU float64
- MemTotal uint64
MemUsed uint64
- SwapTotal uint64
SwapUsed uint64
- DiskTotal uint64
DiskUsed uint64
NetInTransfer uint64
NetOutTransfer uint64
@@ -28,11 +25,8 @@ type State struct {
func (s *State) PB() *pb.State {
return &pb.State{
Cpu: s.CPU,
- MemTotal: s.MemTotal,
MemUsed: s.MemUsed,
- SwapTotal: s.SwapTotal,
SwapUsed: s.SwapUsed,
- DiskTotal: s.DiskTotal,
DiskUsed: s.DiskUsed,
NetInTransfer: s.NetInTransfer,
NetOutTransfer: s.NetOutTransfer,
@@ -46,11 +40,8 @@ func (s *State) PB() *pb.State {
func PB2State(s *pb.State) State {
return State{
CPU: s.GetCpu(),
- MemTotal: s.GetMemTotal(),
MemUsed: s.GetMemUsed(),
- SwapTotal: s.GetSwapTotal(),
SwapUsed: s.GetSwapUsed(),
- DiskTotal: s.GetDiskTotal(),
DiskUsed: s.GetDiskUsed(),
NetInTransfer: s.GetNetInTransfer(),
NetOutTransfer: s.GetNetOutTransfer(),
@@ -65,6 +56,9 @@ type Host struct {
Platform string
PlatformVersion string
CPU []string
+ MemTotal uint64
+ DiskTotal uint64
+ SwapTotal uint64
Arch string
Virtualization string
BootTime uint64
@@ -79,6 +73,9 @@ func (h *Host) PB() *pb.Host {
Platform: h.Platform,
PlatformVersion: h.PlatformVersion,
Cpu: h.CPU,
+ MemTotal: h.MemTotal,
+ DiskTotal: h.DiskTotal,
+ SwapTotal: h.SwapTotal,
Arch: h.Arch,
Virtualization: h.Virtualization,
BootTime: h.BootTime,
@@ -88,12 +85,16 @@ func (h *Host) PB() *pb.Host {
}
}
+
// PB2Host ...
func PB2Host(h *pb.Host) Host {
return Host{
Platform: h.GetPlatform(),
PlatformVersion: h.GetPlatformVersion(),
CPU: h.GetCpu(),
+ MemTotal: h.GetMemTotal(),
+ DiskTotal: h.GetDiskTotal(),
+ SwapTotal: h.GetSwapTotal(),
Arch: h.GetArch(),
Virtualization: h.GetVirtualization(),
BootTime: h.GetBootTime(),
@@ -102,3 +103,6 @@ func PB2Host(h *pb.Host) Host {
Version: h.GetVersion(),
}
}
+
+
+
diff --git a/proto/nezha.proto b/proto/nezha.proto
index 72fbd73..feb37d4 100644
--- a/proto/nezha.proto
+++ b/proto/nezha.proto
@@ -12,27 +12,27 @@ message Host {
string platform = 1;
string platform_version = 2;
repeated string cpu = 3;
- string arch = 4;
- string virtualization = 5;
- uint64 boot_time = 6;
- string ip = 7;
- string country_code = 8;
- string version = 9;
+ uint64 mem_total = 4;
+ uint64 disk_total = 5;
+ uint64 swap_total = 6;
+ string arch = 7;
+ string virtualization = 8;
+ uint64 boot_time = 9;
+ string ip = 10;
+ string country_code = 11;
+ string version = 12;
}
message State {
double cpu = 1;
- uint64 mem_total = 2;
uint64 mem_used = 3;
- uint64 swap_total = 4;
- uint64 swap_used = 5;
- uint64 disk_total = 6;
- uint64 disk_used = 7;
- uint64 net_in_transfer = 8;
- uint64 net_out_transfer = 9;
- uint64 net_in_speed = 10;
- uint64 net_out_speed = 11;
- uint64 uptime = 12;
+ uint64 swap_used = 4;
+ uint64 disk_used = 5;
+ uint64 net_in_transfer = 6;
+ uint64 net_out_transfer = 7;
+ uint64 net_in_speed = 8;
+ uint64 net_out_speed = 9;
+ uint64 uptime = 10;
}
message Receipt{
diff --git a/resource/template/page/home.html b/resource/template/page/home.html
index ae68a05..5d412d7 100644
--- a/resource/template/page/home.html
+++ b/resource/template/page/home.html
@@ -16,9 +16,9 @@
系统:@#server.Host.Platform#@-@#server.Host.PlatformVersion#@ [@#server.Host.Virtualization#@:@#server.Host.Arch#@]
CPU:@#server.Host.CPU#@
- 硬盘:@#formatByteSize(server.State.DiskUsed)#@/@#formatByteSize(server.State.DiskTotal)#@
- 内存:@#formatByteSize(server.State.MemUsed)#@/@#formatByteSize(server.State.MemTotal)#@
- 交换:@#formatByteSize(server.State.SwapUsed)#@/@#formatByteSize(server.State.SwapTotal)#@
+ 硬盘:@#formatByteSize(server.State.DiskUsed)#@/@#formatByteSize(server.Host.DiskTotal)#@
+ 内存:@#formatByteSize(server.State.MemUsed)#@/@#formatByteSize(server.Host.MemTotal)#@
+ 交换:@#formatByteSize(server.State.SwapUsed)#@/@#formatByteSize(server.Host.SwapTotal)#@
流量:@#formatByteSize(server.State.NetInTransfer)#@@#formatByteSize(server.State.NetOutTransfer)#@
@@ -39,7 +39,7 @@