Skip to content

Commit

Permalink
Merge pull request #661 from bytedance/feat-heatbeat-info
Browse files Browse the repository at this point in the history
heartbeat report add info field
  • Loading branch information
yoloyyh authored Jul 23, 2024
2 parents 57c6a9d + 5b32dd9 commit bac50ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rasp/librasp/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub struct ProcessInfo {
pub start_time: Option<f32>,
pub try_attach_count: u16,
pub attached_count: u16,
pub failed_reason:Option<String>,
}

#[allow(non_camel_case_types)]
Expand Down Expand Up @@ -219,6 +220,13 @@ impl ProcessInfo {
}
Ok(self.namespace_info.clone().unwrap())
}

pub fn update_failed_reason(&mut self, reason: &String) -> AnyhowResult<()> {
if self.failed_reason.is_none() {
self.failed_reason = Some(reason.clone());
}
Ok(())
}
pub fn get_mnt_ns(&self) -> AnyhowResult<String> {
if let Some(ref ns) = self.namespace_info {
return match ns.mnt.clone() {
Expand Down
5 changes: 5 additions & 0 deletions rasp/plugin/src/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ fn internal_main(
) {
warn!("operation thread send command to receiver err: {}, pid: {}", e, process.pid);
}
let _ = process.update_failed_reason(&e.to_string());
let mut opp = operation_process_rw.write();
opp.insert(process.pid, process.clone());
drop(opp);

continue;
}
};
Expand Down
1 change: 1 addition & 0 deletions rasp/plugin/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn generate_heartbeat(watched_process: &ProcessInfo) -> HashMap<&'static str
message.insert("try_attach_count", watched_process.try_attach_count.to_string());
message.insert("attached_count", watched_process.attached_count.to_string());
message.insert("probe_version", RASP_VERSION.to_string());
message.insert("info", watched_process.failed_reason.clone().unwrap_or("".to_string()));
message.insert("uptime", match count_uptime(watched_process.start_time.unwrap_or(0 as f32)) {
Ok(t) => t.to_string(),
Err(e) => {
Expand Down

0 comments on commit bac50ac

Please sign in to comment.