Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
cbb9ff7a23 | |||
84b5bbe325 | |||
a42254cf95
|
|||
3d05ea5d28
|
|||
52217c5251
|
|||
022d7a8926 | |||
698f926376 | |||
f74ad50b94 | |||
0c03d9f94e
|
|||
eca5affd53
|
|||
6236673d28
|
|||
4213dc7329
|
@ -1,4 +1,4 @@
|
|||||||
FROM python:3.12-alpine3.21
|
FROM python:3.11-alpine3.21
|
||||||
|
|
||||||
ENV REDIS_URL=""
|
ENV REDIS_URL=""
|
||||||
ENV SECRET_KEY=""
|
ENV SECRET_KEY=""
|
||||||
|
@ -16,6 +16,7 @@ idna==3.10
|
|||||||
importlib_metadata==8.6.1
|
importlib_metadata==8.6.1
|
||||||
itsdangerous==2.2.0
|
itsdangerous==2.2.0
|
||||||
Jinja2==3.1.5
|
Jinja2==3.1.5
|
||||||
|
kaleido==0.2.1
|
||||||
loguru==0.7.3
|
loguru==0.7.3
|
||||||
MarkupSafe==3.0.2
|
MarkupSafe==3.0.2
|
||||||
msgspec==0.19.0
|
msgspec==0.19.0
|
||||||
|
24
src/run.py
24
src/run.py
@ -1,4 +1,4 @@
|
|||||||
from flask import Flask, session, g, render_template_string
|
from flask import Flask, session, g, render_template_string, Response
|
||||||
from flask_session import Session
|
from flask_session import Session
|
||||||
from flask_oidc import OpenIDConnect
|
from flask_oidc import OpenIDConnect
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
@ -8,6 +8,8 @@ import json
|
|||||||
import os
|
import os
|
||||||
import plotly.express as px
|
import plotly.express as px
|
||||||
import plotly.graph_objects as po
|
import plotly.graph_objects as po
|
||||||
|
import plotly.io as pio
|
||||||
|
import io
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import psycopg
|
import psycopg
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
@ -159,7 +161,7 @@ def ntpserver():
|
|||||||
select time_bucket('5 minutes', time) as bucket,
|
select time_bucket('5 minutes', time) as bucket,
|
||||||
device,
|
device,
|
||||||
avg(cast(values->'rootdisp'->>'value' as float)) as rootdisp,
|
avg(cast(values->'rootdisp'->>'value' as float)) as rootdisp,
|
||||||
avg(cast(values->'stratum'->>'value' as int)) as stratum
|
max(cast(values->'stratum'->>'value' as int)) as stratum
|
||||||
from measurements
|
from measurements
|
||||||
where time >= date_trunc('day', now()) AND time < date_trunc('day', now()) + '1 day'::interval and
|
where time >= date_trunc('day', now()) AND time < date_trunc('day', now()) + '1 day'::interval and
|
||||||
application = 'TSM' and attributes->>'Label' = 'david'
|
application = 'TSM' and attributes->>'Label' = 'david'
|
||||||
@ -174,8 +176,6 @@ def ntpserver():
|
|||||||
fig.add_trace(po.Scatter(x=df['bucket'], y=df['stratum'], mode='lines', name='Stratum', yaxis='y2', line=dict(color='blue')))
|
fig.add_trace(po.Scatter(x=df['bucket'], y=df['stratum'], mode='lines', name='Stratum', yaxis='y2', line=dict(color='blue')))
|
||||||
|
|
||||||
fig.update_layout(
|
fig.update_layout(
|
||||||
title='NTP Server Numbers',
|
|
||||||
|
|
||||||
# Linke Y-Achse
|
# Linke Y-Achse
|
||||||
yaxis=dict(
|
yaxis=dict(
|
||||||
title='Root Dispersion'
|
title='Root Dispersion'
|
||||||
@ -193,19 +193,9 @@ def ntpserver():
|
|||||||
legend=dict(x=0.05, y=1) # Position der Legende
|
legend=dict(x=0.05, y=1) # Position der Legende
|
||||||
)
|
)
|
||||||
|
|
||||||
|
img = fig.to_image(format='png')
|
||||||
|
return Response(img, mimetype='image/png')
|
||||||
|
|
||||||
graph_html = fig.to_html(full_html=False, default_height='30%')
|
|
||||||
|
|
||||||
return render_template_string(f"""
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>NTP Server Numbers</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{graph_html}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
""")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"Error when querying NTP server values: {e}")
|
raise Exception(f"Error when querying NTP server values: {e}")
|
||||||
finally:
|
finally:
|
||||||
@ -218,7 +208,7 @@ def ntpserver():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(port=8080)
|
app.run(host="0.0.0.0", port=8080)
|
||||||
else:
|
else:
|
||||||
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user