Skip to main content

systemprompt_api/services/server/
health_stats.rs

1//! Serialized shapes of the detailed health surface: process memory, disk
2//! usage, database and table sizes, and audit-log statistics.
3//!
4//! Copyright (c) systemprompt.io — Business Source License 1.1.
5//! See <https://systemprompt.io> for licensing details.
6
7use serde::Serialize;
8
9#[derive(Debug, Clone, Copy, Serialize)]
10pub struct ProcessMemory {
11    #[serde(rename = "rss_mb")]
12    pub rss: Option<u64>,
13    #[serde(rename = "virtual_mb")]
14    pub virtual_size: Option<u64>,
15    #[serde(rename = "peak_mb")]
16    pub peak: Option<u64>,
17}
18
19#[derive(Debug, Clone, Serialize)]
20pub struct DiskUsage {
21    pub total: String,
22    pub used: String,
23    pub available: String,
24    pub usage_percent: f64,
25}
26
27#[derive(Debug, Clone, Serialize)]
28pub struct SystemStats {
29    pub database: Option<DatabaseStats>,
30    pub disk: Option<DiskUsage>,
31    pub logs: Option<AuditLogStats>,
32}
33
34#[derive(Debug, Clone, Serialize)]
35pub struct DatabaseStats {
36    pub name: String,
37    pub total_size: String,
38    pub total_size_bytes: i64,
39    pub table_count: i64,
40    pub top_tables: Vec<TableStats>,
41}
42
43#[derive(Debug, Clone, Serialize)]
44pub struct TableStats {
45    pub table_name: String,
46    pub total_size: String,
47    pub total_size_bytes: i64,
48    pub row_estimate: i64,
49}
50
51#[derive(Debug, Clone, Serialize)]
52pub struct AuditLogStats {
53    pub audit_rows: i64,
54    pub audit_size: String,
55    pub audit_size_bytes: i64,
56    // JSON: runtime `JsonRow` cell — `MIN(created_at)` as the database driver rendered it.
57    pub oldest: Option<serde_json::Value>,
58    // JSON: runtime `JsonRow` cell — `MAX(created_at)` as the database driver rendered it.
59    pub newest: Option<serde_json::Value>,
60}