Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
4db989022e
|
|||
af76406afa
|
|||
d85c32247e
|
|||
ba7b86e527
|
|||
c93ae4067e | |||
1bbfdf65fb | |||
315ad9998b | |||
047a3a6c08 | |||
5573024fd9 | |||
a58f914c40 | |||
4ec9690981 | |||
6af509c2f6 | |||
22eba69526 | |||
a2855edd47 | |||
a2f720855d | |||
cbb9ff7a23 | |||
84b5bbe325 | |||
a42254cf95
|
|||
3d05ea5d28
|
|||
52217c5251
|
|||
022d7a8926 | |||
698f926376 | |||
f74ad50b94 |
@ -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:
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM python:3.12-alpine3.21
|
||||
FROM python:3.11-alpine3.21
|
||||
|
||||
ENV REDIS_URL=""
|
||||
ENV SECRET_KEY=""
|
||||
|
@ -1,4 +1,3 @@
|
||||
kaleido
|
||||
async-timeout==5.0.1
|
||||
Authlib==1.4.0
|
||||
blinker==1.9.0
|
||||
|
63
src/run.py
63
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
|
||||
@ -159,7 +159,7 @@ def ntpserver():
|
||||
select time_bucket('5 minutes', time) as bucket,
|
||||
device,
|
||||
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
|
||||
where time >= date_trunc('day', now()) AND time < date_trunc('day', now()) + '1 day'::interval and
|
||||
application = 'TSM' and attributes->>'Label' = 'david'
|
||||
@ -174,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
|
||||
@ -191,9 +194,59 @@ 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->'time-reqs-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="",
|
||||
yaxis_ticksuffix="p/s",
|
||||
title=f"Time Requests"
|
||||
)
|
||||
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:
|
||||
|
Reference in New Issue
Block a user