mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2024-11-22 08:16:25 -06:00
Add a real-time flow counter to the display and API.
This commit is contained in:
parent
393c3adc2a
commit
7516715874
@ -156,6 +156,9 @@ pub enum BusRequest {
|
||||
/// Request a dump of all active flows. This can be a lot of data.
|
||||
/// so this is intended for debugging
|
||||
DumpActiveFlows,
|
||||
|
||||
/// Count the nubmer of active flows.
|
||||
CountActiveFlows,
|
||||
}
|
||||
|
||||
/// Specific requests from the long-term stats system
|
||||
|
@ -119,4 +119,7 @@ pub enum BusResponse {
|
||||
|
||||
/// All Active Flows (Not Recommended - Debug Use)
|
||||
AllActiveFlows(Vec<FlowbeeData>),
|
||||
|
||||
/// Count active flows
|
||||
CountActiveFlows(u64),
|
||||
}
|
||||
|
@ -11,5 +11,17 @@ pub async fn all_flows_debug_dump() -> NoCache<Json<Vec<FlowbeeData>>> {
|
||||
_ => Vec::new(),
|
||||
};
|
||||
|
||||
NoCache::new(Json(result))
|
||||
}
|
||||
|
||||
#[get("/api/flows/count")]
|
||||
pub async fn count_flows() -> NoCache<Json<u64>> {
|
||||
let responses =
|
||||
bus_request(vec![BusRequest::CountActiveFlows]).await.unwrap();
|
||||
let result = match &responses[0] {
|
||||
BusResponse::CountActiveFlows(count) => *count,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
NoCache::new(Json(result))
|
||||
}
|
@ -112,6 +112,7 @@ fn rocket() -> _ {
|
||||
toasts::stats_check,
|
||||
// Flowbee System
|
||||
flow_monitor::all_flows_debug_dump,
|
||||
flow_monitor::count_flows,
|
||||
],
|
||||
);
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
<div class="col-sm-4">
|
||||
<div class="card bg-light">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><i class="fa fa-bolt"></i> Current Throughput</h5>
|
||||
<h5 class="card-title"><i class="fa fa-bolt"></i> Current Throughput <span class="badge badge-pill green-badge" id="flowCount">?</span></h5>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td class="bold">Packets/Second</td>
|
||||
@ -190,6 +190,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
function updateFlowCounter() {
|
||||
$.get("/api/flows/count", (data) => {
|
||||
$("#flowCount").text(data + " flows");
|
||||
});
|
||||
}
|
||||
|
||||
function updateCurrentThroughput() {
|
||||
msgPackGet("/api/current_throughput", (tp) => {
|
||||
const bits = 0;
|
||||
@ -316,6 +322,7 @@
|
||||
|
||||
function OneSecondCadence() {
|
||||
updateCurrentThroughput();
|
||||
updateFlowCounter();
|
||||
updateSiteFunnel();
|
||||
|
||||
if (tickCount % 5 == 0) {
|
||||
@ -342,6 +349,7 @@
|
||||
|
||||
colorReloadButton();
|
||||
fillCurrentThroughput();
|
||||
updateFlowCounter();
|
||||
updateCpu();
|
||||
updateRam();
|
||||
updateTop10();
|
||||
|
@ -226,6 +226,9 @@ fn handle_bus_requests(
|
||||
BusRequest::DumpActiveFlows => {
|
||||
throughput_tracker::dump_active_flows()
|
||||
}
|
||||
BusRequest::CountActiveFlows => {
|
||||
throughput_tracker::count_active_flows()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -469,4 +469,10 @@ pub fn all_unknown_ips() -> BusResponse {
|
||||
}
|
||||
|
||||
BusResponse::AllActiveFlows(result)
|
||||
}
|
||||
|
||||
/// Count active flows
|
||||
pub fn count_active_flows() -> BusResponse {
|
||||
let lock = ALL_FLOWS.lock().unwrap();
|
||||
BusResponse::CountActiveFlows(lock.len() as u64)
|
||||
}
|
Loading…
Reference in New Issue
Block a user