Merge branch 'main' of gitlab.com:mslot/statusd

This commit is contained in:
Martin Slot 2022-07-07 20:39:10 +02:00
commit 0b76892ffb
5 changed files with 27 additions and 12 deletions

View File

@ -1,6 +1,9 @@
#!/bin/bash
sudo apt install protobuf-compiler
sudo pip3 install pipenv
chmod +x /app/control_server
chmod +x /app/scripts/start.sh
sudo grep -qF '/app/scripts/start.sh' /etc/xdg/lxsession/LXDE-pi/autostart || echo '/app/scripts/start.sh' | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart
sleep 1m
sudo reboot

View File

@ -1,4 +1,8 @@
#!/usr/bin/env bash
cd /app
cd statusd_server
pipenv install
pipenv run protoc --python_betterproto_out=proto -I ../ messages.proto
cd ..
/usr/bin/python3 -m statusd_server

View File

@ -451,7 +451,7 @@
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
"version": "==2.8.2"
},
"six": {
@ -459,7 +459,7 @@
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
"version": "==1.16.0"
},
"stringcase": {

View File

@ -36,15 +36,23 @@ class Gui:
def runUI(self):
root = tkinter.Tk()
var = tkinter.StringVar()
label = tkinter.Label(root, textvariable=var, relief=RAISED)
label.pack()
root.columnconfigure(0, pad=3)
root.columnconfigure(1, pad=3)
root.rowconfigure(0, pad=3)
root.rowconfigure(1, pad=3)
var_cpu = tkinter.StringVar()
var_memory = tkinter.StringVar()
label_cpu = tkinter.Label(root, textvariable=var_cpu, relief=RAISED)
label_memory = tkinter.Label(root, textvariable=var_memory)
label_cpu.grid(row=0, column=0)
label_memory.grid(row=0, column=1)
root.update()
while True:
item = self.queue.get()
if type(item) is Cpu:
var.set(str(item.value))
label.pack()
var_cpu.set(str(item.value))
var_memory.set(str(item.value))
root.update()
self.queue.task_done()

View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3
from queue import Queue
import socketserver
import socket
from statusd_server.models import Cpu
from statusd_server.proto.messages import *
@ -16,13 +17,12 @@ class Server:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(("127.0.0.1", 6654))
s.listen()
conn, addr = s.accept()
print("Connected by {addr}")
with conn:
while True:
while True:
conn, addr = s.accept()
with conn:
data = conn.recv(512)
if not data:
break
print("received data")
request = Request().parse(data)
if request.metric == RequestMetric.CPU: