mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Worst 10 stats are no longer stored globally in lqos_node_manager. Instead, they are only calculated when requested. Slightly higher utilization with lots of people using the node manager, and no bus traffic during the 99% of the time when its idle.
This commit is contained in:
parent
9f8bf22ff9
commit
67c8f9dec0
@ -1,12 +1,11 @@
|
||||
use lqos_bus::IpStats;
|
||||
use once_cell::sync::Lazy;
|
||||
use std::sync::RwLock;
|
||||
|
||||
//pub static TOP_10_DOWNLOADERS: Lazy<RwLock<Vec<IpStats>>> =
|
||||
// Lazy::new(|| RwLock::new(Vec::with_capacity(10)));
|
||||
|
||||
pub static WORST_10_RTT: Lazy<RwLock<Vec<IpStats>>> =
|
||||
Lazy::new(|| RwLock::new(Vec::with_capacity(10)));
|
||||
//pub static WORST_10_RTT: Lazy<RwLock<Vec<IpStats>>> =
|
||||
// Lazy::new(|| RwLock::new(Vec::with_capacity(10)));
|
||||
|
||||
pub static RTT_HISTOGRAM: Lazy<RwLock<Vec<u32>>> =
|
||||
Lazy::new(|| RwLock::new(Vec::with_capacity(100)));
|
||||
|
@ -129,16 +129,12 @@ fn watch_for_shaped_devices_changing() -> Result<()> {
|
||||
async fn get_data_from_server() -> Result<()> {
|
||||
// Send request to lqosd
|
||||
let requests = vec![
|
||||
BusRequest::GetWorstRtt { start: 0, end: 10 },
|
||||
BusRequest::RttHistogram,
|
||||
BusRequest::AllUnknownIps,
|
||||
];
|
||||
|
||||
for r in bus_request(requests).await?.iter() {
|
||||
match r {
|
||||
BusResponse::WorstRtt(stats) => {
|
||||
*WORST_10_RTT.write().unwrap() = stats.clone();
|
||||
}
|
||||
BusResponse::RttHistogram(stats) => {
|
||||
*RTT_HISTOGRAM.write().unwrap() = stats.clone();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ mod cache;
|
||||
mod cache_manager;
|
||||
use self::cache::{
|
||||
CPU_USAGE, HOST_COUNTS, NUM_CPUS, RAM_USED, RTT_HISTOGRAM,
|
||||
TOTAL_RAM, WORST_10_RTT,
|
||||
TOTAL_RAM,
|
||||
};
|
||||
use crate::{auth_guard::AuthGuard, cache_control::NoCache};
|
||||
pub use cache::{SHAPED_DEVICES, UNKNOWN_DEVICES};
|
||||
@ -123,10 +123,18 @@ pub async fn top_10_downloaders(_auth: AuthGuard) -> NoCache<Json<Vec<IpStatsWit
|
||||
}
|
||||
|
||||
#[get("/api/worst_10_rtt")]
|
||||
pub fn worst_10_rtt(_auth: AuthGuard) -> Json<Vec<IpStatsWithPlan>> {
|
||||
let tt: Vec<IpStatsWithPlan> =
|
||||
WORST_10_RTT.read().unwrap().iter().map(|tt| tt.into()).collect();
|
||||
Json(tt)
|
||||
pub async fn worst_10_rtt(_auth: AuthGuard) -> NoCache<Json<Vec<IpStatsWithPlan>>> {
|
||||
if let Ok(messages) = bus_request(vec![BusRequest::GetWorstRtt { start: 0, end: 10 }]).await
|
||||
{
|
||||
for msg in messages {
|
||||
if let BusResponse::WorstRtt(stats) = msg {
|
||||
let result = stats.iter().map(|tt| tt.into()).collect();
|
||||
return NoCache::new(Json(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NoCache::new(Json(Vec::new()))
|
||||
}
|
||||
|
||||
#[get("/api/rtt_histogram")]
|
||||
|
Loading…
Reference in New Issue
Block a user