Monitoring System Stats via BPQ & Python

While setting up my BPQ node, I came across another node that hosted an interesting application: System Info. This application displayed stats such as CPU usage, system uptime, available memory, etc. I think this would be interesting for remote management, so I decided to implement it.

I found this guide, which was very helpful, but it used the Perl language. Not a big fan of Perl (mostly because I don’t know it well), I wanted to rewrite the small script in Python. Here is the script. Before you run it, you’ll need to install the following modules:

  • py-cpuinfo
  • certifi
  • distro
  • psutil
  • uptime

I’ve included a requirements.txt file, so all you’ll have to do is run pip install -r requirements.txt. If you haven’t got pip install, run sudo apt install -y python3-pip.

Follow the guide linked to above, until you get to the scripting portion. Simply replace the line in /etc/inetd.conf with this:

bpqdemo    stream    tcp    nowait    YOURUSER  /usr/local/linbpq/

make sure you change the path to wherever your linbpq installation is located. It will look like /home/USERNAME/linbpq, so the full path should look like /home/USERNAME/linbpq/ Also, don’t forget to replace YOURUSER with the username used to run linbpq.

The script has been tested on Ubuntu 20.04, but it should run anywhere. Hope you enjoy it! Feel free to submit pull requests if you have any ideas for improvements.

One thought on “Monitoring System Stats via BPQ & Python

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux