7

I am working on a project that will involve having several RPi kiosks set up across a college campus. In the rare event that someone might accidentally/maliciously disconnect the power cord from one of the RPis, the associated kiosk would obviously stop working.

I would like to automatically get email notifications if this happens so that I would be aware of it immediately, but I don't know how to do this or even if it is possible. Any ideas?

1
  • 2
    this is called a "dead man's switch". if it's web-accessible there are a lot of options. but to tell that something is dead you need a nondead device watching it. dead servers don't talk. – tedder42 Jun 4 '16 at 0:35
11

It's certainly possible, but it'll require additional hardware. Once the RPi loses power, that's it. Just like your desktop, there's no magical way for the RPi to do anything (like send a notification) once the power is gone.

You could add a small UPS to the RPi. There are a few that are even designed specifically for the RPi, like this one. If the power goes out, the UPS will send a notification to the RPi. Then the RPi can handle sending a message across the network. If you're fast enough, the RPi may never experience downtime. If you're not fast enough, the RPi can gracefully shutdown.

Alternatively, you could add microcontroller to monitor the power and send a message if needed. Something like this should be able to run off a battery for along time.

I think the best and simplest option though would be to ping the RPi on a set schedule. Since your RPi is a network attached kiosk, you obviously can contact it through said network. Why not just setup a handshake every 1/5/60/whatever minutes? This could be as simple as a script on your server or even desktop workstation that just pings a list of IPs/Hosts and then notifies you which ones don't answer.

0

DIY:

  1. Create an AWS account.
  2. Create a tiny text file that just contains something like "hello" or "alive"
  3. Create a S3 bucket for your project. Copy your tiny text file N times into that bucket, once for each Pi that you need to keep status on. Use unique filenames like pi1, pi2, pi3, ... , piN.
  4. On each pi, create a simple shell script run by cron every minute that grabs that pi's text file via wget or curl.
  5. Enable S3 access logging
  6. On a separate Pi or an EC2 instance, write a script that regularly downloads the S3 logs and checks to see that all of the pi files have been recently accessed. Note that S3 access logging isn't instantaneous, so you may have a 20-30 minute lag before you discover that one of your Pis is down.

There are commercial server monitoring services like New Relic, but they may be too expensive for your application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.