Skip to content

Commit

Permalink
feat: server now runs on Windows PC, added Windows specific scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
therexone committed Jun 30, 2020
1 parent a601c85 commit 0011646
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 37 deletions.
10 changes: 8 additions & 2 deletions scripts/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import psutil
import platform

def getDeviceInfo():
data = {}
Expand All @@ -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
return data


Binary file added scripts/dist/linux-mon-windows.exe
Binary file not shown.
56 changes: 56 additions & 0 deletions scripts/linux-mon-windows.py
Original file line number Diff line number Diff line change
@@ -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()
35 changes: 0 additions & 35 deletions scripts/stats.html

This file was deleted.

0 comments on commit 0011646

Please sign in to comment.