|
|
@ -29,20 +29,11 @@ use aya::{programs::Lsm, Btf};
|
|
|
|
{%- when "tp_btf" -%}
|
|
|
|
{%- when "tp_btf" -%}
|
|
|
|
use aya::{programs::BtfTracePoint, Btf};
|
|
|
|
use aya::{programs::BtfTracePoint, Btf};
|
|
|
|
{%- endcase %}
|
|
|
|
{%- endcase %}
|
|
|
|
use std::{
|
|
|
|
use log::info;
|
|
|
|
convert::TryInto,
|
|
|
|
use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
|
|
|
|
sync::Arc,
|
|
|
|
use std::convert::TryInto;
|
|
|
|
sync::atomic::{AtomicBool, Ordering},
|
|
|
|
|
|
|
|
thread,
|
|
|
|
|
|
|
|
time::Duration,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
use structopt::StructOpt;
|
|
|
|
use structopt::StructOpt;
|
|
|
|
|
|
|
|
use tokio::signal;
|
|
|
|
fn main() {
|
|
|
|
|
|
|
|
if let Err(e) = try_main() {
|
|
|
|
|
|
|
|
eprintln!("error: {:#}", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, StructOpt)]
|
|
|
|
#[derive(Debug, StructOpt)]
|
|
|
|
struct Opt {
|
|
|
|
struct Opt {
|
|
|
@ -58,8 +49,20 @@ struct Opt {
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn try_main() -> Result<(), anyhow::Error> {
|
|
|
|
#[tokio::main]
|
|
|
|
|
|
|
|
async fn main() -> Result<(), anyhow::Error> {
|
|
|
|
let opt = Opt::from_args();
|
|
|
|
let opt = Opt::from_args();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TermLogger::init(
|
|
|
|
|
|
|
|
LevelFilter::Debug,
|
|
|
|
|
|
|
|
ConfigBuilder::new()
|
|
|
|
|
|
|
|
.set_target_level(LevelFilter::Error)
|
|
|
|
|
|
|
|
.set_location_level(LevelFilter::Error)
|
|
|
|
|
|
|
|
.build(),
|
|
|
|
|
|
|
|
TerminalMode::Mixed,
|
|
|
|
|
|
|
|
ColorChoice::Auto,
|
|
|
|
|
|
|
|
)?;
|
|
|
|
|
|
|
|
|
|
|
|
// This will include youe eBPF object file as raw bytes at compile-time and load it at
|
|
|
|
// This will include youe eBPF object file as raw bytes at compile-time and load it at
|
|
|
|
// runtime. This approach is recommended for most real-world use cases. If you would
|
|
|
|
// runtime. This approach is recommended for most real-world use cases. If you would
|
|
|
|
// like to specify the eBPF program at runtime rather than at compile-time, you can
|
|
|
|
// like to specify the eBPF program at runtime rather than at compile-time, you can
|
|
|
@ -133,18 +136,9 @@ fn try_main() -> Result<(), anyhow::Error> {
|
|
|
|
program.attach()?;
|
|
|
|
program.attach()?;
|
|
|
|
{%- endcase %}
|
|
|
|
{%- endcase %}
|
|
|
|
|
|
|
|
|
|
|
|
let running = Arc::new(AtomicBool::new(true));
|
|
|
|
info!("Waiting for Ctrl-C...");
|
|
|
|
let r = running.clone();
|
|
|
|
signal::ctrl_c().await?;
|
|
|
|
|
|
|
|
info!("Exiting...");
|
|
|
|
ctrlc::set_handler(move || {
|
|
|
|
|
|
|
|
r.store(false, Ordering::SeqCst);
|
|
|
|
|
|
|
|
}).expect("Error setting Ctrl-C handler");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
println!("Waiting for Ctrl-C...");
|
|
|
|
|
|
|
|
while running.load(Ordering::SeqCst) {
|
|
|
|
|
|
|
|
thread::sleep(Duration::from_millis(500))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
println!("Exiting...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|