mprober 0.10.12

This program aims to collect Linux system information including hostname, kernel version, uptime, RTC time, load average, CPU, memory, network interfaces and block devices. It can be used not only as a normal CLI tool, but also a web application with a front-end webpage and useful HTTP APIs.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::fs;
use std::io;

const HOSTNAME_PATH: &str = "/proc/sys/kernel/hostname";

#[inline]
pub fn get_hostname() -> Result<String, io::Error> {
    let mut s = fs::read_to_string(HOSTNAME_PATH)?;

    if s.ends_with('\n') {
        s.remove(s.len() - 1);
    }

    Ok(s)
}