The daemon now collects CPU temp, core count, load average, memory/disk

usage, OS info, and system uptime every heartbeat using stdlib-only reads
  from /proc and /sys. Stats are sent as a JSON blob in the heartbeat
  payload, stored in a new system_stats TEXT column, and displayed in a
  new "System" tab in SpoolBuddy Settings with color-coded usage bars.
This commit is contained in:
maziggy
2026-03-26 10:06:24 +01:00
parent 3c53d741a3
commit c1676b1a32
3 changed files with 20 additions and 20 deletions
@@ -827,12 +827,12 @@ function SystemTab({ device }: { device: SpoolBuddyDevice }) {
const diskColor = (disk?.percent ?? 0) >= 90 ? 'bg-red-500' : (disk?.percent ?? 0) >= 70 ? 'bg-amber-500' : 'bg-green-500';
return (
<div className="space-y-1.5">
<div className="space-y-2">
{/* CPU + Memory side by side */}
<div className="grid grid-cols-2 gap-1.5">
<div className="bg-zinc-800 rounded-lg p-2">
<h3 className="text-sm font-semibold text-zinc-300 mb-1">CPU</h3>
<div className="space-y-1 text-xs">
<div className="grid grid-cols-2 gap-2">
<div className="bg-zinc-800 rounded-lg p-3">
<h3 className="text-sm font-semibold text-zinc-300 mb-2">CPU</h3>
<div className="space-y-1.5 text-xs">
<div className="flex justify-between">
<span className="text-zinc-500">{t('spoolbuddy.settings.cores', 'Cores')}</span>
<span className="text-zinc-300 font-mono">{stats.cpu_count ?? '-'}</span>
@@ -853,14 +853,14 @@ function SystemTab({ device }: { device: SpoolBuddyDevice }) {
</div>
{/* Memory */}
<div className="bg-zinc-800 rounded-lg p-2">
<h3 className="text-sm font-semibold text-zinc-300 mb-1">
<div className="bg-zinc-800 rounded-lg p-3">
<h3 className="text-sm font-semibold text-zinc-300 mb-2">
{t('spoolbuddy.settings.memory', 'Memory')}
</h3>
{mem ? (
<div className="space-y-1">
<div className="space-y-1.5">
<UsageBar percent={mem.percent ?? 0} color={memColor} />
<div className="space-y-0.5 text-xs">
<div className="space-y-1 text-xs">
<div className="flex justify-between">
<span className="text-zinc-500">{t('spoolbuddy.settings.used', 'Used')}</span>
<span className="text-zinc-300 font-mono">{mem.used_mb} / {mem.total_mb} MB</span>
@@ -877,8 +877,8 @@ function SystemTab({ device }: { device: SpoolBuddyDevice }) {
</div>
</div>
{/* Disk */}
<div className="bg-zinc-800 rounded-lg p-2">
{/* Disk — compact single row */}
<div className="bg-zinc-800 rounded-lg px-3 py-2">
<div className="flex items-center gap-3">
<h3 className="text-sm font-semibold text-zinc-300 shrink-0">
{t('spoolbuddy.settings.disk', 'Disk')}
@@ -895,12 +895,12 @@ function SystemTab({ device }: { device: SpoolBuddyDevice }) {
</div>
{/* OS + Runtime side by side */}
<div className="grid grid-cols-2 gap-1.5">
<div className="bg-zinc-800 rounded-lg p-2">
<h3 className="text-sm font-semibold text-zinc-300 mb-1">
<div className="grid grid-cols-2 gap-2">
<div className="bg-zinc-800 rounded-lg p-3">
<h3 className="text-sm font-semibold text-zinc-300 mb-1.5">
{t('spoolbuddy.settings.osInfo', 'OS')}
</h3>
<div className="space-y-0.5 text-xs">
<div className="space-y-1 text-xs">
{stats.os?.os && (
<div className="flex justify-between">
<span className="text-zinc-500">{t('spoolbuddy.settings.distro', 'Distro')}</span>
@@ -921,11 +921,11 @@ function SystemTab({ device }: { device: SpoolBuddyDevice }) {
)}
</div>
</div>
<div className="bg-zinc-800 rounded-lg p-2">
<h3 className="text-sm font-semibold text-zinc-300 mb-1">
<div className="bg-zinc-800 rounded-lg p-3">
<h3 className="text-sm font-semibold text-zinc-300 mb-1.5">
{t('spoolbuddy.settings.runtime', 'Runtime')}
</h3>
<div className="space-y-0.5 text-xs">
<div className="space-y-1 text-xs">
{stats.os?.python && (
<div className="flex justify-between">
<span className="text-zinc-500">Python</span>
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -23,7 +23,7 @@
<!-- Splash screens for iOS -->
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
<script type="module" crossorigin src="/assets/index-B0l2F0Xe.js"></script>
<script type="module" crossorigin src="/assets/index-BIwdarJO.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CZLTApPU.css">
</head>
<body>