As a first step, we're going to add a systemd process to provide system information via a flask web interface. This means that if your Pi's local IP address is (say) 192.168.1.99, you'll be able to browse to http://192.168.1.99:9010 from any machine on your local network and see your Pi's uptime, CPU temperature and other info.
The code we're using is a very lightly modified copy of Ashok Raja'a excellent system info code. The zip file also includes a Javascript routine to sort table entries (for displaying process info) by Stuart Langridge, and css style sheets by Dave Gameche. I know next to nothing about HTML, CSS & Javascript so I'm very happy to be able to stand on the shoulders of these three gentlemen.
To install, unzip the contents of sysinfo.zip into directory /home/pi/Python, creating a new sub-directory "sysinfo", with descendants "static" and "templates". (If you change this location, you'll have to change the contents of sysinfo.service to match.)
You'll need to use "sudo" to copy/edit the sysinfo.service file into the directory /lib/systemd/system and give the file the correct permissions by running
sudo chmod 644 /lib/systemd/system/sysinfo.service
When this is done, you can force systemd to read the new file by entering
sudo systemctl daemon-reload
and you can then start the service by running
sudo systemctl enable sysinfo.service
You can check on the status of the service by running
sudo systemctl status sysinfo.service
Now you can browse to <your Pi's IP address>:9010 to view the system info. You can also visit <your Pi's IP address>:9010/cpu_temperature for a cut down screen showing just CPU temperature that refreshes every 15 seconds.
Why port ":9010"? PiHole was arbitrarily set to port ":9012" (to match its hackaday.io project id) and the other web services have been numbered to fit around it. Change the port number in sysinfo.py if you have a conflict (or want to use your lucky number).
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.