Compare commits
3 Commits
main
...
de2db02651
Author | SHA1 | Date | |
---|---|---|---|
de2db02651 | |||
6f59cedd93 | |||
281396d9a6 |
223
Tesi.tex
223
Tesi.tex
@@ -94,6 +94,21 @@
|
|||||||
{]}{{{\color{gray}{]}}}}{1},
|
{]}{{{\color{gray}{]}}}}{1},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\lstdefinelanguage{JavaScript}{
|
||||||
|
keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
|
||||||
|
keywordstyle=\color{blue}\bfseries,
|
||||||
|
ndkeywords={class, export, boolean, throw, implements, import, this},
|
||||||
|
ndkeywordstyle=\color{darkgray}\bfseries,
|
||||||
|
identifierstyle=\color{black},
|
||||||
|
sensitive=false,
|
||||||
|
comment=[l]{//},
|
||||||
|
morecomment=[s]{/*}{*/},
|
||||||
|
commentstyle=\color{purple}\ttfamily,
|
||||||
|
stringstyle=\color{red}\ttfamily,
|
||||||
|
morestring=[b]',
|
||||||
|
morestring=[b]"
|
||||||
|
}
|
||||||
|
|
||||||
\usepackage{csquotes}
|
\usepackage{csquotes}
|
||||||
|
|
||||||
\usepackage{epigraph} % per le frasi inizio capitolo
|
\usepackage{epigraph} % per le frasi inizio capitolo
|
||||||
@@ -1416,9 +1431,213 @@ Per ciascun scenario, abbiamo impostato il numero di client a 5 (limite di Hetzn
|
|||||||
|
|
||||||
\chapter{Conclusioni}
|
\chapter{Conclusioni}
|
||||||
|
|
||||||
[Questa sezione sarà completata la prossima settimana con i risultati dei test]
|
\section{Risultati e analisi}
|
||||||
|
|
||||||
[Essenzialmente siamo riusciti a creare un sistema per riprodurre i test di PeerTube, e abbiamo raccolto i dati necessari, confermando quanto detto da PeerTube, e abbiamo anche raccolto dati aggiuntivi che potrebbero essere utili]
|
Attraverso il nostro sistema di test automatizzato, siamo riusciti a raccogliere i dati che ci hanno permesso di analizzare le prestazioni del sistema P2P di PeerTube. I risultati principali confermano molte delle affermazioni fatte dagli sviluppatori nella loro pubblicazione originale.
|
||||||
|
|
||||||
|
I nostri dati raccolti arrivano da più fonti differenti; per verificare le affermazioni originali, ci siamo avvalsi nell'utilizzare sia i dati raccolti dal sistema di monitoraggio interno di PeerTube (ovver OpenTelemetry), sia i dati raccolti tramite il nostro sistema di test automatizzato esterno ed indipendente. Questo ci ha permesso di avere una visione più completa e dettagliata delle prestazioni del sistema P2P e soprattuto permette la verifica di soluzioni diverse che non includono un sistema di monitoraggio interno.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\textwidth]{images/grafana-default-latency.png}
|
||||||
|
\caption{Grafico nel tempo del traffico HTTP e P2P per la configurazione Normal Latency raccolto da Grafana/OpenTelemetry.}
|
||||||
|
\label{fig:normal-latency-grafana}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
Nella figura \ref{fig:normal-latency-grafana} sono mostrati i grafici del traffico HTTP e P2P nel tempo raccolti da automaticamente da OpenTelemetry per la configurazione Normal Latency. Come si evidenzia, il traffico P2P totale è nettamente superiore al traffico HTTP, con un rapporto di circa 3:1.
|
||||||
|
|
||||||
|
Questo viene ulteriormente confermato dai nostri dati raccolti esternamente da Selenium sulle statistiche messe a disposizione dal player video, che mostrano un traffico P2P che raggiunge il 75\% del traffico totale in download. Questo è un risultato molto positivo, in quanto dimostra che il sistema P2P di PeerTube è in grado di ridurre significativamente il carico sui server centrali, permettendo una distribuzione più efficiente dei contenuti video.
|
||||||
|
|
||||||
|
\begin{table}[H]
|
||||||
|
\centering
|
||||||
|
\caption{Traffico totale in download per la configurazione Normal Latency.}
|
||||||
|
\label{tab:network-traffic}
|
||||||
|
\begin{tabular}{lrr}
|
||||||
|
\toprule
|
||||||
|
\textbf{Metrica} & \textbf{Valore} & \textbf{Percentuale} \\
|
||||||
|
\midrule
|
||||||
|
Download totale da peer & 8.10 GiB & 75\% \\
|
||||||
|
Download totale da server & 2.75 GiB & 25\% \\
|
||||||
|
Download totale & 10.86 GiB & 100\% \\
|
||||||
|
\midrule
|
||||||
|
Rapporto P2P/Server & 3:1 & \\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabular}
|
||||||
|
\end{table}
|
||||||
|
|
||||||
|
I valori non sono strettamente identici a quelli mostrati in figura \ref{fig:normal-latency-grafana} in quanto sono stati raccolti in con metodologie diverse, ma sono comunque molto vicini e confermano i risultati ottenuti.
|
||||||
|
|
||||||
|
Ulteriore conferma arriva dai valori raccolti da WebRTC e il campo \textit{data-channel}, che mostrano un traffico P2P in download totale di 8.80 GiB, leggermente maggiore rispetto a quelli forniti dal player/OpenTelemetry, ma pur sempre con un rapporto di 3:1 rispetto al traffico HTTP totale.
|
||||||
|
|
||||||
|
\begin{figure}[H]
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\textwidth]{images/grafana-high-latency.png}
|
||||||
|
\caption{Grafico nel tempo del traffico HTTP e P2P per la configurazione High Latency raccolto da Grafana/OpenTelemetry.}
|
||||||
|
\label{fig:high-latency-grafana}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
Stesso discorso vale per la configurazione High Latency, mostrata in figura \ref{fig:high-latency-grafana}, dove il traffico P2P è nettamente superiore al traffico HTTP, con un rapporto di circa 3:1. In questo caso, i dati raccolti dal player video mostrano un traffico P2P che raggiunge il 77\% del traffico totale in download, leggermente superiore rispetto alla configurazione Normal Latency ma non sorprendente, in quanto i nostri test sono stati eseguiti in un ambiente di rete ideale e con pochi client simultanei rispetto a quelli mostrati nell'articolo originale.
|
||||||
|
|
||||||
|
\begin{table}[H]
|
||||||
|
\centering
|
||||||
|
\caption{Traffico totale in download per la configurazione High Latency.}
|
||||||
|
\label{tab:high-latency-traffic}
|
||||||
|
\begin{tabular}{lrr}
|
||||||
|
\toprule
|
||||||
|
\textbf{Metrica} & \textbf{Valore} & \textbf{Percentuale} \\
|
||||||
|
\midrule
|
||||||
|
Download totale da peer & 8.28 GiB & 77\% \\
|
||||||
|
Download totale da server & 2.53 GiB & 23\% \\
|
||||||
|
Download totale & 10.82 GiB & 100\% \\
|
||||||
|
\midrule
|
||||||
|
Rapporto P2P/Server & 3:1 & \\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabular}
|
||||||
|
\end{table}
|
||||||
|
|
||||||
|
Il traffico misurato da WebRTC e il campo \textit{data-channel} mostrano un traffico P2P in download totale di 8.84 GiB, con un rapporto di 3:1 rispetto al traffico HTTP totale, anche in questo caso leggermente superiore rispetto alla configurazione Normal Latency.
|
||||||
|
|
||||||
|
\
|
||||||
|
|
||||||
|
Infine, i dati raccolti dai nostri test mostrano che:
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item Il traffico P2P aumenta progressivamente nel tempo, confermando il comportamento descritto nell'articolo originale
|
||||||
|
\item Nei test con High Latency, il traffico P2P ha raggiunto fino al 77\% del traffico totale dopo qualche minuto di riproduzione.
|
||||||
|
\item Con Normal Latency, abbiamo osservato un comportamento simile ma con una curva di adozione P2P più graduale, raggiungendo circa il 75\% di traffico P2P in download.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\break
|
||||||
|
\lstset{language=JavaScript}
|
||||||
|
\begin{lstlisting}[caption={Query MongoDB usata per calcolare il traffico totale in download}, captionpos=b, basicstyle=\scriptsize]
|
||||||
|
[
|
||||||
|
{
|
||||||
|
$group: {
|
||||||
|
_id: "$tags.session",
|
||||||
|
maxDownPeers: {
|
||||||
|
$max: "$player.Download Breakdown.Peers"
|
||||||
|
},
|
||||||
|
maxDownServer: {
|
||||||
|
$max: "$player.Download Breakdown.Server"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$group: {
|
||||||
|
_id: null,
|
||||||
|
totalDownPeers: {
|
||||||
|
$sum: "$maxDownPeers"
|
||||||
|
},
|
||||||
|
totalDownServer: {
|
||||||
|
$sum: "$maxDownServer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 0,
|
||||||
|
totalDownPeers: 1,
|
||||||
|
totalDownServer: 1,
|
||||||
|
totalComputedDown: {
|
||||||
|
$sum: [
|
||||||
|
"$totalDownPeers",
|
||||||
|
"$totalDownServer"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
totalDownPeers: 1,
|
||||||
|
totalDownServer: 1,
|
||||||
|
totalComputedDown: 1,
|
||||||
|
percentageOfTotalPeers: {
|
||||||
|
$round: {
|
||||||
|
$multiply: [
|
||||||
|
{
|
||||||
|
$divide: [
|
||||||
|
"$totalDownPeers",
|
||||||
|
"$totalComputedDown"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
100
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
percentageOfTotalServer: {
|
||||||
|
$round: {
|
||||||
|
$multiply: [
|
||||||
|
{
|
||||||
|
$divide: [
|
||||||
|
"$totalDownServer",
|
||||||
|
"$totalComputedDown"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
100
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ratio: {
|
||||||
|
$round: {
|
||||||
|
$divide: [
|
||||||
|
"$totalDownPeers",
|
||||||
|
"$totalDownServer"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$sort: {
|
||||||
|
ratio: -1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$limit: 10
|
||||||
|
}
|
||||||
|
]
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
|
Tutti i dataset e le query MongoDB usate per l'analisi dei dati sono disponibili pubblicamente qui:
|
||||||
|
\begin{itemize}
|
||||||
|
\item \url{https://gitlab.di.unimi.it/mirko.milovanovic/peertube-collector/-/tree/main/server/peertube%20data}
|
||||||
|
\item \url{https://gitlab.di.unimi.it/mirko.milovanovic/Tesi/-/tree/main/peertube/datavis/CRUD}
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\break
|
||||||
|
\section{Limitazioni dello studio}
|
||||||
|
|
||||||
|
È importante evidenziare alcune limitazioni del nostro approccio:
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item A differenza dei test di PeerTube che utilizzavano 1000 client simultanei, abbiamo potuto testare con un numero limitato di client a causa di vincoli di risorse.
|
||||||
|
\item I nostri client erano distribuiti su data center pubblici con connessioni di qualità superiore rispetto a quelle tipiche degli utenti finali
|
||||||
|
\item Non abbiamo potuto testare tutte le combinazioni possibili di configurazioni di rete (diversi tipi di NAT, firewall, ecc.).
|
||||||
|
\item La nostra analisi si è concentrata principalmente sulle metriche di rete e non sugli aspetti soggettivi dell'esperienza utente.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\section{Prospettive future}
|
||||||
|
|
||||||
|
Questo lavoro apre diverse possibilità per ricerche future:
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item Estendere i test con un numero maggiore di client distribuiti in ambienti di rete più realistici.
|
||||||
|
\item Confrontare PeerTube con altre soluzioni P2P per lo streaming video.
|
||||||
|
\item Sviluppare metriche standardizzate per valutare l'efficienza dei sistemi di streaming decentralizzato.
|
||||||
|
\item Studiare l'impatto di implementazioni WebRTC alternative.
|
||||||
|
\item Analizzare i dati aggiuntivi raccolti da WebRTC Internals Exporter per ottenere informazioni più dettagliate sulle prestazioni del sistema P2P come ad esempio: il grafo delle connessioni, la latenza, e altro ancora.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\break
|
||||||
|
\section{Considerazioni finali}
|
||||||
|
|
||||||
|
Il nostro lavoro ha confermato che PeerTube rappresenta una soluzione tecnica efficace per la distribuzione decentralizzata di contenuti video. L'implementazione P2P basata su WebRTC offre vantaggi tangibili in termini di riduzione del carico sui server centrali, mantenendo una qualità di streaming adeguata.
|
||||||
|
|
||||||
|
La configurazione High Latency si è dimostrata particolarmente efficace nel massimizzare il traffico P2P, rappresentando un ottimo compromesso per contenuti dove la latenza non è critica. Il sistema ha dimostrato una buona resilienza e capacità di adattamento a diverse condizioni di rete.
|
||||||
|
|
||||||
|
In un'epoca in cui la centralizzazione dei servizi di streaming solleva preoccupazioni riguardo privacy, censura e sostenibilità economica, PeerTube offre un'alternativa concreta e funzionante. Il nostro studio conferma che, nonostante alcune limitazioni tecniche, l'approccio decentralizzato allo streaming video non solo è tecnicamente possibile ma anche efficiente in termini di utilizzo delle risorse.
|
||||||
|
|
||||||
|
Ma soprattutto, metodologia e gli strumenti sviluppati per questo studio potranno essere utilizzati per valutare future implementazioni di tecnologie di streaming decentralizzato basate su WebRTC, contribuendo all'evoluzione di Internet verso un ecosistema più equo e distribuito.
|
||||||
|
|
||||||
\nocite{*}
|
\nocite{*}
|
||||||
|
|
||||||
|
BIN
images/grafana-default-latency.png
Normal file
BIN
images/grafana-default-latency.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 86 KiB |
BIN
images/grafana-high-latency.png
Normal file
BIN
images/grafana-high-latency.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 76 KiB |
103
peertube/datavis/CRUD/player-statistics.js
Normal file
103
peertube/datavis/CRUD/player-statistics.js
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/* global use, db */
|
||||||
|
// MongoDB Playground
|
||||||
|
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
|
||||||
|
// Make sure you are connected to enable completions and to be able to run a playground.
|
||||||
|
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
|
||||||
|
// The result of the last command run in a playground is shown on the results panel.
|
||||||
|
// By default the first 20 documents will be returned with a cursor.
|
||||||
|
// Use 'console.log()' to print to the debug output.
|
||||||
|
// For more documentation on playgrounds please refer to
|
||||||
|
// https://www.mongodb.com/docs/mongodb-vscode/playgrounds/
|
||||||
|
|
||||||
|
// Select the database to use.
|
||||||
|
use('statistics');
|
||||||
|
|
||||||
|
// Insert a few documents into the sales collection.
|
||||||
|
db.getCollection('peertube_hetzner_high_latency').aggregate(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
$group: {
|
||||||
|
_id: "$tags.session",
|
||||||
|
maxDownPeers: {
|
||||||
|
$max: "$player.Download Breakdown.Peers"
|
||||||
|
},
|
||||||
|
maxDownServer: {
|
||||||
|
$max: "$player.Download Breakdown.Server"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$group: {
|
||||||
|
_id: null,
|
||||||
|
totalDownPeers: {
|
||||||
|
$sum: "$maxDownPeers"
|
||||||
|
},
|
||||||
|
totalDownServer: {
|
||||||
|
$sum: "$maxDownServer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 0,
|
||||||
|
totalDownPeers: 1,
|
||||||
|
totalDownServer: 1,
|
||||||
|
totalComputedDown: {
|
||||||
|
$sum: [
|
||||||
|
"$totalDownPeers",
|
||||||
|
"$totalDownServer"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
totalDownPeers: 1,
|
||||||
|
totalDownServer: 1,
|
||||||
|
totalComputedDown: 1,
|
||||||
|
percentageOfTotalPeers: {
|
||||||
|
$round: {
|
||||||
|
$multiply: [
|
||||||
|
{
|
||||||
|
$divide: [
|
||||||
|
"$totalDownPeers",
|
||||||
|
"$totalComputedDown"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
100
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
percentageOfTotalServer: {
|
||||||
|
$round: {
|
||||||
|
$multiply: [
|
||||||
|
{
|
||||||
|
$divide: [
|
||||||
|
"$totalDownServer",
|
||||||
|
"$totalComputedDown"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
100
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ratio: {
|
||||||
|
$round: {
|
||||||
|
$divide: [
|
||||||
|
"$totalDownPeers",
|
||||||
|
"$totalDownServer"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$sort: {
|
||||||
|
ratio: -1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$limit: 10
|
||||||
|
}
|
||||||
|
]
|
||||||
|
)
|
255
peertube/datavis/CRUD/webrtc-statistics.js
Normal file
255
peertube/datavis/CRUD/webrtc-statistics.js
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
/* global use, db */
|
||||||
|
// MongoDB Playground
|
||||||
|
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
|
||||||
|
// Make sure you are connected to enable completions and to be able to run a playground.
|
||||||
|
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
|
||||||
|
// The result of the last command run in a playground is shown on the results panel.
|
||||||
|
// By default the first 20 documents will be returned with a cursor.
|
||||||
|
// Use 'console.log()' to print to the debug output.
|
||||||
|
// For more documentation on playgrounds please refer to
|
||||||
|
// https://www.mongodb.com/docs/mongodb-vscode/playgrounds/
|
||||||
|
use("statistics");
|
||||||
|
|
||||||
|
let formattedDate = (date) => ({
|
||||||
|
unix: { $toLong: date },
|
||||||
|
iso: { $toString: date },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find the minimum timestamp and calculate the maximum timestamp (one hour later) for a collection
|
||||||
|
function getTimeWindow(collectionName) {
|
||||||
|
const minTimestamp = db.getCollection(collectionName).aggregate([
|
||||||
|
{ $sort: { timestamp: 1 } },
|
||||||
|
{ $limit: 1 },
|
||||||
|
{ $project: { _id: 0, timestamp: 1 } }
|
||||||
|
]).toArray()[0]?.timestamp;
|
||||||
|
|
||||||
|
if (!minTimestamp) return null;
|
||||||
|
|
||||||
|
const maxTimestamp = new Date(minTimestamp.getTime() + 60 * 60 * 1000);
|
||||||
|
return { minTimestamp, maxTimestamp };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get time windows for both collections
|
||||||
|
const highLatencyTimeWindow = getTimeWindow("peertube_hetzner_high_latency");
|
||||||
|
const defaultLatencyTimeWindow = getTimeWindow("peertube_hetzner_default_latency");
|
||||||
|
|
||||||
|
// Function to perform the aggregation for a given collection
|
||||||
|
function getAggregationResult(collectionName, timeWindow) {
|
||||||
|
if (!timeWindow) return [];
|
||||||
|
|
||||||
|
return db.getCollection(collectionName).aggregate([
|
||||||
|
// Filter documents within the collection's specific time window
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
timestamp: {
|
||||||
|
$gte: timeWindow.minTimestamp,
|
||||||
|
$lt: timeWindow.maxTimestamp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: "$peers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
"peers.iceConnectionState": "connected"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: "$peers.values"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
"peers.values.type": "data-channel",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$group: {
|
||||||
|
_id: "$peers.id",
|
||||||
|
maxBytesReceived: {
|
||||||
|
$max: "$peers.values.bytesReceived"
|
||||||
|
},
|
||||||
|
maxBytesSent: {
|
||||||
|
$max: "$peers.values.bytesSent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$group: {
|
||||||
|
_id: null,
|
||||||
|
totalMaxBytesReceived: {
|
||||||
|
$sum: "$maxBytesReceived"
|
||||||
|
},
|
||||||
|
totalMaxBytesSent: {
|
||||||
|
$sum: "$maxBytesSent"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 0,
|
||||||
|
collection: collectionName,
|
||||||
|
totalBytesReceived: "$totalMaxBytesReceived",
|
||||||
|
totalBytesSent: "$totalMaxBytesSent",
|
||||||
|
formattedBytesReceived: {
|
||||||
|
$switch: {
|
||||||
|
branches: [
|
||||||
|
{
|
||||||
|
case: {
|
||||||
|
$gte: [
|
||||||
|
"$totalMaxBytesReceived",
|
||||||
|
1073741824 // 1024^3
|
||||||
|
]
|
||||||
|
},
|
||||||
|
then: {
|
||||||
|
$concat: [
|
||||||
|
{
|
||||||
|
$toString: {
|
||||||
|
$divide: [
|
||||||
|
"$totalMaxBytesReceived",
|
||||||
|
1073741824 // 1024^3
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
" GiB"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
case: {
|
||||||
|
$gte: [
|
||||||
|
"$totalMaxBytesReceived",
|
||||||
|
1048576 // 1024^2
|
||||||
|
]
|
||||||
|
},
|
||||||
|
then: {
|
||||||
|
$concat: [
|
||||||
|
{
|
||||||
|
$toString: {
|
||||||
|
$divide: [
|
||||||
|
"$totalMaxBytesReceived",
|
||||||
|
1048576 // 1024^2
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
" MiB"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
case: {
|
||||||
|
$gte: [
|
||||||
|
"$totalMaxBytesReceived",
|
||||||
|
1024 // 1024^1
|
||||||
|
]
|
||||||
|
},
|
||||||
|
then: {
|
||||||
|
$concat: [
|
||||||
|
{
|
||||||
|
$toString: {
|
||||||
|
$divide: [
|
||||||
|
"$totalMaxBytesReceived",
|
||||||
|
1024 // 1024^1
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
" KiB"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
default: {
|
||||||
|
$concat: [
|
||||||
|
{
|
||||||
|
$toString:
|
||||||
|
"$totalMaxBytesReceived"
|
||||||
|
},
|
||||||
|
" bytes"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formattedBytesSent: {
|
||||||
|
$switch: {
|
||||||
|
branches: [
|
||||||
|
{
|
||||||
|
case: {
|
||||||
|
$gte: [
|
||||||
|
"$totalMaxBytesSent",
|
||||||
|
1073741824 // 1024^3
|
||||||
|
]
|
||||||
|
},
|
||||||
|
then: {
|
||||||
|
$concat: [
|
||||||
|
{
|
||||||
|
$toString: {
|
||||||
|
$divide: [
|
||||||
|
"$totalMaxBytesSent",
|
||||||
|
1073741824 // 1024^3
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
" GiB"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
case: {
|
||||||
|
$gte: [
|
||||||
|
"$totalMaxBytesSent",
|
||||||
|
1048576 // 1024^2
|
||||||
|
]
|
||||||
|
},
|
||||||
|
then: {
|
||||||
|
$concat: [
|
||||||
|
{
|
||||||
|
$toString: {
|
||||||
|
$divide: [
|
||||||
|
"$totalMaxBytesSent",
|
||||||
|
1048576 // 1024^2
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
" MiB"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
case: {
|
||||||
|
$gte: ["$totalMaxBytesSent", 1024] // 1024^1
|
||||||
|
},
|
||||||
|
then: {
|
||||||
|
$concat: [
|
||||||
|
{
|
||||||
|
$toString: {
|
||||||
|
$divide: [
|
||||||
|
"$totalMaxBytesSent",
|
||||||
|
1024 // 1024^1
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
" KiB"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
default: {
|
||||||
|
$concat: [
|
||||||
|
{ $toString: "$totalMaxBytesSent" },
|
||||||
|
" bytes"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get results from both collections using their respective time windows
|
||||||
|
const highLatencyResults = getAggregationResult("peertube_hetzner_high_latency", highLatencyTimeWindow);
|
||||||
|
const defaultLatencyResults = getAggregationResult("peertube_hetzner_default_latency", defaultLatencyTimeWindow);
|
||||||
|
|
||||||
|
// Combine and return the results
|
||||||
|
const combinedResults = [...highLatencyResults, ...defaultLatencyResults];
|
||||||
|
combinedResults;
|
Submodule peertube/statnerd updated: fbd87e01c5...8b35d3068b
Reference in New Issue
Block a user