[−][src]Crate procshot_server
This crate can be used to continuously scan over /proc
filesystem and store it in the struct `EncoDecode. This struct is serialized and is written to /var/log/procshot/data.
This is a wrapper over the procfs crate, so the compatibility of this crate depends on the compatibility of the procfs crate.
The stored data is of type EncoDecode
and can be read as:
Examples
use std::fs::File; use std::io::Read; use procshot_server::EncoDecode; pub fn read_test_data() { let mut file = File::open("./test_data.procshot").unwrap(); let mut data = Vec::new(); file.read_to_end(&mut data).unwrap(); let decoded: EncoDecode = bincode::deserialize(&data[..]).unwrap_or_else(|x| panic!("Error reading saved data. This was either created with an older version of procshot, or the file is corrupt. Error is {}", x)); println!("Decoded test file data: {:#?}", decoded); }
Structs
Config | Config struct holds the user input when running the server. It is a bad design to hold the client's option as well in the same struct, but as of now, it is here. |
EncoDecode | EncodDecode is the struct that we use to hold additional metadata and write to disk as
serialized data of the form |
PidStatus | PidStatus is the struct that holds the data that we store for each process' status. In this crate, we create a
|
Functions
check_sudo | Checks if the program is run as sudo (root) user. This doesn't check if the user has the privilege to read over all of /proc or write to /var/log
but just checks if the uid passed to this is 0, and returns a |
scan_proc | scan_proc continuously scans /proc and records all the processes.
scan_proc omits the pids if status.vmpeak == None || prc.stat.rss == 0 || status.pid < 0.
One file is created for each iteration and sleeps for |