feat: add swap info

This commit is contained in:
utox39
2025-03-12 00:20:24 +01:00
parent d38cb7b413
commit 68b735179d

View File

@@ -47,6 +47,17 @@ pub fn main() !void {
try stdout.print("ram: {d:.2} / {d:.2} GB ({}%)\n", .{ ram_info.ram_usage, ram_info.ram_size, ram_info.ram_usage_percentage }); try stdout.print("ram: {d:.2} / {d:.2} GB ({}%)\n", .{ ram_info.ram_usage, ram_info.ram_size, ram_info.ram_usage_percentage });
try bw.flush(); try bw.flush();
const swap_result = try os_module.getSwapInfo();
switch (swap_result) {
.swap_info => |s| {
try stdout.print("Swap: {d:.2} / {d:.2} GB ({}%)\n", .{ s.swap_usage, s.swap_size, s.swap_usage_percentage });
},
.swap_disabled => {
try stdout.print("Swap: Disabled\n", .{});
},
}
try bw.flush();
const diskInfo = try os_module.getDiskSize("/"); const diskInfo = try os_module.getDiskSize("/");
try stdout.print("disk ({s}): {d:.2} / {d:.2} GB ({}%)\n", .{ diskInfo.disk_path, diskInfo.disk_usage, diskInfo.disk_size, diskInfo.disk_usage_percentage }); try stdout.print("disk ({s}): {d:.2} / {d:.2} GB ({}%)\n", .{ diskInfo.disk_path, diskInfo.disk_usage, diskInfo.disk_size, diskInfo.disk_usage_percentage });
try bw.flush(); try bw.flush();