Before I took this screenshot, I launched Battlefield 6 -- you can see the resource spike.
This repo contains the monitor.py and requirements.txt files.
-
monitor.py is used to create a Windows Service name PCMonitor, with auto start and restart capabilities.
- INTERVAL inside monitor.py dictates how often it sends data to the InfluxDB bucket.
-
monitor.py uses the InfluxDB_client module to initialize an InfluxDB Client as part of the Windows Service, and then the rest of the script uses the write_api to send the CPU/GPU data to the InfluxDB container.
- This is sent as an HTTP POST request to the InfluxDB container running on my Unraid home lab, with the data in Line Protocol Format. Benefits of the Line Protocol:
- More compact, efficient, and faster to parse since it just simple text.
- Mainly, this format has less bandwidth than JSON/XML which is great because I want this service to be as light as possible since it is also my gaming computer.
- This is sent as an HTTP POST request to the InfluxDB container running on my Unraid home lab, with the data in Line Protocol Format. Benefits of the Line Protocol:
-
nssm.exe was then used to turn the monitor.py file into a Windows Service, with auto start and restart capabilities
![IMPORTANT NOTE] Because of how difficult it is to read CPU temperatures via Python on Windows machine, PyLibreHardwareMonitor is the library used. PyLibreHardwareMonitor requires Administrative privileges to run, which nssm.exe made easy to set up.
The PCMonitor service runs, sending data every 10 seconds (default) via HTTP POST request to the InfluxDB container.
Grafana then consumes the time-series data by using InfluxDB as a data source. Then I made a Grafana dashboard with Flux queries.