Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
af76406afa
|
|||
d85c32247e
|
|||
ba7b86e527
|
|||
c93ae4067e | |||
1bbfdf65fb | |||
315ad9998b | |||
047a3a6c08 | |||
5573024fd9 | |||
a58f914c40 | |||
4ec9690981 | |||
6af509c2f6 | |||
22eba69526 | |||
a2855edd47 | |||
a2f720855d |
@ -13,6 +13,42 @@ steps:
|
||||
dockerfile: Dockerfile
|
||||
when:
|
||||
- event: [push, tag]
|
||||
|
||||
scan:
|
||||
image: quay.io/wollud1969/woodpecker-helper:0.5.1
|
||||
environment:
|
||||
TRIVY_TOKEN:
|
||||
from_secret: trivy_token
|
||||
TRIVY_URL:
|
||||
from_secret: trivy_url
|
||||
DTRACK_API_KEY:
|
||||
from_secret: dtrack_api_key
|
||||
DTRACK_API_URL:
|
||||
from_secret: dtrack_api_url
|
||||
commands:
|
||||
- HOME=/home/`id -nu`
|
||||
- TAG="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
||||
- |
|
||||
trivy image \
|
||||
--server $TRIVY_URL \
|
||||
--token $TRIVY_TOKEN \
|
||||
--format cyclonedx \
|
||||
--scanners license \
|
||||
--output /tmp/sbom.xml \
|
||||
$FORGE_NAME/$CI_REPO:$TAG
|
||||
- cat /tmp/sbom.xml
|
||||
- |
|
||||
curl -X "POST" \
|
||||
-H "Content-Type: multipart/form-data" \
|
||||
-H "X-Api-Key: $DTRACK_API_KEY" \
|
||||
-F "autoCreate=true" \
|
||||
-F "projectName=$CI_REPO" \
|
||||
-F "projectVersion=$TAG" \
|
||||
-F "bom=@/tmp/sbom.xml"\
|
||||
"$DTRACK_API_URL/api/v1/bom"
|
||||
when:
|
||||
- event: [push, tag]
|
||||
|
||||
deploy:
|
||||
image: quay.io/wollud1969/k8s-admin-helper:0.2.1
|
||||
environment:
|
||||
|
@ -16,7 +16,6 @@ idna==3.10
|
||||
importlib_metadata==8.6.1
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.5
|
||||
kaleido==0.2.1
|
||||
loguru==0.7.3
|
||||
MarkupSafe==3.0.2
|
||||
msgspec==0.19.0
|
||||
|
64
src/run.py
64
src/run.py
@ -1,4 +1,4 @@
|
||||
from flask import Flask, session, g, render_template_string, Response
|
||||
from flask import Flask, session, g, render_template_string
|
||||
from flask_session import Session
|
||||
from flask_oidc import OpenIDConnect
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
@ -8,8 +8,6 @@ import json
|
||||
import os
|
||||
import plotly.express as px
|
||||
import plotly.graph_objects as po
|
||||
import plotly.io as pio
|
||||
import io
|
||||
import pandas as pd
|
||||
import psycopg
|
||||
import sqlalchemy
|
||||
@ -176,9 +174,12 @@ def ntpserver():
|
||||
fig.add_trace(po.Scatter(x=df['bucket'], y=df['stratum'], mode='lines', name='Stratum', yaxis='y2', line=dict(color='blue')))
|
||||
|
||||
fig.update_layout(
|
||||
title='NTP Server Numbers',
|
||||
|
||||
# Linke Y-Achse
|
||||
yaxis=dict(
|
||||
title='Root Dispersion'
|
||||
title='Root Dispersion',
|
||||
ticksuffix=' ms'
|
||||
),
|
||||
|
||||
# Rechte Y-Achse
|
||||
@ -193,9 +194,58 @@ def ntpserver():
|
||||
legend=dict(x=0.05, y=1) # Position der Legende
|
||||
)
|
||||
|
||||
img = fig.to_image(format='png')
|
||||
return Response(img, mimetype='image/png')
|
||||
graph_html_1 = fig.to_html(full_html=False, default_height='30%')
|
||||
|
||||
query = """
|
||||
select time_bucket('5 minutes', time) as bucket,
|
||||
device,
|
||||
avg(cast(values->'lan-in-pkts'->>'value' as float)) as packets
|
||||
from measurements
|
||||
where time >= date_trunc('day', now()) AND time < date_trunc('day', now()) + '1 day'::interval and
|
||||
application = 'SNMP' and attributes->>'Label' = 'david'
|
||||
group by bucket, device
|
||||
order by bucket, device
|
||||
"""
|
||||
df = pd.read_sql(query, con=engine)
|
||||
fig_2 = px.line(df, x='bucket', y='packets')
|
||||
fig_2.update_layout(
|
||||
xaxis_title="",
|
||||
yaxis_title="",
|
||||
title=f"Packets"
|
||||
)
|
||||
graph_html_2 = fig_2.to_html(full_html=False, default_height='30%')
|
||||
|
||||
query = """
|
||||
select time_bucket('5 minutes', time) as bucket,
|
||||
device,
|
||||
avg(cast(values->'load1'->>'value' as float)) as loadaverage1min
|
||||
from measurements
|
||||
where time >= date_trunc('day', now()) AND time < date_trunc('day', now()) + '1 day'::interval and
|
||||
application = 'SNMP' and attributes->>'Label' = 'david'
|
||||
group by bucket, device
|
||||
order by bucket, device
|
||||
"""
|
||||
df = pd.read_sql(query, con=engine)
|
||||
fig_3 = px.line(df, x='bucket', y='loadaverage1min')
|
||||
fig_3.update_layout(
|
||||
xaxis_title="",
|
||||
yaxis_title="",
|
||||
title=f"CPU Load"
|
||||
)
|
||||
graph_html_3 = fig_3.to_html(full_html=False, default_height='30%')
|
||||
|
||||
return render_template_string(f"""
|
||||
<html>
|
||||
<head>
|
||||
<title>NTP Server Numbers</title>
|
||||
</head>
|
||||
<body>
|
||||
{graph_html_1}
|
||||
{graph_html_2}
|
||||
{graph_html_3}
|
||||
</body>
|
||||
</html>
|
||||
""")
|
||||
except Exception as e:
|
||||
raise Exception(f"Error when querying NTP server values: {e}")
|
||||
finally:
|
||||
@ -208,7 +258,7 @@ def ntpserver():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", port=8080)
|
||||
app.run(port=8080)
|
||||
else:
|
||||
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
||||
|
||||
|
Reference in New Issue
Block a user