Statistics page: the statistics database's size, and a fullness bar on the disk tiles

The server section shows the statistics database's size (with its -wal and -shm) and how many answers the query log holds, linking to the dashboard's Storage panel; the disk tiles get the same bar as the dashboard. GET /stats/server has database {path, bytes, query_log_rows}.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adamandClaude Opus 5.5 committed 2026-10-13 18:24:32 +01:00
1 parent 01ec37b9b2
commit 1b102a78f6
8 files changed
+78 -13

No files matched your search

+12 -6
View File
@@ -18,12 +18,7 @@ func (s *Server) storage(ctx context.Context) *api.Storage {
if path == "" || path == ":memory:" {
return nil
}
d := api.Database{Label: label, Path: path}
for _, suffix := range []string{"", "-wal", "-shm"} {
if fi, err := os.Stat(path + suffix); err == nil {
d.Bytes += fi.Size()
}
}
d := api.Database{Label: label, Path: path, Bytes: dbBytes(path)}
out.Databases = append(out.Databases, d)
out.Total += d.Bytes
return &out.Databases[len(out.Databases)-1]
@@ -70,3 +65,14 @@ func (s *Server) storage(ctx context.Context) *api.Storage {
}
return out
}
// dbBytes is the size of a SQLite database: its file, -wal and -shm.
func dbBytes(path string) int64 {
var n int64
for _, suffix := range []string{"", "-wal", "-shm"} {
if fi, err := os.Stat(path + suffix); err == nil {
n += fi.Size()
}
}
return n
}