From 52acd9c073896088bf86952d20adbbafb94ddd62 Mon Sep 17 00:00:00 2001 From: tebarius Date: Sun, 24 Nov 2024 18:40:36 +0100 Subject: [PATCH] v.0.2.0 --- Dockerfile | 2 +- README.md | 4 ++++ app/netdata_DocRudi.py | 10 +++++++--- app/templates/index.html | 9 +++------ docker-compose.yml | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ad4ca4..38dfd23 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG TARGETPLATFORM ARG BUILDPLATFORM LABEL authors="tebarius" -LABEL version="0.1.0" +LABEL version="0.2.0" LABEL description="netdata-DocRudi" WORKDIR /app diff --git a/README.md b/README.md index 865efd2..57b9076 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # netdata-DocRudi + + + + ## build to build container from source: 1. clone repository diff --git a/app/netdata_DocRudi.py b/app/netdata_DocRudi.py index 814b3a4..fe2ffb8 100755 --- a/app/netdata_DocRudi.py +++ b/app/netdata_DocRudi.py @@ -5,7 +5,6 @@ from datetime import datetime from urllib import request, parse, error import plotly.graph_objs as go -import plotly.utils from flask import Flask, render_template from plotly.subplots import make_subplots from waitress import serve @@ -40,7 +39,6 @@ def get_docker_data(q_context, q_dimension): url = f"{netdata_url}?{parse.urlencode(params)}" with request.urlopen(url) as response: data = json.loads(response.read().decode()) - return data['result'] def process_label(label): @@ -71,9 +69,15 @@ def create_plot(): return for i, label in enumerate(labels[1:], start=1): # Skip the first label (usually timestamp) + # docker-cgroups mit slice ... aussortieren, da solche nur kurzzeitig während ContainerBau + # aktiv sind if 'slice_system-slice' in labels[i]: continue y_values = [round(float(row[i]), 2) if row[i] is not None else None for row in plot_data] + # Überprüfen, ob es sich um die CPU-Daten handelt und wenn Netdata da Werte > 1000 liefert diese anpassen + # dies war beim docker_buildx_buildkit-Container geschehen (20000 % CPU-Nutzung geht halt irgendwie nicht) + if row == 1: # Angenommen, Reihe 1 ist für CPU-Daten + y_values = [value / 1000 if value is not None and value > 1000 else value for value in y_values] x_values = [datetime.fromtimestamp(row[0]) for row in plot_data] processed_label = process_label(label) @@ -103,7 +107,7 @@ def create_plot(): plot_bgcolor='#687a8a' ) - return plotly.utils.PlotlyJSONEncoder().encode(fig) + return fig.to_html(full_html=False) @app.route('/') diff --git a/app/templates/index.html b/app/templates/index.html index 9c8b4a2..eade7af 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -7,14 +7,11 @@ {% endif %} Docker Container CPU-Nutzung -

Docker Container CPU/MEM from netdata: {{ netdata_host }}

-
- +
+ {{ plot | safe }}; +
diff --git a/docker-compose.yml b/docker-compose.yml index fb8ad31..0dd41bc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - "19998:19998" environment: - NETDATA_HOST: http://my-netdata-ip:19999 # default: http://localhost:19999 + NETDATA_HOST: http://192.168.2.17:19999 # default: http://localhost:19999 #NETDATA_QUERY_SECONDS: 200000 # default: 200000 (last how many seconds to get from netdata) #NETDATA_QUERY_POINTS: 3000 # default: 3000 (how many points in a row for the query) #SITE_REFRESH: 0 # default: 0 (seconds to refresh the dashboard-website, 0 = no refresh)