Skip to content

Commit

Permalink
Chore: Add %
Browse files Browse the repository at this point in the history
  • Loading branch information
Blu-J committed Oct 22, 2024
1 parent b00879e commit d8e7a56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions core/startos/src/lxc/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ pub fn lxc<C: Context>() -> ParentHandler<C> {
from_fn_async(stats)
.with_custom_display_fn(|_, res| {
use prettytable::*;
let mut table =
table!(["Container ID", "Name", "Memory Usage", "Memory Limit"]);
let mut table = table!([
"Container ID",
"Name",
"Memory Usage",
"Memory Limit",
"Memory %"
]);
for ServiceStats {
container_id,
package_id,
Expand All @@ -57,7 +62,11 @@ pub fn lxc<C: Context>() -> ParentHandler<C> {
&*container_id,
&*package_id,
memory_usage,
memory_limit
memory_limit,
format!(
"{:.2}",
memory_usage.0 as f64 / memory_limit.0 as f64 * 100.0
)
]);
}
table.printstd();
Expand Down
2 changes: 1 addition & 1 deletion core/startos/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub enum LoadDisposition {
struct RootCommand(pub String);

#[derive(Clone, Debug, Serialize, Deserialize, Default, TS)]
pub struct MiB(u64);
pub struct MiB(pub u64);

impl MiB {
fn new(value: u64) -> Self {
Expand Down

0 comments on commit d8e7a56

Please sign in to comment.