Solved

Event detection

Posted on 2004-10-26
168 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
Question by:SteveHodge
    10 Comments
     
    LVL 45

    Expert Comment

    by:sunnycoder
    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
    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:
    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
     
    LVL 2

    Expert Comment

    by:Sadrul
    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
    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
    no problemo :-)

    -- Adil
    0
     

    Expert Comment

    by:dddd
    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
    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
    Posted in your question.
    0
     

    Expert Comment

    by:dddd
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    Course: From Zero to Hero with Nodejs & MongoDB

    Interested in Node.js, but don't know where to start or how to learn it properly? Confused about how the MEAN stack pieces of MongoDB, Expressjs, Angularjs, and Nodejs fit together? Or how it's even possible to run JavaScript outside of the browser?

    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…
    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…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    877 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now