Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
047a3a6c08 | |||
5573024fd9 | |||
a58f914c40 | |||
4ec9690981 | |||
6af509c2f6 | |||
22eba69526 | |||
a2855edd47 | |||
a2f720855d | |||
cbb9ff7a23 | |||
84b5bbe325 | |||
a42254cf95
|
@ -13,6 +13,42 @@ steps:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
- 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:
|
deploy:
|
||||||
image: quay.io/wollud1969/k8s-admin-helper:0.2.1
|
image: quay.io/wollud1969/k8s-admin-helper:0.2.1
|
||||||
environment:
|
environment:
|
||||||
|
@ -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,7 +16,6 @@ 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==1.0.0rc0
|
|
||||||
loguru==0.7.3
|
loguru==0.7.3
|
||||||
MarkupSafe==3.0.2
|
MarkupSafe==3.0.2
|
||||||
msgspec==0.19.0
|
msgspec==0.19.0
|
||||||
|
63
src/run.py
63
src/run.py
@ -1,7 +1,6 @@
|
|||||||
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_session import Session
|
||||||
from flask_oidc import OpenIDConnect
|
from flask_oidc import OpenIDConnect
|
||||||
import kaleido
|
|
||||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
import redis
|
import redis
|
||||||
@ -160,7 +159,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'
|
||||||
@ -175,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.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',
|
||||||
|
ticksuffix=' ms'
|
||||||
),
|
),
|
||||||
|
|
||||||
# Rechte Y-Achse
|
# Rechte Y-Achse
|
||||||
@ -192,9 +194,58 @@ 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')
|
graph_html_1 = fig.to_html(full_html=False, default_height='30%')
|
||||||
return Response(img, mimetype='image/png')
|
query = """
|
||||||
|
select tiem_bucket('5 minutes', time) as bucket,
|
||||||
|
device,
|
||||||
|
avg(cast(values->'lan-out'->>'value' as int)) as outOctetsPerSeconds,
|
||||||
|
avg(cast(values->'lan-in'->>'value' as int)) as inOctetsPerSeconds
|
||||||
|
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=['outOctetsPerSeconds', 'inOctetsPerSeconds'])
|
||||||
|
xaxis_title="",
|
||||||
|
yaxis_title="",
|
||||||
|
title=f"Network Load",
|
||||||
|
yaxis=dict(ticksuffix=" KiB/s")
|
||||||
|
)
|
||||||
|
graph_html_2 = fig_2.to_html(full_html=False, default_height='30%')
|
||||||
|
|
||||||
|
query = """
|
||||||
|
select tiem_bucket('5 minutes', time) as bucket,
|
||||||
|
device,
|
||||||
|
avg(cast(values->'local'->>'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:
|
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:
|
||||||
|
Reference in New Issue
Block a user