parse /proc/meminfo for memory usage (#7)

* fix: calculate memory usage via /proc/meminfo

* refactor: move sysinfo call into get_current

No longer used by anything but uptime.
This commit is contained in:
Ryan 2024-08-15 16:14:27 +08:00 committed by GitHub
commit 1cf4f754ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 17 deletions

View file

@ -1,8 +1,9 @@
use color_eyre::Result;
use nix::sys::sysinfo::SysInfo;
use nix::sys::sysinfo::sysinfo;
use std::io;
pub fn get_current(info: &SysInfo) -> Result<String, io::Error> {
pub fn get_current() -> Result<String, io::Error> {
let info = sysinfo().map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
let uptime_seconds = info.uptime().as_secs_f64();
let total_minutes = (uptime_seconds / 60.0).round() as u64;