v.0.2.0
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
# netdata-DocRudi
|
||||
|
||||
|
||||
|
||||
|
||||
## build
|
||||
to build container from source:
|
||||
1. clone repository
|
||||
|
||||
@@ -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('/')
|
||||
|
||||
@@ -7,14 +7,11 @@
|
||||
<meta http-equiv="refresh" content="{{ site_refresh }}">
|
||||
{% endif %}
|
||||
<title>Docker Container CPU-Nutzung</title>
|
||||
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
||||
</head>
|
||||
<body style="background-color:#64a0d6">
|
||||
<h1>Docker Container CPU/MEM from netdata: <a href="{{ netdata_host }}" target="_blank">{{ netdata_host }}</a></h1>
|
||||
<div id="plot"></div>
|
||||
<script>
|
||||
var graphs = {{ plot | safe }};
|
||||
Plotly.plot('plot', graphs, {});
|
||||
</script>
|
||||
<div id="plot">
|
||||
{{ plot | safe }};
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user