Skip to content

Commit

Permalink
feat: Add GPU inspection support (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
uubulb authored Jun 23, 2024
1 parent 65dee23 commit cf9bbb5
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 72 deletions.
6 changes: 6 additions & 0 deletions model/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type HostState struct {
UdpConnCount uint64
ProcessCount uint64
Temperatures []SensorTemperature
GPU float64
}

func (s *HostState) PB() *pb.State {
Expand Down Expand Up @@ -60,6 +61,7 @@ func (s *HostState) PB() *pb.State {
UdpConnCount: s.UdpConnCount,
ProcessCount: s.ProcessCount,
Temperatures: ts,
Gpu: s.GPU,
}
}

Expand Down Expand Up @@ -89,6 +91,7 @@ func PB2State(s *pb.State) HostState {
UdpConnCount: s.GetUdpConnCount(),
ProcessCount: s.GetProcessCount(),
Temperatures: ts,
GPU: s.GetGpu(),
}
}

Expand All @@ -105,6 +108,7 @@ type Host struct {
IP string `json:"-"`
CountryCode string
Version string
GPU []string
}

func (h *Host) PB() *pb.Host {
Expand All @@ -121,6 +125,7 @@ func (h *Host) PB() *pb.Host {
Ip: h.IP,
CountryCode: h.CountryCode,
Version: h.Version,
Gpu: h.GPU,
}
}

Expand All @@ -138,5 +143,6 @@ func PB2Host(h *pb.Host) Host {
IP: h.GetIp(),
CountryCode: h.GetCountryCode(),
Version: h.GetVersion(),
GPU: h.GetGpu(),
}
}
160 changes: 89 additions & 71 deletions proto/nezha.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions proto/nezha.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ message Host {
string ip = 10;
string country_code = 11;
string version = 12;
repeated string gpu = 13;
}

message State {
Expand All @@ -42,6 +43,7 @@ message State {
uint64 udp_conn_count = 15;
uint64 process_count = 16;
repeated State_SensorTemperature temperatures = 17;
double gpu = 18;
}

message State_SensorTemperature {
Expand Down
1 change: 1 addition & 0 deletions resource/template/theme-angel-kanade/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
[<span
v-if="server.Host.Virtualization">@#server.Host.Virtualization#@:</span>@#server.Host.Arch#@]<br />
CPU: @#server.Host.CPU#@<br />
GPU: @#server.Host.GPU#@<br />
{{tr "DiskUsed"}}:
@#formatByteSize(server.State.DiskUsed)#@/@#formatByteSize(server.Host.DiskTotal)#@<br />
{{tr "MemUsed"}}:
Expand Down
2 changes: 2 additions & 0 deletions resource/template/theme-default/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<br />
CPU: @#server.Host.CPU#@
<br />
GPU: @#server.Host.GPU#@
<br />
{{tr "DiskUsed"}}:
@#formatByteSize(server.State.DiskUsed)#@/@#formatByteSize(server.Host.DiskTotal)#@
<br />
Expand Down
2 changes: 1 addition & 1 deletion resource/template/theme-mdui/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
var disk = this.formatByteSize(server.State.DiskUsed) + '/' + this.formatByteSize(server.Host.DiskTotal);
var upTime = this.secondToDate(server.State.Uptime);
var tooltip =
`{content: 'System: ${server.Host.Platform}-${server.Host.PlatformVersion}[${server.Host.Arch}]<br>CPU: ${server.Host.CPU}<br>Disk: ${disk}<br>Online: ${upTime}<br>Version: ${server.Host.Version}'}`;
`{content: 'System: ${server.Host.Platform}-${server.Host.PlatformVersion}[${server.Host.Arch}]<br>CPU: ${server.Host.CPU}<br>GPU: ${server.Host.GPU}<br>Disk: ${disk}<br>Online: ${upTime}<br>Version: ${server.Host.Version}'}`;
return tooltip
}
}
Expand Down
4 changes: 4 additions & 0 deletions resource/template/theme-server-status/home-group-false.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
<span class="node-cell-expand-label">CPU:</span>
@#node.host.CPU.join(",")#@ (@#node.cpu.percent#@%)
</span>
<span class="node-cell-expand" v-if="node.host.GPU">
<span class="node-cell-expand-label">GPU:</span>
@#node.host.GPU.join(",")#@ (@#node.gpu.percent#@%)
</span>
<span class="node-cell-expand">
<span class="node-cell-expand-label">{{tr "DiskUsed"}}:</span>
@#formatByteSize(node.state.DiskUsed)#@ / @#formatByteSize(node.host.DiskTotal)#@ (@#node.hdd.percent#@%)
Expand Down
4 changes: 4 additions & 0 deletions resource/template/theme-server-status/home-group-true.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<span class="node-cell-expand-label">CPU:</span>
@#node.host.CPU.join(",")#@ (@#node.cpu.percent#@%)
</span>
<span class="node-cell-expand" v-if="node.host.GPU">
<span class="node-cell-expand-label">GPU:</span>
@#node.host.GPU.join(",")#@ (@#node.gpu.percent#@%)
</span>
<span class="node-cell-expand">
<span class="node-cell-expand-label">{{tr "DiskUsed"}}:</span>
@#formatByteSize(node.state.DiskUsed)#@ / @#formatByteSize(node.host.DiskTotal)#@ (@#node.hdd.percent#@%)
Expand Down
1 change: 1 addition & 0 deletions resource/template/theme-server-status/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ <h4 class="modal-title" id="mapChartTitle">{{tr "ServersOnWorldMap"}}</h4>
network: this.getNetworkSpeed(server.State.NetInSpeed, server.State.NetOutSpeed),
traffic: this.formatByteSize(server.State.NetInTransfer) + ' | ' + this.formatByteSize(server.State.NetOutTransfer),
cpu: this.formatPercents(server.live, this.toFixed2(server.State.CPU)),
gpu: this.formatPercents(server.live, this.toFixed2(server.State.GPU)),
memory: this.formatPercent(server.live, server.State.MemUsed, server.Host.MemTotal),
hdd: this.formatPercent(server.live, server.State.DiskUsed, server.Host.DiskTotal),
online: server.live,
Expand Down

0 comments on commit cf9bbb5

Please sign in to comment.