diff --git a/scripts/data.py b/scripts/data.py index e358ca1..abd32c9 100644 --- a/scripts/data.py +++ b/scripts/data.py @@ -1,4 +1,5 @@ import psutil +import platform def getDeviceInfo(): data = {} @@ -23,9 +24,14 @@ def getDeviceInfo(): 'total': swap.total, 'free': swap.free } - data['sensor_temperatures'] = psutil.sensors_temperatures(fahrenheit=False) + if platform.system() != 'Windows': + data['sensor_temperatures'] = psutil.sensor_temperatures(fahrenheit=False) + else: + data['sensor_temperatures'] = {"acpitz":[["", 0.0, 0.0, 0.0]]} data['battery_percentage'] = battery.percent data['plugged'] = battery.power_plugged data['approx_sec_left'] = battery.secsleft - return data \ No newline at end of file + return data + + diff --git a/scripts/dist/linux-mon-windows.exe b/scripts/dist/linux-mon-windows.exe new file mode 100644 index 0000000..b8e979d Binary files /dev/null and b/scripts/dist/linux-mon-windows.exe differ diff --git a/scripts/linux-mon-windows.py b/scripts/linux-mon-windows.py new file mode 100644 index 0000000..530462d --- /dev/null +++ b/scripts/linux-mon-windows.py @@ -0,0 +1,56 @@ +# WINDOWS specific script + +import psutil +import platform +import asyncio +import datetime +import random +import websockets +import json + +def getDeviceInfo(): + data = {} + battery = psutil.sensors_battery() + ram = psutil.virtual_memory() + disk = psutil.disk_usage('/') + swap = psutil.swap_memory() + data['user'] = psutil.users()[0].name + data['cpu_freq'] = psutil.cpu_freq() + data['ram_data'] = { + 'percentage_used': ram.percent, + 'total': ram.total, + 'available': ram.available + } + data['disk_data'] = { + 'percentage_used': disk.percent, + 'total': disk.total, + 'free': disk.free + } + data['swap_data'] = { + 'percentage_used': swap.percent, + 'total': swap.total, + 'free': swap.free + } + if platform.system() != 'Windows': + data['sensor_temperatures'] = psutil.sensor_temperatures(fahrenheit=False) + else: + data['sensor_temperatures'] = {"acpitz":[["", 0.0, 0.0, 0.0]]} + data['battery_percentage'] = battery.percent + data['plugged'] = battery.power_plugged + data['approx_sec_left'] = battery.secsleft + + return data + + + +async def sendBatteryLevel(websocket, path): + while True: + deviceInfo = getDeviceInfo() + await websocket.send(json.dumps(deviceInfo)) + await asyncio.sleep(2) + +start_server = websockets.serve(sendBatteryLevel, "0.0.0.0", 5678) +print('---------- [L I N U X M O N] -------------\n Server started\n Press Ctrl + C or Close this window to stop the server') + +asyncio.get_event_loop().run_until_complete(start_server) +asyncio.get_event_loop().run_forever() \ No newline at end of file diff --git a/scripts/stats.html b/scripts/stats.html deleted file mode 100644 index 8b17380..0000000 --- a/scripts/stats.html +++ /dev/null @@ -1,35 +0,0 @@ - - - -
-