zinit UI: admin section on zinit + graphs for memory usage... #37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
we used to have a nice section where we could see basic stats at left side of screen
use a graph to show this
restore this, if needed check in development branch how it was done
make sure skill: hero_ui_dashboard is followed
then make an admin tab
shutdown
stopall
clean
resetall
service & job management
we need full management of the jobs
make a detailed page per job/service
now same for service
use router feature
for all relevent elements
do proper tests with mcp browser
Implementation Spec for Issue #37
Objective
Extend the Zinit web admin dashboard with: (1) a dashboard stats panel showing memory/CPU usage graphs, (2) an Admin tab with system-level operations (shutdown, stop-all, clean, reset-all), (3) enhanced service and job detail panels with lifecycle management controls, (4) dedicated detail pages per job/service with real-time resource tracking, (5) URL-based routing for deep-linking, and (6) MCP browser tests.
Requirements
Dashboard Stats Panel
Admin Tab
system.shutdownRPC; polls to verify processes emptyservice.stop_allRPC; shows progress and stopped countjob.purgeandlogs.delete_older_thanRPC/api/services/reset-allREST endpointService & Job Lifecycle Controls
Detailed Pages per Job/Service
service.stats, children processes, dependency infoURL Router
/,/job/{id},/service/{name},/admin,/run/{id}, etc.Testing
Implementation Plan (7 Steps)
Step 1: Implement real
service.statsand addsystem.statsRPCservice.statshandler to usesysinfocrate for real CPU/memory (currently returns zeros)system.statshandler returning system-wide memory, CPU, process countopenrpc.jsonwithsystem.statsmethod definitionzinit_server/src/rpc/service.rs,zinit_server/src/rpc/system.rs,zinit_server/src/rpc/mod.rs,zinit_server/openrpc.jsonStep 2: Add Chart.js loading and Dashboard Stats UI
system.statsevery 5 seconds, maintain rolling 60-point historyzinit_ui/templates/base.html,zinit_ui/static/js/dashboard.js,zinit_ui/static/css/dashboard.cssStep 3: Add Admin Tab with Bulk Operations
admin.jswith shutdown, stop-all, clean, reset-all functionszinit_ui/templates/base.html,zinit_ui/templates/index.html,zinit_ui/static/js/admin.js,zinit_ui/static/css/dashboard.cssStep 4: Enhance Service Detail Panel
zinit_ui/static/js/dashboard.jsStep 5: Enhance Job Detail Panel
zinit_ui/static/js/dashboard.jsStep 6: Implement Path-Based URL Router
zinit_ui/src/routes.rs,zinit_ui/static/js/dashboard.jsStep 7: MCP Browser Tests
tests/ui/(new directory)Key Notes
static/js/chart.umd.min.js— just needs a script tagreset-allendpoint already exists with full implementationsysinfocrate is already a dependency — no new deps neededopenrpc.jsonviaopenrpc_client!macroopenrpc_proxy!macroAcceptance Criteria
system.statsreturns real memory, CPU, and process countservice.statsreturns real memory/CPU (not zeros)Updated Implementation Spec for Issue #37 — Server-First Approach
RPC Audit Results
67 RPC methods already exist with 100% handler ↔ OpenRPC ↔ SDK coverage. Almost all required server-side functionality for the UI is already implemented:
✅ Already working:
system.shutdown,system.reboot,system.ping,system.prepare_restartservice.start,service.stop,service.restart,service.killservice.start_all,service.stop_allservice.status,service.status_full,service.is_running,service.why,service.treejob.cancel,job.retry,job.cancel_bulk,job.purgejob.graph,job.graph_for,job.why_waitingjob.logs,job.elapsed_ms,job.attempts,job.statslogs.delete_older_than,logs.delete_by_srcdebug.state,debug.process_tree❌ Broken / missing (needs implementation):
system.statsdoesn't existservice.statsreturns fake datamemory_bytes: 0,cpu_percent: 0.0alwayssysinfocrate (already a dep) to read real process metrics from PIDservice.childrenreturns fake memorymemory_bytes: 0per childsysinfoto read child process memoryservice.statusreturnsrestarts: 0alwaysattempt: 1entryImplementation Plan
Step 1: Implement real
service.statswith sysinfoFiles:
crates/zinit_server/src/rpc/service.rshandle_statsto usesysinfo::Systemto look up process by PIDmemory()andcpu_usage()from the processStep 2: Fix
service.childrenmemory reportingFiles:
crates/zinit_server/src/rpc/service.rshandle_childrento usesysinfofor child process memoryStep 3: Add
system.statsRPC methodFiles:
crates/zinit_server/src/rpc/system.rs,crates/zinit_server/src/rpc/mod.rs,crates/zinit_server/openrpc.jsonhandle_statsfunction usingsysinfo::Systemfor system-wide metricsmemory_total_bytes,memory_used_bytes,cpu_percent,process_count,service_count,job_stats(fromdb.jobs.stats())mod.rsopenrpc.json(SDK auto-generates from this)Step 4: Track actual restart count
Files:
crates/zinit_server/src/rpc/service.rs(and possibly service state/DB)service.restarthandler)service.statusandservice.status_fullStep 5: Fix job log archive attempt separation
Files:
crates/zinit_server/src/rpc/job.rshandle_log_archiveto properly separate logs by attempt numberStep 6: Verify OpenRPC + SDK integration
openrpc.jsoncargo buildto verify SDK auto-generation workscargo testto verify nothing brokeAcceptance Criteria
service.statsreturns real memory_bytes and cpu_percent from sysinfoservice.childrenreturns real memory_bytes per child processsystem.statsRPC exists, returns real system memory/CPU/process/service/job countssystem.statsappears in openrpc.json and is auto-generated in SDKservice.statusreturns actual restart count (not always 0)job.log_archiveproperly separates logs by attempt numbercargo testpassescargo buildsucceeds (SDK generation works)Notes
sysinfocrate is already a dependency (used inprocess.rs) — no new deps neededopenrpc.jsonviaopenrpc_client!macro — adding to openrpc.json is sufficientopenrpc_proxy!— no UI route changes needed for new methodsImplementation Complete: Server-Side Stats & Fixes
Commit:
1708f5eon branchdevelopment_kristofWhat was implemented
New:
system.statsRPC methodReturns real system-wide resource usage:
memory_total_bytes,memory_used_bytes— real system memory via sysinfocpu_percent— accurate CPU with delta tracking across callsprocess_count— total OS processesservice_count— registered zinit servicesjob_stats— aggregate job counts by phaseopenrpc.json→ SDK auto-generatessystem_stats()client methodFixed:
service.stats— real data (was returning zeros)Systeminstance for accurate CPU deltasmemory_bytesandcpu_percentfor the service's processsleepprocess shows 1,196,032 bytes memory, 0.0% CPU (correct)Fixed:
service.children— real memory per childmemory_bytesFixed:
service.status/service.status_full— real restart countattempt > 1)0Fixed:
job.log_archive— attempt separationattempt:Ntags when presentNew:
sysmonmodule — shared system monitorSysteminstance behindLazyLock<Mutex<System>>system_stats(),process_stats(pid),processes_stats(pids)Bugs found and fixed during implementation
Critical:
JobFilter::default()hadlimit: 0#[derive(Default)]gavelimit: 0(u32 default), not 100serde(default = "default_list_limit")only applies during JSON deserializationservice_running_jobs()to always return empty viaLIMIT 0SQLDefaultimpl settinglimit: 100Bug:
service_running_jobsdidn't match by action nameservice_running_jobsonly matchedjob.action == service_nameor prefixservice_name:Verified with live testing
All endpoints tested against a running zinit_server with real processes:
Test results
All 189 tests pass (136 zinit_lib + 37 zinit_server + 16 zinit_sdk)
UI Integration Check Results
Current State
I checked the zinit UI at http://localhost:9999 and found the following:
Tabs Currently Implemented:
Missing / NOT Integrated
❌ Admin Tab - NOT VISIBLE
❌ Stats/Graphs Section - NOT VISIBLE
❌ Detailed Job/Service Pages - PARTIALLY IMPLEMENTED
❌ Router Paths - NOT VISIBLE
/logs_run/$run/logs_job/$jobid/job/$jobid/service/.../action/.../run/...Summary
The admin section is NOT integrated into the UI. The current implementation focuses on Actions, Jobs, Runs, Services, Secrets, and Logs management, but lacks the critical admin controls (shutdown, stop-all, clean, reset-all) and system monitoring features (memory/CPU graphs) that are specified in this issue.
The code for
/api/services/reset-allexists in the backend routes, but there is no UI button or admin tab to access it.