Fix warnings, implement Errors
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
use std::net::IpAddr;
|
||||
|
||||
use clap::ArgGroup;
|
||||
use serde::de;
|
||||
|
||||
#[derive(Debug, Clone, clap::Parser, Default)]
|
||||
#[command(
|
||||
|
||||
@@ -12,7 +12,7 @@ use clap::Parser;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tabled::Tabled;
|
||||
|
||||
use crate::config::cli::{CliArgs, CliCommand};
|
||||
use crate::config::cli::CliArgs;
|
||||
|
||||
const DEFAULT_CONFIG: &'static str = include_str!("../../config.default.toml");
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(dead_code)]
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::prelude::*;
|
||||
|
||||
|
||||
27
src/main.rs
27
src/main.rs
@@ -13,11 +13,9 @@ use std::{
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
use clap::builder;
|
||||
use diesel::{ExpressionMethods, RunQueryDsl};
|
||||
use diesel::{ExpressionMethods, RunQueryDsl, query_dsl::methods::FilterDsl};
|
||||
use log::LevelFilter;
|
||||
use serde_json::json;
|
||||
use tabled::Table;
|
||||
use tokio::time::{self, Duration};
|
||||
|
||||
use crate::{
|
||||
@@ -25,7 +23,10 @@ use crate::{
|
||||
Config, ConfigHost,
|
||||
cli::{CliCommand, CliDeviceCommand, OutputFormat},
|
||||
},
|
||||
db::models::{NewAntenna, NewClientReading},
|
||||
db::{
|
||||
models::{NewAntenna, NewClientReading},
|
||||
schema::antennas,
|
||||
},
|
||||
};
|
||||
|
||||
mod config;
|
||||
@@ -92,7 +93,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
let v6_cmd = "/interface/wireless/registration-table/print";
|
||||
let v7_cmd = "/interface/wifi/registration-table/print";
|
||||
|
||||
let mut interval = time::interval(Duration::from_secs(5));
|
||||
let mut interval = time::interval(Duration::from_mins(3));
|
||||
|
||||
loop {
|
||||
interval.tick().await;
|
||||
@@ -143,7 +144,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
if client_db.contains("@") {
|
||||
client_db = client_db.split('@').nth(0).unwrap().to_string();
|
||||
}
|
||||
dbg!(&client_db);
|
||||
|
||||
let client_db =
|
||||
parse_int::parse::<i32>(&client_db).expect("Unparseble number");
|
||||
records.push(NewClientReading {
|
||||
@@ -155,11 +156,17 @@ async fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
}
|
||||
Ok(_) => unreachable!(),
|
||||
Err(_) => {}
|
||||
Err(e) => {
|
||||
diesel::update(
|
||||
antennas::table.filter(antennas::ip.eq(antenna.ip.to_string())),
|
||||
)
|
||||
.set(antennas::error.eq(e.to_string()))
|
||||
.execute(&mut conn)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log::info!("inserting: {records:?}");
|
||||
log::debug!("inserting: {records:?}");
|
||||
diesel::insert_into(crate::db::schema::client_readings::table)
|
||||
.values(&records)
|
||||
.execute(&mut conn)
|
||||
@@ -309,7 +316,7 @@ fn print_output(
|
||||
e.to_string(),
|
||||
];
|
||||
|
||||
for wanted_col in &wanted_cols {
|
||||
for _ in &wanted_cols {
|
||||
row.push(String::new());
|
||||
}
|
||||
table.push(row);
|
||||
@@ -374,7 +381,7 @@ fn print_output(
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let mut row = vec![
|
||||
let _ = vec![
|
||||
host.name.clone(),
|
||||
host.ip.clone().to_string(),
|
||||
e.to_string(),
|
||||
|
||||
@@ -10,14 +10,12 @@
|
||||
use core::panic;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
hash::Hash,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use anyhow::bail;
|
||||
use futures::future::join_all;
|
||||
use mikrotik_rs::{Command, CommandBuilder, Event, MikrotikDevice};
|
||||
use regex::Regex;
|
||||
use mikrotik_rs::{CommandBuilder, Event, MikrotikDevice};
|
||||
|
||||
use crate::config::{Config, ConfigHost};
|
||||
|
||||
@@ -97,6 +95,7 @@ impl MtCommander {
|
||||
}*/
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl MtCommanderInternal {
|
||||
fn new(cfg: Config) -> Self {
|
||||
Self { cfg: Some(cfg) }
|
||||
|
||||
Reference in New Issue
Block a user