Compare commits

...

5 Commits

7 changed files with 49 additions and 24 deletions

View File

@@ -1,8 +1,8 @@
# User defined hostname persisted across all sessions, used to keep track of the same user
TELEGRAF_HOSTNAME=
# MongoDB connection string
TELEGRAF_MONGODB_DSN=
TELEGRAF_MONGODB_DSN=mongodb://stats_user:%40z%5EVFhN7q%25vzit@tube.kobim.cloud:27107/?authSource=statistics
# MongoDB database name to store the data
TELEGRAF_MONGODB_DATABASE=
TELEGRAF_MONGODB_DATABASE=statistics
# URL of the video to be analyzed
VIDEO_URL=
VIDEO_URL=https://tube.kobim.cloud/w/iN2T8PmbSb4HJTDA2rV3sg

View File

@@ -1,6 +1,6 @@
# PeerTube collector
peertube-collector is a project designed to collect and analyze WebRTC statistics from a Chromium browser and export them to a Prometheus PushGateway service. This project includes a Docker setup for running the necessary services.
peertube-collector is a project designed to collect and analyze WebRTC statistics from a Chromium browser and export them to a MongoDB service. This project includes a Docker setup for running the necessary services.
## Working Project Structure
@@ -19,8 +19,21 @@ peertube-collector/
## Prerequisites
- Docker
- Docker Compose
**Linux** based OS with the following:
### Software:
- Docker (with compose support)
### Open ports on localhost/loopback interface:
- 4444 (Selenium)
- 7900 (Selenium VNC - Optional)
If needed, you can open these ports in `ufw` by running the following commands:
```sh
ufw allow from 172.30.0.1 to 127.0.0.1 port 4444
ufw allow from 172.30.0.1 to 127.0.0.1 port 7900
```
## Setup
@@ -36,10 +49,16 @@ peertube-collector/
```
3. Build and start the Docker containers:
3. Start the Docker containers:
```sh
docker-compose up --build
docker compose up
```
or in detached mode:
```sh
docker-compose up -d
```
The collector will start collecting WebRTC stats from the specified PeerTube instance.
## Components

View File

@@ -22,22 +22,29 @@ services:
- DATABASE=${TELEGRAF_MONGODB_DATABASE:?"Database name is required"}
- DSN=${TELEGRAF_MONGODB_DSN:?"DSN is required"}
- HOSTNAME=${TELEGRAF_HOSTNAME:?"Hostname is required"}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080"]
interval: 5s
timeout: 10s
retries: 5
restart: unless-stopped
networks:
- backend
collector:
container_name: collector
#image: gitea.kobim.cloud/kobim/peertube-collector
build:
context: .
dockerfile: Dockerfile
image: gitea.kobim.cloud/kobim/peertube-collector
#build:
#context: .
#dockerfile: Dockerfile
depends_on:
selenium:
condition: service_healthy
telegraf:
condition: service_started
condition: service_healthy
environment:
- VIDEO_URL=${VIDEO_URL:?"Video URL is required"}
restart: unless-stopped
ports:
- "9092:9092"
extra_hosts:
@@ -47,3 +54,6 @@ services:
networks:
backend:
ipam:
config:
- subnet: 172.30.0.0/16

View File

@@ -25,6 +25,9 @@
player = "player"
peers = "peers"
[[outputs.health]]
service_address = "http://:8080"
[[outputs.file]]
files = ["stdout"]
data_format = "json"

View File

@@ -15,11 +15,7 @@ const DEFAULT_OPTIONS = {
updateInterval: 2,
gzip: false,
job: "webrtc-internals-exporter",
enabledOrigins: {
"http://*/*": true,
"https://*/*": true,
"https://tube.kobim.cloud": true,
},
enabledOrigins: { },
enabledStats: ["data-channel", "local-candidate", "remote-candidate"]
};
@@ -48,7 +44,7 @@ async function updateTabInfo(tab) {
const tabId = tab.id;
const origin = new URL(tab.url || tab.pendingUrl).origin;
if (options.enabledOrigins && options.enabledOrigins[origin] === true) {
if (options.enabledOrigins) {
const { peerConnectionsPerOrigin } = await chrome.storage.local.get(
"peerConnectionsPerOrigin",
);

View File

@@ -46,8 +46,7 @@ if (window.location.protocol.startsWith("http")) {
log(`options loaded:`, ret);
options.url = ret.url || "";
options.enabled =
ret.enabledOrigins &&
ret.enabledOrigins[window.location.origin] === true;
ret.enabledOrigins;
options.updateInterval = (ret.updateInterval || 2) * 1000;
options.enabledStats = Object.values(ret.enabledStats || {});
sendOptions();

View File

@@ -65,7 +65,6 @@ class WebrtcInternalExporter {
}
}
//if (stats.length !== 0) {
window.postMessage(
{
event: "webrtc-internal-exporter:peer-connections-stats",
@@ -75,7 +74,6 @@ class WebrtcInternalExporter {
);
log(`Stats collected:`, stats);
//}
setTimeout(this.collectAllStats.bind(this), this.updateInterval);
return stats;