Compare commits

..

5 Commits
0.5.0 ... 0.5.5

Author SHA1 Message Date
730168ab61 fix, 2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-03-12 16:18:28 +01:00
8bef6d676c fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-03-12 16:14:36 +01:00
813265f8ee forgotten requirement, 2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-03-12 16:10:28 +01:00
b47070cfc2 forgotten requirement
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/tag/woodpecker Pipeline failed
2025-03-12 16:08:57 +01:00
92ef3e6a85 more png
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-03-12 16:04:34 +01:00
2 changed files with 44 additions and 0 deletions

View File

@ -3,10 +3,12 @@ from loguru import logger
import json import json
import plotly.express as px import plotly.express as px
import plotly.graph_objects as po import plotly.graph_objects as po
import matplotlib.pyplot as plt
import pandas as pd import pandas as pd
import psycopg import psycopg
import sqlalchemy import sqlalchemy
import time import time
import io
from app import app from app import app
from app import oidc from app import oidc
@ -118,3 +120,43 @@ def ntpserver():
dbh.close() dbh.close()
@app.route('/plot.png')
def plot_png():
dbh = psycopg.connect()
engine = sqlalchemy.create_engine("postgresql+psycopg://", creator=lambda: dbh)
query = """
select time_bucket('5 minutes', time) as bucket,
device,
avg(cast(values->'rootdisp'->>'value' as float)) as rootdisp,
max(cast(values->'stratum'->>'value' as int)) as stratum
from measurements
where time >= date_trunc('day', now()) AND time < date_trunc('day', now()) + '1 day'::interval and
application = 'TSM' and attributes->>'Label' = 'david'
group by bucket, device
order by bucket, device
"""
df = pd.read_sql(query, con=engine)
fig, ax1 = plt.subplots()
ax1.plot(df['bucket'], df['rootdisp'], 'r-', label='Root Dispersion')
ax1.set_xlabel('Time')
ax1.set_ylabel('Root Dispersion (ms)', color='r')
ax1.tick_params(axis='y', labelcolor='r')
ax2 = ax1.twinx()
ax2.plot(df['bucket'], df['stratum'], 'b-', label='Stratum')
ax2.set_ylabel('Stratum', color='b')
ax2.tick_params(axis='y', labelcolor='b')
ax2.set_yticks(range(int(df['stratum'].min()), int(df['stratum'].max()) + 1))
fig.suptitle('NTP Server Numbers')
fig.tight_layout()
img_io = io.BytesIO()
plt.savefig(img_io, format='png')
img_io.seek(0)
plt.close(fig)
return Response(img_io, mimetype='image/png')

View File

@ -39,3 +39,5 @@ urllib3==2.3.0
Werkzeug==3.1.3 Werkzeug==3.1.3
zipp==3.21.0 zipp==3.21.0
pillow==11.1.0 pillow==11.1.0
matplotlib==3.10.1