mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-16 14:34:45 -06:00
Include RTT events per second tracking in the /api/stats call
This commit is contained in:
parent
f44af37670
commit
beda42194a
@ -89,6 +89,8 @@ pub enum BusResponse {
|
||||
high_watermark: (u64, u64),
|
||||
/// Number of flows tracked
|
||||
tracked_flows: u64,
|
||||
/// RTT events per second
|
||||
rtt_events_per_second: u64,
|
||||
},
|
||||
|
||||
/// The index of the new packet collection session
|
||||
|
@ -66,17 +66,19 @@ pub struct LqosStats {
|
||||
pub time_to_poll_hosts_us: u64,
|
||||
pub high_watermark: (u64, u64),
|
||||
pub tracked_flows: u64,
|
||||
pub rtt_events_per_second: u64,
|
||||
}
|
||||
|
||||
#[get("/api/stats")]
|
||||
pub async fn stats() -> NoCache<Json<LqosStats>> {
|
||||
for msg in bus_request(vec![BusRequest::GetLqosStats]).await.unwrap() {
|
||||
if let BusResponse::LqosdStats { bus_requests, time_to_poll_hosts, high_watermark, tracked_flows } = msg {
|
||||
if let BusResponse::LqosdStats { bus_requests, time_to_poll_hosts, high_watermark, tracked_flows, rtt_events_per_second } = msg {
|
||||
return NoCache::new(Json(LqosStats {
|
||||
bus_requests_since_start: bus_requests,
|
||||
time_to_poll_hosts_us: time_to_poll_hosts,
|
||||
high_watermark,
|
||||
tracked_flows,
|
||||
rtt_events_per_second,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ use signal_hook::{
|
||||
iterator::Signals,
|
||||
};
|
||||
use stats::{BUS_REQUESTS, TIME_TO_POLL_HOSTS, HIGH_WATERMARK_DOWN, HIGH_WATERMARK_UP, FLOWS_TRACKED};
|
||||
use throughput_tracker::flow_data::get_rtt_events_per_second;
|
||||
use tokio::join;
|
||||
mod stats;
|
||||
|
||||
@ -200,6 +201,7 @@ fn handle_bus_requests(
|
||||
HIGH_WATERMARK_UP.load(std::sync::atomic::Ordering::Relaxed),
|
||||
),
|
||||
tracked_flows: FLOWS_TRACKED.load(std::sync::atomic::Ordering::Relaxed),
|
||||
rtt_events_per_second: get_rtt_events_per_second(),
|
||||
}
|
||||
}
|
||||
BusRequest::GetPacketHeaderDump(id) => {
|
||||
|
@ -137,3 +137,7 @@ pub fn flowbee_rtt_map() -> FxHashMap<FlowbeeKey, RttData> {
|
||||
.map(|(k, v)| (k.clone(), v.median()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn get_rtt_events_per_second() -> u64 {
|
||||
EVENTS_PER_SECOND.swap(0, std::sync::atomic::Ordering::Relaxed)
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use std::sync::{
|
||||
};
|
||||
pub(crate) use flow_analysis::{setup_flow_analysis, get_asn_name_and_country,
|
||||
FlowAnalysis, RECENT_FLOWS, flowbee_handle_events, get_flowbee_event_count_and_reset,
|
||||
expire_rtt_flows, flowbee_rtt_map, RttData,
|
||||
expire_rtt_flows, flowbee_rtt_map, RttData, get_rtt_events_per_second,
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user