Skip to content

Commit bac50ac

Browse files
authored
Merge pull request #661 from bytedance/feat-heatbeat-info
heartbeat report add info field
2 parents 57c6a9d + 5b32dd9 commit bac50ac

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

rasp/librasp/src/process.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub struct ProcessInfo {
4444
pub start_time: Option<f32>,
4545
pub try_attach_count: u16,
4646
pub attached_count: u16,
47+
pub failed_reason:Option<String>,
4748
}
4849

4950
#[allow(non_camel_case_types)]
@@ -219,6 +220,13 @@ impl ProcessInfo {
219220
}
220221
Ok(self.namespace_info.clone().unwrap())
221222
}
223+
224+
pub fn update_failed_reason(&mut self, reason: &String) -> AnyhowResult<()> {
225+
if self.failed_reason.is_none() {
226+
self.failed_reason = Some(reason.clone());
227+
}
228+
Ok(())
229+
}
222230
pub fn get_mnt_ns(&self) -> AnyhowResult<String> {
223231
if let Some(ref ns) = self.namespace_info {
224232
return match ns.mnt.clone() {

rasp/plugin/src/monitor.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ fn internal_main(
486486
) {
487487
warn!("operation thread send command to receiver err: {}, pid: {}", e, process.pid);
488488
}
489+
let _ = process.update_failed_reason(&e.to_string());
490+
let mut opp = operation_process_rw.write();
491+
opp.insert(process.pid, process.clone());
492+
drop(opp);
493+
489494
continue;
490495
}
491496
};

rasp/plugin/src/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub fn generate_heartbeat(watched_process: &ProcessInfo) -> HashMap<&'static str
4747
message.insert("try_attach_count", watched_process.try_attach_count.to_string());
4848
message.insert("attached_count", watched_process.attached_count.to_string());
4949
message.insert("probe_version", RASP_VERSION.to_string());
50+
message.insert("info", watched_process.failed_reason.clone().unwrap_or("".to_string()));
5051
message.insert("uptime", match count_uptime(watched_process.start_time.unwrap_or(0 as f32)) {
5152
Ok(t) => t.to_string(),
5253
Err(e) => {

0 commit comments

Comments
 (0)