Server Stats
Compact server-health pill — Load / RAM / HDD / Net / Up — color-coded green/amber/red, with a full-detail tooltip on hover. The tooltip carries a Copy button that puts every metric on the clipboard, and you can pass a servers array for 2+ machines — the pill shows one server at a time and its name becomes a switcher. For machines with several drives, pass a disks array (first = primary). Presentational: feed it data from your own polling loop.
Preview
Hover the pill to see the detailed breakdown and the Copy button.
Multiple servers
Pass a servers array of { label, stats } entries. The pill shows one server at a time — click the server name (with the ⟷ icon) to switch to the next machine. Copy still grabs every server at once. With a single server, no name is shown.
Multiple disks
Pass a disks array — the first entry is the primary (system) disk. The pill shows the primary's usage with a ·N badge for the disk count; hover to see every disk broken out by name. The single disk field still works for one-disk machines.
Source
Copy this file to components/status/server-stats.tsx
'use client'
import * as React from 'react'
import { Activity } from 'lucide-react'
import { cn } from '@/lib/utils'
export interface DiskStats {
name?: string // mount/label, e.g. "/", "/data", "C:"
total: number; used: number; free: number; percent: number
}
export interface ServerStatsData {
cpu_count: number
load_avg: number[] // [1m, 5m, 15m]
load_percent: number[] // [1m, 5m, 15m] as % of capacity
uptime_seconds: number
ram: { total: number; used: number; available: number; percent: number }
disk: DiskStats // primary disk (single-disk case)
disks?: DiskStats[] // all disks; first = primary (wins over disk)
network: { bytes_sent: number; bytes_recv: number; send_bps: number; recv_bps: number; percent: number; max_mbits: number }
}
export interface ServerStatsItem {
label?: string
stats: ServerStatsData
}
export interface ServerStatsProps {
stats?: ServerStatsData | null // single server
servers?: ServerStatsItem[] // 2+ servers (wins over stats)
copyable?: boolean // tooltip "Copy" button (default true)
className?: string
}
// Compact health pill(s): Load / RAM / HDD / Net / Up, color-coded
// green < 50% < amber < 80% < red, with a full-detail hover tooltip.
// The tooltip has a Copy button that dumps every metric as text.
// Presentational: feed it stats from your own polling loop.Props
| Prop | Type |
|---|---|
| stats | ServerStatsData | null |
| servers | ServerStatsItem[] |
| copyable | boolean |
| className | string |