v.0.2.0
This commit is contained in:
@@ -4,7 +4,7 @@ ARG TARGETPLATFORM
|
|||||||
ARG BUILDPLATFORM
|
ARG BUILDPLATFORM
|
||||||
|
|
||||||
LABEL authors="tebarius"
|
LABEL authors="tebarius"
|
||||||
LABEL version="0.1.0"
|
LABEL version="0.2.0"
|
||||||
LABEL description="netdata-DocRudi"
|
LABEL description="netdata-DocRudi"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
# netdata-DocRudi
|
# netdata-DocRudi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## build
|
## build
|
||||||
to build container from source:
|
to build container from source:
|
||||||
1. clone repository
|
1. clone repository
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ from datetime import datetime
|
|||||||
from urllib import request, parse, error
|
from urllib import request, parse, error
|
||||||
|
|
||||||
import plotly.graph_objs as go
|
import plotly.graph_objs as go
|
||||||
import plotly.utils
|
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
from plotly.subplots import make_subplots
|
from plotly.subplots import make_subplots
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
@@ -40,7 +39,6 @@ def get_docker_data(q_context, q_dimension):
|
|||||||
url = f"{netdata_url}?{parse.urlencode(params)}"
|
url = f"{netdata_url}?{parse.urlencode(params)}"
|
||||||
with request.urlopen(url) as response:
|
with request.urlopen(url) as response:
|
||||||
data = json.loads(response.read().decode())
|
data = json.loads(response.read().decode())
|
||||||
|
|
||||||
return data['result']
|
return data['result']
|
||||||
|
|
||||||
def process_label(label):
|
def process_label(label):
|
||||||
@@ -71,9 +69,15 @@ def create_plot():
|
|||||||
return
|
return
|
||||||
|
|
||||||
for i, label in enumerate(labels[1:], start=1): # Skip the first label (usually timestamp)
|
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]:
|
if 'slice_system-slice' in labels[i]:
|
||||||
continue
|
continue
|
||||||
y_values = [round(float(row[i]), 2) if row[i] is not None else None for row in plot_data]
|
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]
|
x_values = [datetime.fromtimestamp(row[0]) for row in plot_data]
|
||||||
processed_label = process_label(label)
|
processed_label = process_label(label)
|
||||||
|
|
||||||
@@ -103,7 +107,7 @@ def create_plot():
|
|||||||
plot_bgcolor='#687a8a'
|
plot_bgcolor='#687a8a'
|
||||||
)
|
)
|
||||||
|
|
||||||
return plotly.utils.PlotlyJSONEncoder().encode(fig)
|
return fig.to_html(full_html=False)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
|
|||||||
@@ -7,14 +7,11 @@
|
|||||||
<meta http-equiv="refresh" content="{{ site_refresh }}">
|
<meta http-equiv="refresh" content="{{ site_refresh }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<title>Docker Container CPU-Nutzung</title>
|
<title>Docker Container CPU-Nutzung</title>
|
||||||
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body style="background-color:#64a0d6">
|
<body style="background-color:#64a0d6">
|
||||||
<h1>Docker Container CPU/MEM from netdata: <a href="{{ netdata_host }}" target="_blank">{{ netdata_host }}</a></h1>
|
<h1>Docker Container CPU/MEM from netdata: <a href="{{ netdata_host }}" target="_blank">{{ netdata_host }}</a></h1>
|
||||||
<div id="plot"></div>
|
<div id="plot">
|
||||||
<script>
|
{{ plot | safe }};
|
||||||
var graphs = {{ plot | safe }};
|
</div>
|
||||||
Plotly.plot('plot', graphs, {});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "19998:19998"
|
- "19998:19998"
|
||||||
environment:
|
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_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)
|
#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)
|
#SITE_REFRESH: 0 # default: 0 (seconds to refresh the dashboard-website, 0 = no refresh)
|
||||||
|
|||||||
Reference in New Issue
Block a user