Read-only terminal UI dashboard for observing the ServeScheduler service. Launched as a standalone CLI command; it does not start the scheduler — it only polls the database.
SchedulerMonitorTUI is distinct from ObjSchedulerTUI, which is an embedded push-based TUI that runs inside the scheduler service. This module is a DB-polling observer that works whether the scheduler service is running or not.
It uses a dual poll-rate strategy:
TuiConstants.SCHEDULER_POLL_FAST_SECS, default 3 s) — queries def_scheduler for aggregate counts (active, done, overdue) and stage_scheduler for recent job history.TuiConstants.SCHEDULER_POLL_SLOW_SECS, default 10 s) — fetches the full list of active scheduled tasks from def_scheduler.Status colour thresholds for job CPU load:
| Metric | Color |
|---|---|
CPU > CPU_FAIL_PCT (80%) |
fail |
CPU > CPU_WARN_PCT (50%) |
warn |
| CPU ≤ 50% | white |
Job status colours: DONE/COMPLETE → ok, FAILED → fail, otherwise → warn.
__init__(self)Initialises the theme, console, layout, and internal state including active_count, done_count, running_count, due_soon_count, scheduled_tasks, and running_jobs.
start(self) / stop(self)Standard TUI lifecycle — start runs both polls immediately to populate the display before the Live starts, then launches the background thread. stop signals the thread and tears down.
log(self, message, level) / set_status(self, message)Thread-safe log append and footer status update.
_poll_fast(self) (internal)Runs every SCHEDULER_POLL_FAST_SECS. Aggregates def_scheduler counts via a single SQL SUM(CASE ...) query and fetches recent stage_scheduler rows within STATS_INTERVAL_SQL. Uses SchedulerJobStatus enum values for status comparisons.
_poll_slow(self) (internal)Runs every SCHEDULER_POLL_SLOW_SECS. Fetches active tasks from def_scheduler scoped to Package IN ('CORE', 'SYSTEM', {package}), ordered by LastTrigger DESC.
| Panel | Content |
|---|---|
| Header | Heartbeat, package, clock, uptime |
| Sidebar | DB status, active tasks, running jobs, completed, overdue |
| Scheduled Tasks | Active def_scheduler rows — task name, crontab, trigger type, last run, run count, status |
| Recent Jobs | stage_scheduler rows (last 1 hr) — status, instance GUID, PID, CPU%, memory%, start time |
| Log | Scrolling log |
| Footer | Polling summary |
python ServeScheduler.py tui
Press Ctrl+C to exit.