mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-18 04:38:09 +00:00
don't refresh system stats when only reporting process stats (#784)
This commit is contained in:
@ -301,12 +301,15 @@ fn try_report_iter_update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn report_fuzzer_sys_info(worker_id: usize, run_id: Uuid, fuzzer_pid: u32) -> Result<()> {
|
async fn report_fuzzer_sys_info(worker_id: usize, run_id: Uuid, fuzzer_pid: u32) -> Result<()> {
|
||||||
loop {
|
|
||||||
system::refresh()?;
|
|
||||||
|
|
||||||
// Allow for sampling CPU usage.
|
// Allow for sampling CPU usage.
|
||||||
time::delay_for(PROC_INFO_COLLECTION_DELAY).await;
|
time::delay_for(PROC_INFO_COLLECTION_DELAY).await;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
// process doesn't exist
|
||||||
|
if !system::refresh_process(fuzzer_pid)? {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(proc_info) = system::proc_info(fuzzer_pid)? {
|
if let Some(proc_info) = system::proc_info(fuzzer_pid)? {
|
||||||
event!(process_stats;
|
event!(process_stats;
|
||||||
EventData::WorkerId = worker_id,
|
EventData::WorkerId = worker_id,
|
||||||
|
@ -22,6 +22,11 @@ pub fn proc_info(pid: u32) -> Result<Option<ProcInfo>> {
|
|||||||
Ok(s.proc_info(pid))
|
Ok(s.proc_info(pid))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn refresh_process(pid: u32) -> Result<bool> {
|
||||||
|
let mut s = SYSTEM.write().map_err(|e| format_err!("{}", e))?;
|
||||||
|
Ok(s.refresh_process(pid))
|
||||||
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref SYSTEM: RwLock<System> = {
|
static ref SYSTEM: RwLock<System> = {
|
||||||
let mut s = System::new();
|
let mut s = System::new();
|
||||||
@ -56,6 +61,10 @@ impl System {
|
|||||||
self.system.refresh_all();
|
self.system.refresh_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn refresh_process(&mut self, pid: u32) -> bool {
|
||||||
|
self.system.refresh_process(pid as Pid)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn system_info(&self) -> SystemInfo {
|
pub fn system_info(&self) -> SystemInfo {
|
||||||
let system = &self.system;
|
let system = &self.system;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user