[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Event detection

Posted on 2004-10-26
11
Medium Priority
?
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
11 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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 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