mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Continued improvement: the refresh time matches the default 10s submission time, graph enhancements
This commit is contained in:
@@ -10,4 +10,4 @@ cp ../../site_build/output/* .
|
||||
cp ../../site_build/src/main.html .
|
||||
cp ../../site_build/wasm/wasm_pipe_bg.wasm .
|
||||
popd
|
||||
RUST_LOG=info RUST_BACKTRACE=1 cargo run
|
||||
RUST_LOG=info RUST_BACKTRACE=1 cargo run --release
|
||||
|
||||
@@ -15,10 +15,11 @@ pub async fn send_rtt_for_all_nodes(cnn: &Pool<Postgres>, socket: &mut WebSocket
|
||||
let mut histogram = vec![0; 20];
|
||||
for node in nodes.iter() {
|
||||
for rtt in node.rtt.iter() {
|
||||
let bucket = usize::min(19, (rtt.value / 200.0) as usize);
|
||||
let bucket = usize::min(19, (rtt.value / 10.0) as usize);
|
||||
histogram[bucket] += 1;
|
||||
}
|
||||
}
|
||||
let nodes = vec![RttHost { node_id: "".to_string(), node_name: "".to_string(), rtt: rtt_bucket_merge(&nodes) }];
|
||||
send_response(socket, wasm_pipe_types::WasmResponse::RttChart { nodes, histogram }).await;
|
||||
|
||||
Ok(())
|
||||
@@ -70,6 +71,21 @@ pub async fn send_rtt_for_node(cnn: &Pool<Postgres>, socket: &mut WebSocket, key
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn rtt_bucket_merge(rtt: &[RttHost]) -> Vec<Rtt> {
|
||||
let mut entries: Vec<Rtt> = Vec::new();
|
||||
for entry in rtt.iter() {
|
||||
for entry in entry.rtt.iter() {
|
||||
if let Some(e) = entries.iter().position(|d| d.date == entry.date) {
|
||||
entries[e].l = f64::min(entries[e].l, entry.l);
|
||||
entries[e].u = f64::max(entries[e].u, entry.u);
|
||||
} else {
|
||||
entries.push(entry.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
pub async fn get_rtt_for_all_nodes(cnn: &Pool<Postgres>, key: &str, period: InfluxTimePeriod) -> anyhow::Result<Vec<RttHost>> {
|
||||
let node_status = pgdb::node_status(cnn, key).await?;
|
||||
let mut futures = Vec::new();
|
||||
@@ -158,13 +174,13 @@ pub async fn get_rtt_for_node(
|
||||
|
||||
let mut rtt = Vec::new();
|
||||
|
||||
// Fill download
|
||||
// Fill RTT
|
||||
for row in rows.iter() {
|
||||
rtt.push(Rtt {
|
||||
value: row.avg,
|
||||
value: f64::min(200.0, row.avg),
|
||||
date: row.time.format("%Y-%m-%d %H:%M:%S").to_string(),
|
||||
l: row.min,
|
||||
u: row.max - row.min,
|
||||
l: f64::min(200.0, row.min),
|
||||
u: f64::min(200.0, row.max) - f64::min(200.0, row.min),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -15,6 +15,7 @@ export class PacketsChart implements Component {
|
||||
}
|
||||
|
||||
wireup(): void {
|
||||
request_packet_chart(window.graphPeriod);
|
||||
}
|
||||
|
||||
ontick(): void {
|
||||
|
||||
@@ -15,6 +15,7 @@ export class RttChart implements Component {
|
||||
}
|
||||
|
||||
wireup(): void {
|
||||
request_rtt_chart(window.graphPeriod);
|
||||
}
|
||||
|
||||
ontick(): void {
|
||||
@@ -38,8 +39,8 @@ export class RttChart implements Component {
|
||||
let d: number[] = [];
|
||||
let u: number[] = [];
|
||||
let l: number[] = [];
|
||||
for (let j=0; j<node.rtt.length; j++) {
|
||||
if (first) x.push(node.rtt[j].date);
|
||||
for (let j=0; j<node.rtt.length; j++) {
|
||||
if (first) x.push(node.rtt[j].date);
|
||||
d.push(node.rtt[j].value);
|
||||
u.push(node.rtt[j].u);
|
||||
l.push(node.rtt[j].l);
|
||||
|
||||
@@ -23,9 +23,7 @@ export class SiteStackChart implements Component {
|
||||
|
||||
ontick(): void {
|
||||
this.counter++;
|
||||
if (this.counter % 10 == 0 || this.counter == 0) {
|
||||
request_site_stack(window.graphPeriod, this.siteId);
|
||||
}
|
||||
request_site_stack(window.graphPeriod, this.siteId);
|
||||
}
|
||||
|
||||
onmessage(event: any): void {
|
||||
|
||||
@@ -15,6 +15,7 @@ export class ThroughputChart implements Component {
|
||||
}
|
||||
|
||||
wireup(): void {
|
||||
request_throughput_chart(window.graphPeriod);
|
||||
}
|
||||
|
||||
ontick(): void {
|
||||
|
||||
@@ -111,7 +111,7 @@ pub struct ThroughputChart {
|
||||
pub nodes: Vec<ThroughputHost>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct Rtt {
|
||||
pub value: f64,
|
||||
pub date: String,
|
||||
|
||||
Reference in New Issue
Block a user