Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Event detection

Posted on 2004-10-26
11
Medium Priority
?
174 Views
Last Modified: 2010-04-22
My house alarm system is coupled to a webcam which on an alarm event uploads pictures to my linux server. What I would like to do is have the server notify me by e-mail and/or SMS message whenever the webcam uploads pictures. What is the best way to achieve this; some sort of cron-job that runs very frequently; or is there another way?
0
Comment
Question by:SteveHodge
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 12418532
Hi SteveHodge,

>What I would like to do is have the server notify me by e-mail and/or SMS message whenever the webcam uploads pictures.
There might be several options here ...

One you could write a small stub in the kernel, to be more specific in the IRQ handler for webcam ... If webcam is not running on linux, then how are the pictures uploaded (ftp/tftp etc.) ... You can edit the code for that server to check for this specific instance and generate a mail when you need to be notified ....

Both these approaches will make your notifications event based and hence will be fast (in terms of delay) and less resource consuming (in terms of cycles wasted polling) ...

Still another way out is what you suggested ... writing a daemon program which will scan the directory in which pictures are uploaded and as soon as it finds a change in the directory listing, it shall generate a mail/message ... Obvious drawback is the processing time spent polling the directory ....

Let me know which approach suits you the most and we can discuss that further ....

cheers
sunnycoder
0
 

Author Comment

by:SteveHodge
ID: 12418848
The webcam does run on Linux, it is an Axis 2100, but I would rather not mess around with the code in it (proprietary code, upgrades come every now and again etc). It uploads via ftp to the linux server. I am not too worried about the processing load on the linux server, it is very under-loaded indeed, so a solution that is easy to implement even if expensive on processor cycles would be my preferred direction, especially since I am really not at all proficient at at writing scripts and so on

Steve
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 2000 total points
ID: 12430166
Hi Steve,

In that case, you can use some readymade code to solve your problem ... The code will monitor the directory in which images are uploaded and as soon as it senses a change in the directory listing, it will generate a mail/message

You can use either PHP (dont script much in PHP myself but was able to find something very useful in the manual)
http://www.linuxforum.com/phpmanual/ref.fam.html
http://www.linuxforum.com/phpmanual/function.fam-monitor-collection.html

Or C++ code
http://www.linuxquestions.org/questions/showthread.php?threadid=22105

Or you can download and use a utility like dnotify
http://linux.tcpip.com.cn/download/showdown.php?pa=2337

or a simple script like

#!/bin/bash

ls /path/to/my_dir > out1.txt
d=`diff out1.txt out2.txt`
if [ -n "$d" ]
then
       mail "alert" someone@something.com //or whatever your mailing /smsing command line
fi
mv -f out1.txt out2.txt

you can run this as a cron job every minute .... ofcourse for first execution, you will have to create an out2.txt yourself ...

cheers
sunnycoder
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Expert Comment

by:Sadrul
ID: 12434627
you can use `fcntl' function. you'll set fd to the directory where the images get uploaded, cmd to F_NOTIFY and arg to DN_CREATE. you'll get a SIGIO whenever a file is created in the directory. look into the man page for more details.

(PS: you'll have to define _GNU_SOURCE before you #include <fcntl.h>)

-- Adil
0
 

Author Comment

by:SteveHodge
ID: 12439215
Many thanks sunnycoder - I am sure I can get this working. Thanks also Adil, but I have given the points to sunnycoder as he was first, and also his solution works on my level of linux proficiency.

I am going to post another question now on whether anyone knows how to send an SMS from a linux box. Meanwhile I'll get it working with email

Steve
0
 
LVL 2

Expert Comment

by:Sadrul
ID: 12439680
no problemo :-)

-- Adil
0
 

Expert Comment

by:dddd
ID: 13090995
SteveHodge:

i face same probleum like you.
did you found the solution? if yes can you email to me: <email -id removed by sunnycoder, Page Editor>
coz the solution you accept cannot go in : http://linux.tcpip.com.cn/download/showdown.php?pa=2337

thanks
0
 

Expert Comment

by:dddd
ID: 13091070
sunnycoder
>http://linux.tcpip.com.cn/download/showdown.php?pa=2337
the link above is removed, can you provide another link if you have?
thanks
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 13091111
Posted in your question.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question