Add "database_memory_usage" AdminCommand

This commit is contained in:
Andrej Kacian 2022-01-09 20:07:50 +01:00 committed by Timo Kösters
parent 71431f330a
commit ff243870f8
No known key found for this signature in database
GPG key ID: 356E705610F626D5
2 changed files with 11 additions and 0 deletions

View file

@ -14,6 +14,7 @@ pub enum AdminCommand {
RegisterAppservice(serde_yaml::Value), RegisterAppservice(serde_yaml::Value),
UnregisterAppservice(String), UnregisterAppservice(String),
ListAppservices, ListAppservices,
ShowMemoryUsage,
SendMessage(RoomMessageEventContent), SendMessage(RoomMessageEventContent),
} }
@ -113,6 +114,13 @@ impl Admin {
send_message(RoomMessageEventContent::text_plain("Failed to get appservices."), guard, &state_lock); send_message(RoomMessageEventContent::text_plain("Failed to get appservices."), guard, &state_lock);
} }
} }
AdminCommand::ShowMemoryUsage => {
if let Ok(response) = guard._db.memory_usage() {
send_message(RoomMessageEventContent::text_plain(response), guard, &state_lock);
} else {
send_message(RoomMessageEventContent::text_plain("Failed to get database memory usage".to_string()), guard, &state_lock);
}
}
AdminCommand::SendMessage(message) => { AdminCommand::SendMessage(message) => {
send_message(message, guard, &state_lock); send_message(message, guard, &state_lock);
} }

View file

@ -1693,6 +1693,9 @@ impl Rooms {
)); ));
} }
} }
"database_memory_usage" => {
db.admin.send(AdminCommand::ShowMemoryUsage);
}
_ => { _ => {
db.admin.send(AdminCommand::SendMessage( db.admin.send(AdminCommand::SendMessage(
RoomMessageEventContent::text_plain(format!( RoomMessageEventContent::text_plain(format!(