add hostname to system info

This commit is contained in:
Henry Dollman
2024-09-14 18:09:38 -04:00
parent 53b02dd55f
commit 3e95269a7c
4 changed files with 22 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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"`

View File

@@ -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>
</> </>
)} )}

View File

@@ -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 */