mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-20 18:55:28 +00:00
feat(dashboard): Database usage task, API and settings
The database_usage task (hourly) measures on the background connection, checks the free space on the database's disk (database_disk_path, else the SQLite file or a local MySQL data directory) and alerts once when it drops under database_disk_warn_percent. Log pruning keeps database_usage_days. GET /api/database/usage?range=day|week|month. The settings are on the Settings page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -217,6 +217,7 @@ namespace {
|
||||
std::tuple{ std::optional<eLog>(), "log_task_days", 90 },
|
||||
std::tuple{ std::optional<eLog>(), "health_days", 30 },
|
||||
std::tuple{ std::optional<eLog>(), "traffic_days", 30 },
|
||||
std::tuple{ std::optional<eLog>(), "database_usage_days", 365 },
|
||||
std::tuple{ std::optional<eLog>(), "position_history_days", 3 } }) {
|
||||
const auto days = Setting(key, fallback);
|
||||
run->Log(std::string(key) + " = " + (days > 0 ? std::to_string(days) : "0 (keep everything)"));
|
||||
@@ -230,6 +231,7 @@ namespace {
|
||||
const auto before = now - days * DAY_SECONDS;
|
||||
pruned[key] = log ? db.PruneLog(*log, before) : key == std::string("health_days") ? db.PruneHealthSamples(before)
|
||||
: key == std::string("traffic_days") ? db.PruneTrafficMinutes(before)
|
||||
: key == std::string("database_usage_days") ? db.PruneDatabaseUsage(before)
|
||||
: key == std::string("position_history_days") ? db.PrunePositionSamples(before) : db.PruneTaskRuns(before);
|
||||
}
|
||||
return pruned;
|
||||
|
||||
Reference in New Issue
Block a user