I have a stack of five Pis, each of which have a separate hostname and are on the same network. I need to physically identify each Pi from another Pi, perhaps by flashing the onboard LEDs in a recognisable manner. Any idea how I might do this from Bash ideally, and without wiring anything up?
On at least a Pi 3, you can turn the green (SD card activity) LED to be on constantly with the following command (as root):
echo 1 > /sys/class/leds/led0/brightness
Now that Pi will have the green LED on steady, which makes it very easy to identify and label.
To put the LED back to its default state:
echo 0 > /sys/class/leds/led0/brightness echo mmc0 > /sys/class/leds/led0/trigger
Iterate through all of your Pis this way until you've got them all addressed and labeled accordingly.
Shut one of them down. There should be recognizable behavior from the green light, which will eventually go out.
Then put a label on that pi with its ipname.
Then you can start that one up again.
Repeat until all are marked.
Or you can shut them all down, and then bring them up one at a time and see what ip number comes up in your router.
Either a physical label or a hostname with a really good description of where they are if that won't change is a very useful thing. If they use Ethernet, you can wrap the label around the cable.
I would recommend just pulling the ethernet cable, and pinging each Pi in turn. Which does then not reply? These other solutions are neat, but ping is evergreen. If for some reason you’ve filtered icmp requests on these Pis, you can use nping from the nmap package:
nping —arp 192.168.0.25
If you’re in a hurry, just use Fing (free) from Play/App store to do a quick arp scan, and see which host drops off when you pull a cable.
And assign static IPs based on MAC address in your dhcpd.conf to avoid this kind of problem. ISC-DHCPD is just what you need. It’s a beautiful service. Don’t use dnsmasq unless you need its many++ features.
Print dymo-labels with MACs, IPs and hostnames and stick them on top of each Pi. Don’t rely on mDNS/avahi/bonjour/auto-anything, it’s not foolproof. Besides, avahi-daemon has had some serious security problems over the years.
/etc/hosts remains king for small lab/SoHo networks, I always use it as a reference for my dhcpd static clients.
I can't change the color of the led for some reason following @stevieb's instruction. However following similar path, I was able to turn on and off the power led by changing the led1 value instead.
echo 0 > /sys/devices/platform/leds/leds/led1/brightness <-- turn it off echo 1 > /sys/devices/platform/leds/leds/led1/brightness <-- turn it back on