1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add more db stats to chat command

This commit is contained in:
NG (Graham)
2026-01-05 20:34:53 -05:00
parent 0465f0664b
commit 47df45ece9
5 changed files with 35 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ pub type UserTy = std::sync::Arc<oj_rc_core::UserState>;
pub static START_TIMESTAMP_S: std::sync::atomic::AtomicI64 = std::sync::atomic::AtomicI64::new(0);
pub static READY_DURATION_NS: std::sync::atomic::AtomicI64 = std::sync::atomic::AtomicI64::new(0);
pub static ONLINE_USERS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
pub static LOGINS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
#[tokio::main]
async fn main() -> std::io::Result<()> {
@@ -67,6 +68,7 @@ async fn process_socket(mut socket: net::TcpStream, address: std::net::SocketAdd
return;
}
};
LOGINS.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
ONLINE_USERS.store(chat.system().await.user_count() as u64 + 1, std::sync::atomic::Ordering::SeqCst);
let (chann_tx, chann_rx) = tokio::sync::mpsc::unbounded_channel();
let user_state = std::sync::Arc::new(oj_rc_core::UserState::<()>::new(users, chann_tx.clone()));

View File

@@ -171,9 +171,13 @@ impl BuiltIn {
"db" | "database" => {
let db_stats = format!("(chat db) {}", ctx.user.db_metrics().await);
stats.push(db_stats);
let counters = ctx.user.db_counters().await;
for (key, val) in counters {
stats.push(format!("(db) {}: {}", key, val));
}
},
"perms" | "permission" | "permissions" => {
let com_stats = format!("(perms {}) mod:{} admin:{} dev:{} banned:{} royal:{}",
let com_stats = format!("(perms {}) mod:{} admin:{} dev:{} banned:{} r:{}",
ctx.user.public_id(),
ctx.user.is_mod(),
ctx.user.is_admin(),
@@ -245,7 +249,7 @@ impl BuiltIn {
Self::System(s) => s.do_help(),
Self::OnlineUsers => "Show total users online".to_owned(),
Self::TotalUsers => "Show total users registered".to_owned(),
Self::Stats => "Show server metrics (db|perms)".to_owned(),
Self::Stats => "Show server metrics (db|perms|uptime|counts)".to_owned(),
Self::Version => "Show chat server version information".to_owned(),
Self::Help => "Display this message".to_owned(),
}