Skip to content

tested locally on my mac #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/ymir.csv
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ AKHQ, 3, 0, 10.100.211.94, 8443, 0, -450, -20, https://10.10
graylog, 3, 0, ymir-graylog.daq.esss.dk, 9000, 0, -450, -5, http://ymir-graylog.daq.esss.dk:9000/search
forwarder01, 2, 0, 10.102.10.244, 8093, 0, -450, 10, none
#
filewriter0625, 2, 0, 10.100.6.25, 8888, 0, -355, -50, https://10.100.211.93:3000/d/kafka-to-nexus/kafka-to-nexus-filewriter?orgId=1&refresh=5s
filewriter0627, 2, 0, 10.100.6.27, 8888, 0, -355, -35, https://10.100.211.93:3000/d/kafka-to-nexus/kafka-to-nexus-filewriter?orgId=1&refresh=5s
filewriter0625, 5, 0, 10.100.6.25, 9999, 0, -355, -50, https://10.100.211.93:3000/d/kafka-to-nexus/kafka-to-nexus-filewriter?orgId=1&refresh=5s
filewriter0627, 5, 0, 10.100.6.27, 9999, 0, -355, -35, https://10.100.211.93:3000/d/kafka-to-nexus/kafka-to-nexus-filewriter?orgId=1&refresh=5s
nicosserver01, 2, 0, 10.102.10.238, 14869, 0, -355, -20, none
#
Kafka   Brokers, 4, 64, 0.0.0.0, 65535, 0, -450, -160, none
Expand Down
77 changes: 51 additions & 26 deletions dashboard/generate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
from datetime import datetime
import json
import html
import os
import socket
Expand All @@ -9,6 +10,7 @@
import htmlsvg

type_efu = 1
type_fw = 5
type_text = 4

col1 = "#c0c0c0"
Expand Down Expand Up @@ -137,6 +139,37 @@ def efu_get_version(self, ipaddr, port):
self.dprint("connection reset (by peer?)")
return "connection reset (by peer?)"


def check_fw_pipeline(self, ipaddr, port):
if self.test:
return 5
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ipaddr, port))
s.shutdown(socket.SHUT_WR) # no data sent
data = b""
while True:
chunk = s.recv(4096)
if not chunk:
break
data += chunk
lines = data.decode("utf-8", errors="ignore").strip().splitlines()
for line in lines:
try:
obj = json.loads(line)
# Look for any key ending with '.worker_state'
for key, value in obj.items():
if key.endswith(".worker_state"):
return int(value)
except Exception as e:
self.dprint(f"JSON parse error: {e}")
# If no worker_state found
return -1
except OSError as e:
self.dprint(f"Socket error: {e}")
return -1


def check_efu_pipeline(self, ipaddr, port):
if self.test:
return 5
Expand All @@ -156,6 +189,7 @@ def check_efu_pipeline(self, ipaddr, port):
self.dprint("connection reset (by peer?)")
return 0


# Check that service is running (accept tcp connection)
def check_service(self, idx, type, ipaddr, port):
if self.test:
Expand All @@ -174,13 +208,21 @@ def check_service(self, idx, type, ipaddr, port):
else:
self.lab.setstatus(idx, status)
self.lab.servers[idx][9] = self.efu_get_version(ipaddr, port)

elif type == type_fw:
status = self.check_fw_pipeline(ipaddr, port)
if status == 0:
self.lab.clearstatus(
idx, self.s_stage1 | self.s_stage2 | self.s_stage3
)
else:
self.lab.setstatus(idx, status)
else:
self.lab.setstatus(idx, self.s_stage1 | self.s_stage2 | self.s_stage3)
else:
self.lab.clearstatus(idx, self.s_service)
self.dprint("no service for {}:{}".format(ipaddr, port))


def getstatus(self):
for idx, res in enumerate(self.lab.servers):
name, type, status, ip, port, ang, xo, yo, grafana, sw = res
Expand All @@ -191,6 +233,7 @@ def getstatus(self):
else:
self.lab.clearstatus(idx, self.s_ping)


def printbox(self, x, y, a, color, efu, motext="", width=25):
if efu:
res = '<use href="#chevron" width="{}" height="10" '.format(width)
Expand Down Expand Up @@ -245,33 +288,15 @@ def printinst(self, name, mouseovertext, type, state, angle, ofsx, ofsy):
texty, angle
)
if type == type_efu:
self.printbox(
510 + ofsx, boxy, angle, self.statetocolor(1, state), 1, mouseovertext
)
self.printbox(
532 + ofsx, boxy, angle, self.statetocolor(2, state), 1, mouseovertext
)
self.printbox(
554 + ofsx, boxy, angle, self.statetocolor(4, state), 1, mouseovertext
)
self.mprint('{} font-size="8px" x="460">{}</text>'.format(common, name))
self.printbox(506 + ofsx, boxy, angle, self.statetocolor(1, state), 1, mouseovertext)
self.printbox(528 + ofsx, boxy, angle, self.statetocolor(2, state), 1, mouseovertext)
self.printbox(550 + ofsx, boxy, angle, self.statetocolor(4, state), 1, mouseovertext)
self.mprint('{} font-size="8px" x="450">{}</text>'.format(common, name))
elif type == type_text:
self.mprint(
'{} font-size="12px" x="{}">{}</text>'.format(common, textx, name)
)
self.mprint('{} font-size="12px" x="{}">{}</text>'.format(common, textx, name))
else:
self.printbox(
505 + ofsx,
boxy,
angle,
self.statetocolor(1, state),
0,
mouseovertext,
35,
)
self.mprint(
'{} font-size="8px" x="{}">{}</text>'.format(common, textx, name)
)
self.printbox(505 + ofsx, boxy,angle, self.statetocolor(1, state), 0, mouseovertext)
self.mprint('{} font-size="8px" x="{}">{}</text>'.format(common, textx, name))
self.mprint("")

def makelegend(self):
Expand Down