Fix ps sys units (#2967)

* Fix the units for sys and ps

* Better conversion
This commit is contained in:
Jonathan Turner 2021-01-25 08:34:43 +13:00 committed by GitHub
parent 52dc04a35a
commit b692ca7896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -35,8 +35,11 @@ pub async fn ps(tag: Tag, long: bool) -> Result<Vec<Value>, ShellError> {
"cpu",
UntaggedValue::decimal_from_float(process.cpu_usage() as f64, tag.span),
);
dict.insert_untagged("mem", UntaggedValue::filesize(process.memory()));
dict.insert_untagged("virtual", UntaggedValue::filesize(process.virtual_memory()));
dict.insert_untagged("mem", UntaggedValue::filesize(process.memory() * 1000));
dict.insert_untagged(
"virtual",
UntaggedValue::filesize(process.virtual_memory() * 1000),
);
if long {
if let Some(parent) = process.parent() {

View File

@ -100,10 +100,10 @@ pub fn mem(sys: &mut System, tag: Tag) -> Option<UntaggedValue> {
let total_swap = sys.get_total_swap();
let free_swap = sys.get_free_swap();
dict.insert_untagged("total", UntaggedValue::filesize(total_mem));
dict.insert_untagged("free", UntaggedValue::filesize(free_mem));
dict.insert_untagged("swap total", UntaggedValue::filesize(total_swap));
dict.insert_untagged("swap free", UntaggedValue::filesize(free_swap));
dict.insert_untagged("total", UntaggedValue::filesize(total_mem * 1000));
dict.insert_untagged("free", UntaggedValue::filesize(free_mem * 1000));
dict.insert_untagged("swap total", UntaggedValue::filesize(total_swap * 1000));
dict.insert_untagged("swap free", UntaggedValue::filesize(free_swap * 1000));
Some(dict.into_untagged_value())
}