diff --git a/src/config/mod.rs b/src/config/mod.rs index 96df9ac..e0df7fe 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1,15 +1,13 @@ use crate::zabbix::api::get_zabbix_authtoken; use crate::zabbix::problems::DataMatrix; use clap::App; -use nix::sys::inotify::{AddWatchFlags, InitFlags, Inotify, InotifyEvent}; +use nix::sys::inotify::{AddWatchFlags, InitFlags, Inotify}; use serde::{Deserialize, Serialize}; use serde_json::Error as JsonError; use serde_json::Value as JsonValue; use std::fs::File; use std::io::Read; use std::string::String; -use std::thread::sleep; -use std::time::Duration; #[derive(Debug)] pub enum ReloadFrequency { @@ -121,41 +119,31 @@ impl<'a> Config { Ok(cfg) => { let tmpcfg = Config::new(); Config { -<<<<<<< Updated upstream - server: cfg["server"].as_str().unwrap_or(tmpcfg.server.as_str()).to_string(), - username: cfg["username"].as_str().unwrap_or(tmpcfg.username.as_str()).to_string(), - password: cfg["password"].as_str().unwrap_or(tmpcfg.password.as_str()).to_string(), - authtoken: Some(cfg["authtoken"].as_str().unwrap_or(tmpcfg.authtoken.unwrap().as_str()).to_string()), - sloweffect: Some(cfg["sloweffect"].as_bool().unwrap_or(tmpcfg.sloweffect.unwrap())), - refresh: Some(cfg["refresh"].as_u64().unwrap_or(tmpcfg.refresh.unwrap())), - limit: Some(cfg["limit"].as_u64().unwrap_or(tmpcfg.limit.unwrap())), -======= - server: ncfg["server"] + server: cfg["server"] .as_str() - .unwrap_or(&tmpcfg.server.clone()) + .unwrap_or(tmpcfg.server.as_str()) .to_string(), - username: ncfg["username"] + username: cfg["username"] .as_str() - .unwrap_or(&tmpcfg.username.clone()) + .unwrap_or(tmpcfg.username.as_str()) .to_string(), - password: ncfg["password"] + password: cfg["password"] .as_str() - .unwrap_or(&tmpcfg.password.clone()) + .unwrap_or(tmpcfg.password.as_str()) .to_string(), authtoken: Some( - ncfg["authtoken"] + cfg["authtoken"] .as_str() - .unwrap_or(self.authtoken.clone().unwrap().as_str()) + .unwrap_or(tmpcfg.authtoken.unwrap().as_str()) .to_string(), ), sloweffect: Some( - ncfg["sloweffect"] + cfg["sloweffect"] .as_bool() .unwrap_or(tmpcfg.sloweffect.unwrap()), ), - refresh: Some(ncfg["refresh"].as_u64().unwrap_or(tmpcfg.refresh.unwrap())), - limit: Some(ncfg["limit"].as_u64().unwrap_or(tmpcfg.limit.unwrap())), ->>>>>>> Stashed changes + refresh: Some(cfg["refresh"].as_u64().unwrap_or(tmpcfg.refresh.unwrap())), + limit: Some(cfg["limit"].as_u64().unwrap_or(tmpcfg.limit.unwrap())), } } Err(err) => { @@ -163,14 +151,7 @@ impl<'a> Config { Config::new() } }; -<<<<<<< Updated upstream self.save(&configfile); -======= - *self = newcfg; - if !fileexists || errorreading { - self.save(&configfile).await; - } ->>>>>>> Stashed changes } async fn save(&self, configfile: &str) { diff --git a/src/zabbix/api.rs b/src/zabbix/api.rs index 1c0ee8a..316a130 100644 --- a/src/zabbix/api.rs +++ b/src/zabbix/api.rs @@ -51,7 +51,7 @@ async fn _async_check_zabbix_connection(cfg: &Config) -> Result Value { +fn build_query_auth_token(zabbix_username: &String, zabbix_password: &String) -> JsonValue { let zabbix_api_function = "user.login"; json!({ "jsonrpc": ZABBIX_API_VERSION, @@ -88,7 +88,7 @@ fn _build_query_problems(zabbix_token: &String, zabbix_limit: i64) -> JsonValue } /// Build the query that fetchs triggers -fn build_query_triggers(zabbix_token: &String) -> Value { +fn build_query_triggers(zabbix_token: &String) -> JsonValue { let zabbix_api_function = "trigger.get"; json!({ "jsonrpc": ZABBIX_API_VERSION,