Intel NUc's from two generations ago have a nice feature, a multicolor LED Ring and Power LED you can controll by Software. I use a i5 9th gen NUC at home as my "Homeserver, IoT, whatever" device. I create a tiny script running as cron every Minute to set the LED Color depending of the internet connection "quality". I'm not really pully Data from the Modem, for my purposenot neccessary. I Just want to have a quick solution to let others in my family at home see if there is some issues or not. You know the Situation, Wife cannot open a certain Internet page or something is loading very slowly. "What's wrong with our internet?" most time the Anwer is "Nothing - it's not on our end" - but now I have a quick way to visualize if anything may be wrong.

Now the NUC LED show follwoing Status:

  • GREEN:  Everything is fine
  • YELLOW: Still no critical Error but ping is higher than it should
  • PINK: something wrong but still "working" somehow
  • RED BLINKING: DNS Lookup errors, Packetloss, probably big impact


Instead of writing a complicated measurement script I really just make it simple and stupid. I do several Ping Check via well known Hosts and in addition several DNS Lookups. If a DN SLookup fail I just add some "time" and by evaluating the overall Time the check Process needed I set the Status:

# vi: set ft=sh :
echo "Color NUC Ring LED based on Internet Status..."

my_dns_check() {
    echo -n -e "Checking DNS: " $dnslookup
    nslookup $dnslookup > /dev/null 2> /dev/null
    if [ $? -eq 0 ]; then
        echo -e " (DNS OK)"
        echo -e " (DNS NACK)"
        sleep 2.2

start=`date +%s.%N`
result=$(fping -u -c1 | grep -c ".");my_dns_check;my_dns_check;my_dns_check;my_dns_check;my_dns_check;my_dns_check
end=`date +%s.%N`
runtime=$( echo "$end - $start" | bc -l )

echo "Time needed:" $runtime
if (( $(echo "$runtime < 1" |bc -l) )); then
    echo 'ring,3,none,green' | sudo tee /proc/acpi/nuc_led > /dev/null
elif (( $(echo "$runtime < 2" |bc -l) )); then
    echo 'ring,5,none,yellow' | sudo tee /proc/acpi/nuc_led > /dev/null
elif (( $(echo "$runtime < 3" |bc -l) )); then    
    echo 'ring,10,fade_medium,yellow' | sudo tee /proc/acpi/nuc_led > /dev/null
elif (( $(echo "$runtime < 5" |bc -l) )); then
    echo 'ring,20,none,pink' | sudo tee /proc/acpi/nuc_led > /dev/null
elif (( $(echo "$runtime >= 5" |bc -l) )); then
    echo 'ring,60,blink_fast,red' | sudo tee /proc/acpi/nuc_led > /dev/null

To set the NUC LED Color you need to install a Module:

This is a simple kernel module to control the power and ring LEDs on Intel NUC7i[x]BN and NUC6CAY kits.


Follow Icon
Don’t miss out and subscribe by email:
Don't worry! NO Spam and FREE; Receive a summarizing email for new posts, easy to unsubscribe at any time.
← Other Blog Posts