mirror of
https://github.com/JonasunderscoreJones/PI-server-rack.git
synced 2025-10-23 09:39:18 +02:00
Preparing for v0.1.1
This commit is contained in:
parent
6a8e2379e9
commit
59c3b90e0b
3 changed files with 74 additions and 43 deletions
|
@ -1,6 +1,9 @@
|
||||||
# PI-MC-WATCHER
|
# PI-MC-WATCHER
|
||||||
A system that allows Monitoring of Raspberry PI('s) and it's running Minecraft Server(s) on PC and Mac
|
A system that allows Monitoring of Raspberry PI('s) and it's running Minecraft Server(s) on PC and Mac
|
||||||
|
|
||||||
|
## Why?
|
||||||
|
Because I can. Overcomplicated stupid projects are a lot of fun.
|
||||||
|
|
||||||
## What it is about
|
## What it is about
|
||||||
The system contains of three parts. Those are the **PC Module**, **RPi Master Module** and ** RPi Slave Module**
|
The system contains of three parts. Those are the **PC Module**, **RPi Master Module** and ** RPi Slave Module**
|
||||||
|
|
||||||
|
|
46
pc/main.py
46
pc/main.py
|
@ -1,23 +1,40 @@
|
||||||
|
VERSION = "0.1.1"
|
||||||
|
|
||||||
from ftplib import FTP
|
from ftplib import FTP
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
from xml.sax.handler import feature_namespace_prefixes
|
|
||||||
|
|
||||||
launch_time = time()
|
launch_time = time()
|
||||||
|
|
||||||
|
print("Starting PI-MC-WATCHER v" + VERSION + " for PC and Mac")
|
||||||
|
print("Initializing...")
|
||||||
|
|
||||||
|
# wehther or not to print the stats to the console
|
||||||
print_stats = True
|
print_stats = True
|
||||||
|
|
||||||
|
# The credentials for the ftp server. These must be tweaked.
|
||||||
hostname = "172.24.1.193"
|
hostname = "172.24.1.193"
|
||||||
username = "testuser"
|
username = "testuser"
|
||||||
password = "uwu"
|
password = "uwu"
|
||||||
|
|
||||||
|
# defining the name of the file the stats are saved to
|
||||||
|
filename = "output.txt"
|
||||||
|
|
||||||
|
print("Connecting to FTP server...")
|
||||||
|
|
||||||
ftp = FTP(hostname, username, password)
|
ftp = FTP(hostname, username, password)
|
||||||
ftp.encoding = "utf-8"
|
ftp.encoding = "utf-8"
|
||||||
|
|
||||||
filename = "output.txt"
|
print("Connected!")
|
||||||
|
|
||||||
|
start_time = time()
|
||||||
|
|
||||||
|
print("All setup!")
|
||||||
|
|
||||||
|
# permits user to read console logs from above. Can be removed to accelerate start.
|
||||||
|
sleep(3)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
start_time = time()
|
|
||||||
|
|
||||||
with open(filename, "wb") as file:
|
with open(filename, "wb") as file:
|
||||||
# use FTP's RETR command to download the file
|
# use FTP's RETR command to download the file
|
||||||
|
@ -26,7 +43,9 @@ while True:
|
||||||
file = open(filename, 'r')
|
file = open(filename, 'r')
|
||||||
content = file.read()
|
content = file.read()
|
||||||
content = content.split(";")
|
content = content.split(";")
|
||||||
|
# it is possible for the program to fetch the output text file right inbetween when the program on the Master PI cleared it and before it writes the stats.
|
||||||
|
# This sends an error message in the rare case of this occuring.
|
||||||
|
try:
|
||||||
fanmode = content[0]
|
fanmode = content[0]
|
||||||
slave_fanmode = content[1]
|
slave_fanmode = content[1]
|
||||||
fanspeed = content[2]
|
fanspeed = content[2]
|
||||||
|
@ -50,15 +69,20 @@ while True:
|
||||||
mc_version_brand = content[19]
|
mc_version_brand = content[19]
|
||||||
mc_plugins = content[20]
|
mc_plugins = content[20]
|
||||||
mc_playerlist = content[21]
|
mc_playerlist = content[21]
|
||||||
|
except:
|
||||||
|
# The error message to display if the above explained happens
|
||||||
|
print("WARNING: Couldn't read the file's data. If this doesn't happen a lot, just ignore this warning.")
|
||||||
|
|
||||||
sleep(2)
|
|
||||||
|
|
||||||
stop_time = time()
|
|
||||||
|
|
||||||
if print_stats:
|
if print_stats:
|
||||||
print("---------- Uptime: " + str(cpu_up) + " ----------")
|
print("---------- Uptime: " + str(cpu_up) + " ----------")
|
||||||
print("Loop time:\t" + str(round(stop_time - start_time, 2)) + "\ts")
|
# loop_time and stop_time won't be available on the first run as they haven't been measured yet. Therefore this fallback is needed.
|
||||||
|
try:
|
||||||
|
print("Loop time:\t" + str(round(loop_time, 2)) + "\ts")
|
||||||
print("CMD Uptime:\t" + str(round(stop_time - launch_time, 2)) + "\ts")
|
print("CMD Uptime:\t" + str(round(stop_time - launch_time, 2)) + "\ts")
|
||||||
|
except:
|
||||||
|
print("Loop time:\t--.--\ts")
|
||||||
|
print("CMD Uptime:\t--.--\ts")
|
||||||
print("CPU")
|
print("CPU")
|
||||||
print("\tusage:\t" + str(cpu_usage) + "\t%")
|
print("\tusage:\t" + str(cpu_usage) + "\t%")
|
||||||
print("\tfreq:\t" + str(cpu_freq) + "\tMHz")
|
print("\tfreq:\t" + str(cpu_freq) + "\tMHz")
|
||||||
|
@ -74,6 +98,8 @@ while True:
|
||||||
print("\tglobal:\t" + str(fanspeed) + "\t%")
|
print("\tglobal:\t" + str(fanspeed) + "\t%")
|
||||||
print("\t2ndary:\t" + str(fanspeed2) + "\t%")
|
print("\t2ndary:\t" + str(fanspeed2) + "\t%")
|
||||||
|
|
||||||
|
sleep(2)
|
||||||
|
|
||||||
# Close the Connection
|
stop_time = time()
|
||||||
ftp.quit()
|
loop_time = stop_time - start_time
|
||||||
|
start_time = time()
|
|
@ -1,3 +1,5 @@
|
||||||
|
VERSION = "0.1.1"
|
||||||
|
|
||||||
from http import server
|
from http import server
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import subprocess, os, time, psutil
|
import subprocess, os, time, psutil
|
||||||
|
@ -10,7 +12,7 @@ print_stats = True
|
||||||
ignore_slave = True
|
ignore_slave = True
|
||||||
|
|
||||||
# Starting Messages
|
# Starting Messages
|
||||||
print("Starting PI-MC-WATCHER v0.0.1 for RPi")
|
print("Starting PI-MC-WATCHER v" + VERSION + " for RPi")
|
||||||
print("Processing first loop. Each loop takes 5 seconds...")
|
print("Processing first loop. Each loop takes 5 seconds...")
|
||||||
print("\n")
|
print("\n")
|
||||||
if print_stats:
|
if print_stats:
|
||||||
|
@ -42,7 +44,7 @@ GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||||
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||||
|
|
||||||
# setting up control pin for fancontrol
|
# setting up control pin for fancontrol
|
||||||
GPIO.setup(244, GPIO.OUT)
|
GPIO.setup(4, GPIO.OUT)
|
||||||
|
|
||||||
# setting up power pin for second fancontrol
|
# setting up power pin for second fancontrol
|
||||||
GPIO.setup(25, GPIO.OUT)
|
GPIO.setup(25, GPIO.OUT)
|
||||||
|
@ -218,31 +220,31 @@ while True:
|
||||||
|
|
||||||
|
|
||||||
if fanmode == 100:
|
if fanmode == 100:
|
||||||
GPIO.output(24, True)
|
GPIO.output(4, True)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
elif fanmode == 75:
|
elif fanmode == 75:
|
||||||
while i < 6:
|
while i < 6:
|
||||||
GPIO.output(24, True)
|
GPIO.output(4, True)
|
||||||
time.sleep(0.3)
|
time.sleep(0.3)
|
||||||
GPIO.output(24, False)
|
GPIO.output(4, False)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
elif fanmode == 50:
|
elif fanmode == 50:
|
||||||
while i < 6:
|
while i < 6:
|
||||||
GPIO.output(24, True)
|
GPIO.output(4, True)
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
GPIO.output(24, False)
|
GPIO.output(4, False)
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
elif fanmode == 25:
|
elif fanmode == 25:
|
||||||
while i < 6:
|
while i < 6:
|
||||||
GPIO.output(24, True)
|
GPIO.output(4, True)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
GPIO.output(24, False)
|
GPIO.output(4, False)
|
||||||
time.sleep(0.3)
|
time.sleep(0.3)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
else:
|
else:
|
||||||
GPIO.output(24, True)
|
GPIO.output(4, True)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# write all data to list
|
# write all data to list
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue