Alan
Alan

Reputation: 25

Check status of raspberry pi

I have a raspberry pi that is connected to the internet and writing data to my mysql database server. I wanted to write a php script that would echo the status. So if the raspberry pi for some reason stops writing data to my mysql device it will echo $status = 0 or something. I wanted to ping the Raspberry pi from my webpage but my raspberry pi IP address won't be the same once I move it somewhere. I thought about maybe just check the last timestamp of the data it wrote to the mysql server with the current time and if it was greater than 5 minutes it will echo status 0. Is there a better way to do this?

Upvotes: 1

Views: 660

Answers (1)

tadman
tadman

Reputation: 211610

If you want to heartbeat something, which is what you're talking about, give the device a consistent ID, even a UUID, which identifies it, and update some table with a check-in DATETIME field:

UPDATE checkins SET checked_in_at=UTC_TIMESTAMP() where device_id=?

When the device stops checking in you know it's offline for some reason.

You could also add an ip_address column so you know where your device is.

Upvotes: 2

Related Questions