Visual Alerting for PRTG using a Raspberry Pi, Python and a BlinkStick

Like a lot of people recently, I have been working from home a lot. While I have managed to get most of my work toys set up at home, I was missing the monitoring screens that we have set up in the office to display our PRTG alerting maps. These are incredibly useful and allow us to react to problems very quickly. I needed a way to know when we had PRTG sensors down without having a screen dedicated to the task at home.

Some sort of alert light would do the trick and after some quick googling I came across the BlinkStick. These are a range of USB connected LED’s that have APIs available for a variety of languages. There was nothing for PowerShell but there was for Python. I haven’t used Python for a while but was keen to get back into it so this seemed like a great opportunity. I ordered a BlinkStick Square along with an enclosure.

I had a few Raspberry Pis sitting about doing not much so decided to use one of them to control the BlinkStick Square.

The script I came up with is fairly rudimentary but does the job nicely. It queries the PRTG REST API for a list of Down sensors and if any are returned, it will change the LED in the BlinkStick Square to Red. If there are no errors, it will set the LED to Green. There are a few other colours used to show various errors regarding the script operation itself as well.

It runs as a daemon that launches automatically at boot and writes logs files to enable easy troubleshooting.

I am still fairly new to Python so there are a few things that need to be tweaked regarding the structure of the code. It also currently runs as the root user which is not ideal. I will be refining this over the next few weeks.

This configuration is for a Raspberry Pi 3B+ running Raspbian Buster Lite using Python 3.7.3

Install Python3 and required Python modules

sudo apt update
sudo apt install python3

sudo apt install python3-pip
sudo apt install python3-usb
sudo pip3 install blinkstick
sudo pip3 install requests

Prepare a User with API access in PRTG and adequate permission to view down sensors.

Copy the script below to a suitable location on your Raspberry Pi. I run mine from /home/pi/

You will need to change the PrtgUser, PrtgPass and PrtgServer values to suit your environment.

To enable management by systemd, create the following file at /lib/systemd/system/prtgled.service
Be sure to adjust the ExecStart line to suit the name and location of the script.

Description=PRTG LED Poller

ExecStart=/usr/bin/python3 /home/pi/


Run the following commands to Enable and Start

sudo systemctl enable prtgled.service
sudo systemctl start prtgled.service

Logs will be written to /var/log/prtg_led.log

To automatically rotate the logs, create a file at the following path


/var/log/prtg_led.log {
rotate 10
create 644 root root

Leave a Reply

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