🎨 CPU display
This commit is contained in:
		
							parent
							
								
									b46216fe5d
								
							
						
					
					
						commit
						86712e93a5
					
				@ -1,6 +1,10 @@
 | 
				
			|||||||
package model
 | 
					package model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pb "github.com/p14yground/nezha/proto"
 | 
					import (
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pb "github.com/p14yground/nezha/proto"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	_ = iota
 | 
						_ = iota
 | 
				
			||||||
@ -85,13 +89,24 @@ func (h *Host) PB() *pb.Host {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
// PB2Host ...
 | 
					// PB2Host ...
 | 
				
			||||||
func PB2Host(h *pb.Host) Host {
 | 
					func PB2Host(h *pb.Host) Host {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						cpuCount := make(map[string]int, 0)
 | 
				
			||||||
 | 
						cpus := h.GetCpu()
 | 
				
			||||||
 | 
						for _, u := range cpus {
 | 
				
			||||||
 | 
							cpuCount[u]++
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var distCpu []string
 | 
				
			||||||
 | 
						for u, num := range cpuCount {
 | 
				
			||||||
 | 
							distCpu = append(distCpu, fmt.Sprintf("%sx%d", u, num))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return Host{
 | 
						return Host{
 | 
				
			||||||
		Platform:        h.GetPlatform(),
 | 
							Platform:        h.GetPlatform(),
 | 
				
			||||||
		PlatformVersion: h.GetPlatformVersion(),
 | 
							PlatformVersion: h.GetPlatformVersion(),
 | 
				
			||||||
		CPU:             h.GetCpu(),
 | 
							CPU:             distCpu,
 | 
				
			||||||
		MemTotal:        h.GetMemTotal(),
 | 
							MemTotal:        h.GetMemTotal(),
 | 
				
			||||||
		DiskTotal:       h.GetDiskTotal(),
 | 
							DiskTotal:       h.GetDiskTotal(),
 | 
				
			||||||
		SwapTotal:       h.GetSwapTotal(),
 | 
							SwapTotal:       h.GetSwapTotal(),
 | 
				
			||||||
@ -103,6 +118,3 @@ func PB2Host(h *pb.Host) Host {
 | 
				
			|||||||
		Version:         h.GetVersion(),
 | 
							Version:         h.GetVersion(),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -23,7 +23,7 @@
 | 
				
			|||||||
                                class='arrow alternate circle down outline icon'></i>@#formatByteSize(server.State.NetInTransfer)#@<i
 | 
					                                class='arrow alternate circle down outline icon'></i>@#formatByteSize(server.State.NetInTransfer)#@<i
 | 
				
			||||||
                                class='arrow alternate circle up outline icon'></i>@#formatByteSize(server.State.NetOutTransfer)#@<br>
 | 
					                                class='arrow alternate circle up outline icon'></i>@#formatByteSize(server.State.NetOutTransfer)#@<br>
 | 
				
			||||||
                            启动:@# formatTimestamp(server.Host.BootTime) #@<br>
 | 
					                            启动:@# formatTimestamp(server.Host.BootTime) #@<br>
 | 
				
			||||||
                            版本:@#'v'+server.Host.Version#@<br>
 | 
					                            版本:@#server.Host.Version#@<br>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                    <div class="description">
 | 
					                    <div class="description">
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user