nawasara / uptime
Uptime monitoring hub — reads Uptime Kuma data and displays it in the Nawasara dashboard
Requires
- php: ^8.2
- livewire/livewire: ^3.0
- nawasara/database-monitor: *
- nawasara/sync: *
- nawasara/ui: *
- spatie/laravel-permission: ^6.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
An uptime monitoring hub. It reads Uptime Kuma data and shows it on the Nawasara dashboard, so service status is visible without switching apps.
Status v0.1.0
| Feature | Status |
|---|---|
| Read monitors + status from the Kuma database | ready |
| Periodic sync to local cache | ready |
| Monitor list page + detail | ready |
| 24-hour sparkline | ready |
| Uptime percentage from Kuma aggregates | ready |
| Add/edit monitors from Nawasara | not built yet, needs a write API |
| Notification when a monitor goes down | not built yet |
Read directly from the database, not the API
Uptime Kuma 2.x does not yet have a stable read API, so this package reads its database directly, SELECT only, never writing.
The connection reuses MysqlConnection from nawasara/database-monitor: the same credentials (kmf-db, which already has GRANT SELECT ON *.*) and the same connection lifecycle (register it on use, close it afterward). Queries are prefixed with the Kuma database name so they run across databases without swapping the default connection.
Note: this ties the package to Kuma's internal schema. The targeted version is named in the config (kuma_version, currently 2.0.0-beta.3); a Kuma upgrade can change its schema and break the reads. If Kuma later provides a stable read API, that is the better path.
Uptime percentage uses Kuma aggregates
Kuma already computes stat_daily, stat_hourly, and stat_minutely. This package reads those tables instead of scanning raw heartbeat rows.
The difference matters: the heartbeat table grows to hundreds of thousands of rows per monitor, and computing a percentage by scanning it would load the Kuma database, the very database whose main job is monitoring and which must not slow down.
Setup
composer require nawasara/uptime
php artisan migrate
php artisan db:seed --class="Nawasara\Uptime\Database\Seeders\PermissionSeeder"
Add this to resources/css/app.css:
@source "../../vendor/nawasara/uptime";
Configure via .env:
UPTIME_KUMA_DATABASE=terraform_uptime_kuma UPTIME_KUMA_URL=https://kuma.example.id # for the "open in Kuma" link UPTIME_SYNC_INTERVAL=1 # minutes UPTIME_SPARKLINE_HOURS=24 UPTIME_SCHEDULER_ENABLED=true
This package requires nawasara/database-monitor to be installed with its credentials filled in Vault, since that is where the connection to the Kuma database comes from.
Sync
SyncMonitorsJob copies the monitor list and their status into the local nawasara_uptime_monitors table, scheduled every sync_interval minutes.
The local cache exists so pages stay open when the Kuma database is unreachable: what shows is the last known data, not an error screen. Stale status is more useful than no status.
Roadmap
- Add/edit monitors from Nawasara (needs the Kuma write API)
- Notification when a monitor goes down, via
nawasara/notification - Public status for citizens (a service status page)
Author
Pringgo J. Saputro, Dinas Kominfo Kabupaten Ponorogo
License
MIT