Introduction: Garage Monitor 3001 Paging System

This is an updated paging system for the Garage Monitor 3001( GM3K1).

I was using Nagios before for paging , but after switching to the SheevaPlug I decided to skip installing Nagios and just use a script for this.

Step 1: Pre Reqs

I am going to assume you are running linux and a db. I use Fedora and Mysql.

And obviously you need to run the Garage Monitor 3001.

Step 2: Create Table.

Create a db instance and create a table in it.

CREATE TABLE `status` (
  `door` enum('overhead','side') DEFAULT NULL,
  `status` enum('Open','Closed') DEFAULT NULL,
  `date` datetime NOT NULL,
  PRIMARY KEY (`id`)

Step 3: Monitoring Script

This is the script I use to monitor the garage, which will grab the page, and insert the status in the database.

#Script to enter garage status in DB
#Joe McManus 2010/01/26

#who mail should go to

#who mail comes from

#set the time
$now=date('Y-m-d H:i');

#web status  url

#public url to include in page to check status online

function connect(&$db){
  $db = mysql_pconnect("localhost", "garage", "monitor");
  if ( mysql_select_db("garagemon", $db)) {
        } else {
        echo "Sorry we are currently experiences technical issues. We'll be back shortly.";


#check the page
system("curl $garageurl -o /tmp/garage.txt", $retval);
if ($retval == 1 ) {
        echo "Error: Unable to reach web server";

#Get the door status
$overhead=exec('grep Overhead /tmp/garage.txt | cut -d" " -f2');
$side=exec('grep Side /tmp/garage.txt | cut -d" " -f2');

#insert the side door in to the db
$insert="insert into status(id, date, door, status)";
$insert.="values('', now(), 'side', '$side')";
$result=mysql_query($insert, $db);

#insert the overhead door in to the db
$insert="insert into status(id, date, door, status)";
$insert.="values('', now(), 'overhead', '$overhead')";
$result=mysql_query($insert, $db);

echo "Overhead: $overhead ";
echo "Side: $side ";

#Query for doors being open 10 minutes or more.
$query='select date, door, status from status where status="Open" and date > date_sub(now(), interval 10 minute)';
$result=mysql_query($query, $db);

if ($rowcount >= 2) {
        echo "Alert: Door Open ";
        //Message start
        $mailsubject="Alert: Garage Door Open $now";
        $mailmsg="The Garage Monitor 3001 has detected that a door has been open for more than 10 minutes. $now ";
        $mailmsg.="$puburl ";

        if(file_exists($mailfile)) {
                echo "Mail not being sent $mailfile exists ";
        } else {
                mail($mailto, $mailsubject, $mailmsg);
                exec("/bin/touch $mailfile");
} else {
        if(file_exists($mailfile)) {
                echo "Alert: Garage Door Closed $now";
                $mailsubject="Alert: Garage Door Closed";
                $mailmsg="The Garage Monitor 3001 has detected that a door has been closed. $now ";
                $mailmsg.="$puburl ";
                mail($mailto, $mailsubject, $mailmsg);
                exec("/bin/rm $mailfile");

#Just a query for debugging
$query='select date, door, status from status where date > date_sub(now(), interval 10 minute)';
$result=mysql_query($query, $db);
echo  "door    | status  | date ";
while($row=mysql_fetch_row($result)) {
        echo "$row[0] | $row[1] | $row[2] ";


Step 4: Add to Cron

Add the script to cron, have it run every 5 minutes.

Step 5: Alerts

You will get only get one email if a door is open for 10 minutes or 10 hours, no need to fill up your inbox. You will get one more when it clears.



I just had a great idea - somehow link it up so it'll post a status update to a Twitter account!

About This Instructable




Bio: I like to tinker with just about anything, sometimes it works out in the end. Have fun looking at the projects, try tearing something open ... More »
More by joe:Intel Edison Garage Monitor and Alert SystemIntel Edison Fat Bike Tire AnalyzerIntel Galileo Garage Monitor
Add instructable to: