management "stats" command

This commit is contained in:
Mike Dilger 2025-02-11 10:52:22 +13:00
parent cbd3d0fa19
commit da897b950e
No known key found for this signature in database
GPG Key ID: 47581A78D4329BA4

View File

@ -108,6 +108,7 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
"supportedmethods",
"numconnections",
"uptime",
"stats",
"listadmins",
"listmoderators",
"grantmoderator",
@ -213,6 +214,21 @@ pub fn handle_inner(pubkey: Pubkey, command: Value) -> Result<Option<Value>, Err
"result": uptime_in_secs,
})))
}
"stats" => {
let store_stats = GLOBALS.store.get().unwrap().stats()?;
Ok(Some(json!({
"result": {
"uptime": GLOBALS.start_time.elapsed().as_secs(),
"num_connections": &GLOBALS.num_connections,
"bytes_received": &GLOBALS.bytes_inbound,
"bytes_sent": &GLOBALS.bytes_outbound,
"event_bytes": store_stats.event_bytes,
"num_events": store_stats.index_stats.i_index_entries,
"index_disk_usage": store_stats.index_stats.disk_usage,
"index_memory_usage": store_stats.index_stats.memory_usage,
}
})))
}
"listadmins" => {
let keys = GLOBALS.config.read().admin_hex_keys.clone();
Ok(Some(json!({