mirror of
https://github.com/fankes/beszel.git
synced 2025-10-20 02:09:28 +08:00
add hostname to system info
This commit is contained in:
@@ -201,7 +201,7 @@ func (a *Agent) getSystemStats() (system.Info, system.Stats) {
|
|||||||
// add host info
|
// add host info
|
||||||
if info, err := host.Info(); err == nil {
|
if info, err := host.Info(); err == nil {
|
||||||
systemInfo.Uptime = info.Uptime
|
systemInfo.Uptime = info.Uptime
|
||||||
// systemInfo.Os = info.OS
|
systemInfo.Hostname = info.Hostname
|
||||||
}
|
}
|
||||||
// add cpu stats
|
// add cpu stats
|
||||||
if info, err := cpu.Info(); err == nil && len(info) > 0 {
|
if info, err := cpu.Info(); err == nil && len(info) > 0 {
|
||||||
|
@@ -45,6 +45,8 @@ type NetIoStats struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Info struct {
|
type Info struct {
|
||||||
|
Hostname string `json:"h"`
|
||||||
|
|
||||||
Cores int `json:"c"`
|
Cores int `json:"c"`
|
||||||
Threads int `json:"t"`
|
Threads int `json:"t"`
|
||||||
CpuModel string `json:"m"`
|
CpuModel string `json:"m"`
|
||||||
|
@@ -9,6 +9,7 @@ import {
|
|||||||
CpuIcon,
|
CpuIcon,
|
||||||
GlobeIcon,
|
GlobeIcon,
|
||||||
LayoutGridIcon,
|
LayoutGridIcon,
|
||||||
|
MonitorIcon,
|
||||||
StretchHorizontalIcon,
|
StretchHorizontalIcon,
|
||||||
XIcon,
|
XIcon,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
@@ -255,9 +256,23 @@ export default function SystemDetail({ name }: { name: string }) {
|
|||||||
<div className="flex gap-1.5 items-center">
|
<div className="flex gap-1.5 items-center">
|
||||||
<GlobeIcon className="h-4 w-4" /> {system.host}
|
<GlobeIcon className="h-4 w-4" /> {system.host}
|
||||||
</div>
|
</div>
|
||||||
|
{/* show hostname if it's different than host or name */}
|
||||||
|
{system.info?.h && system.info.h != system.host && system.info.h != system.name && (
|
||||||
|
<TooltipProvider>
|
||||||
|
<Tooltip delayDuration={150}>
|
||||||
|
<Separator orientation="vertical" className="h-4 bg-primary/30" />
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<div className="flex gap-1.5 items-center">
|
||||||
|
<MonitorIcon className="h-4 w-4" /> {system.info.h}
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>Hostname</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
)}
|
||||||
{system.info?.u && (
|
{system.info?.u && (
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<Tooltip>
|
<Tooltip delayDuration={150}>
|
||||||
<Separator orientation="vertical" className="h-4 bg-primary/30" />
|
<Separator orientation="vertical" className="h-4 bg-primary/30" />
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<div className="flex gap-1.5 items-center">
|
<div className="flex gap-1.5 items-center">
|
||||||
@@ -273,7 +288,7 @@ export default function SystemDetail({ name }: { name: string }) {
|
|||||||
<Separator orientation="vertical" className="h-4 bg-primary/30" />
|
<Separator orientation="vertical" className="h-4 bg-primary/30" />
|
||||||
<div className="flex gap-1.5 items-center">
|
<div className="flex gap-1.5 items-center">
|
||||||
<CpuIcon className="h-4 w-4" />
|
<CpuIcon className="h-4 w-4" />
|
||||||
{system.info.m} ({system.info.c}c / {system.info.t}t)
|
{system.info.m} ({system.info.c}c/{system.info.t}t)
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
2
beszel/site/src/types.d.ts
vendored
2
beszel/site/src/types.d.ts
vendored
@@ -10,6 +10,8 @@ export interface SystemRecord extends RecordModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface SystemInfo {
|
export interface SystemInfo {
|
||||||
|
/** hostname */
|
||||||
|
h: string
|
||||||
/** cpu percent */
|
/** cpu percent */
|
||||||
cpu: number
|
cpu: number
|
||||||
/** cpu threads */
|
/** cpu threads */
|
||||||
|
Reference in New Issue
Block a user