Commit 2acfa487 authored by Curtis Men's avatar Curtis Men
Browse files

upd: report mechanism

parent 6ed105bb
No related merge requests found
Showing with 6 additions and 4 deletions
+6 -4
...@@ -12,5 +12,5 @@ ctrlc = "3.2.2" ...@@ -12,5 +12,5 @@ ctrlc = "3.2.2"
tokio = "1.19.2" tokio = "1.19.2"
lazy_static = "1.4.0" lazy_static = "1.4.0"
serde_json = "1.0.82" serde_json = "1.0.82"
reqwest = {version = "0.11.11", features = ["blocking"]} reqwest = {version = "0.11.11", features = ["blocking", "json"]}
clap = { version = "3.2.17", features = ["derive"] } clap = { version = "3.2.17", features = ["derive"] }
...@@ -134,7 +134,7 @@ pub(crate) fn dump_result() -> Result<(), std::io::Error>{ ...@@ -134,7 +134,7 @@ pub(crate) fn dump_result() -> Result<(), std::io::Error>{
pub (crate) fn report_result(master_server: &str) -> Result<(), Box<dyn Error>>{ pub (crate) fn report_result(master_server: &str) -> Result<(), Box<dyn Error>>{
let client = reqwest::blocking::Client::new(); let client = reqwest::blocking::Client::new();
let stats = match File::open("secmonitor-stats.json") { /*let stats = match File::open("secmonitor-stats.json") {
Ok(file) => file, Ok(file) => file,
Err(_) => { Err(_) => {
let mut new_file = File::create("secmonitor-stats.json")?; let mut new_file = File::create("secmonitor-stats.json")?;
...@@ -142,10 +142,12 @@ pub (crate) fn report_result(master_server: &str) -> Result<(), Box<dyn Error>>{ ...@@ -142,10 +142,12 @@ pub (crate) fn report_result(master_server: &str) -> Result<(), Box<dyn Error>>{
new_file new_file
} }
}; };*/
let mut report_body = HashMap::<String, HashMap<u32, u64>>::new();
report_body.insert("data".to_string(), SYSCALL_COUNTER.lock().unwrap().clone());
let resp = client.post(master_server) let resp = client.post(master_server)
.body(stats) .json(&report_body)
.send()? .send()?
.text()?; .text()?;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment