View unanswered posts | View active topics It is currently Fri Aug 29, 2014 3:02 pm



Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
ZM and phone notifications 
Author Message

Joined: Tue Oct 02, 2007 10:38 am
Posts: 128
Location: Greece
Post ZM and phone notifications
Hi, i'd like to implement a solution for ZM to call my mobile phone whenever motion is detected, and i'd like to customize the behaviour of those notifications.

I already implemented a solution, with filters, vgetty, Modem::Voice perl package, with an old ZyXel modem, and although it has its problems, it actually works.

However i have some considerations:
The documentation about filters is not too extensive and the configuration is not too intuitive.
With filters, i had big trouble persuading my FreeBSD to allow www to run programs on the serial port, but i eventually solved it.

I had to write a C program, which called setuid(0), and then called the actual script as system("su - root -c '/root/script'");
and then also seting the setuid bit of the executable.

I tried with background and foreground on the filter, i tried changing the ZM_FILTER_RELOAD_DELAY=5 (secs), ZM_FILTER_EXECUTE_INTERVAL=5 (secs),
and the thing finally worked, but it was so hard/clumpsy, that i eventually started doubting if i had gone to the right path.

I played with "limit to first"..."results only", and to be honest
i am not sure i am doing the right thing.

There is triggers too, which sound more appropriate, although i failed to understand their semantics.

What should be the most appropriate path to follow?

I just found
http://www.zoneminder.com/wiki/index.ph ... tification
i'll try that, making the trigger foreground and resetting
ZM_FILTER_RELOAD_DELAY, ZM_FILTER_EXECUTE_INTERVAL
to their defaults.

i'll try in the evening, and let you know.


Mon Oct 22, 2007 8:55 am
Profile
User avatar

Joined: Wed Jan 17, 2007 11:29 am
Posts: 194
Location: Malmesbury, UK
Post 
Hi achix,

I do something similiar, albeit not quite as advanced as what you're striving for, utilising SMS text notifications in response to certaing alarm events (e.g. motion >30seconds). The SMS extracts various bits of info from the database such as the monitor name, alarm duration, incident time etc. I use MercurySMS to perform the SMS sending.

But anyway, I digress, as it sounds like you're having difficulties with the script execution side of things.

That link you posted is interesting - when I read it I thought 'that sounds like a good reason to upgrade to v1.23.0 in order to have immediate event triggers' but then realised it was talking about v1.22.3 ...? Really? I didn't realise it had such a feature, and indeed on my box the filters get executed every 60 seconds (in accordance with ZM_FILTER_EXECUTE_INTERVAL). Of course, this means I get a 60 seconds delay between detection and notification but this is of little concern to me.

Note that every event essentially has a database flag that records when a script has been executed for it. Hence, once a script has (successfully) executed for a filter then no other scripts will execute against that event - this can really trip you up whilst testing so make sure you have plenty of matching events to run scripts against. Note that if the script exits !=0 then the aforementioned flag will not get set.

If I were you I'd start with simple scripts to ensure you've mastered the filtering options and script firing. Then move onto making the scripts more elaborate. It's also a good idea, during testing, to redirect all output from every script command to a logfile as ZM will not tell you why things failed yet the logs may well do.

Mathew


Mon Oct 22, 2007 2:21 pm
Profile WWW

Joined: Tue Oct 02, 2007 10:38 am
Posts: 128
Location: Greece
Post 
Thx MJN,

i tried this evening making the filter foreground but it just wouldn't work.
Only as background stored filter did it work, so i had to decrease the zmfilter period to 5 secs inorder for the filter to run semi real time.
Since there is shortage of documentation regarding the "Execute", "Submit",etc.. functions as well as the whole concept behind filters and
especially "foreground" filters, it would be nice if someone could exlpain the whole idea behind filters.

from what i saw zmfilter.pl seems completely irrelevant to foreground (refered to also as "interactive") filters which have an external program attached to them.

Setting the periodicity of zmfilter to a low value and making the filter background seems to do what i want, at the expense of a higher load.

Are you sure foreground filters in conjunction with external programs work together?


Mon Oct 22, 2007 8:53 pm
Profile
User avatar

Joined: Wed Jan 17, 2007 11:29 am
Posts: 194
Location: Malmesbury, UK
Post 
This is the way I understand it, just to clarify things:

'Background filters' are checked every ZM_FILTER_EXECUTE_INTERVAL seconds (as you've found).

If the background status for any particular filter is removed (to make it 'foreground' as you've termed it) then these filters now require manual intervention to fire.

If I click 'Submit' then all it does it update the filter results window with the results of that filter i.e. no scripts are run, no e-mail sent, no ftp etc. Nothing actually happens other than effectively display the matched results of that filter.

However, if I click 'Execute' then not only does what 'Submit' did but it also takes action against whatever we'd told it to e.g. execute the script if set to do so.

I can confirm this behaviour on my machine so I wonder why not yours? Are you sure you're not falling into the trap of having events that have already had scripts executed for them? Perhaps from the very same filter when it was previously running in the background?

For what it's worth even why I manually trigger the actioning of a filter the logs confirm it is zmfilter doing the work.

What do your logs say when you attempt to trigger a filter which should execute a script? Does the script subsequently execute when you later put the filter back to operate in the background (waiting long enough for it to be polled of course)?

Mathew


Mon Oct 22, 2007 9:06 pm
Profile WWW

Joined: Tue Oct 02, 2007 10:38 am
Posts: 128
Location: Greece
Post 
Sorry if i am missing smth, but isnt the idea of filters, to have the system
do things for you, without your continuous monitoring/administering?

I havent checked the "Execute" function individually, altho i think that it does not help since its not automatically triggered but manually triggered.

The question is, and that goes to all ZM developers/users:
Does foreground filter execution actually work or not?

Another thing i tried by updating/saving the same foreground filter/restarting ZM, was to email the event, without an external program attached, and it also did not work.

By using the very exact same filter as background (denoted by a * in the <select>)
works like a charm.


Last edited by achix on Tue Oct 23, 2007 9:01 am, edited 1 time in total.



Tue Oct 23, 2007 8:41 am
Profile

Joined: Tue Oct 02, 2007 10:38 am
Posts: 128
Location: Greece
Post 
By doing a little research i found out that
Code:
# grep -l -r AutoExecuteCmd .
./web/zm_html_view_filter.php
./web/zm_actions.php
./scripts/zmfilter.pl
./db/zm_create.sql.in
./db/zm_update-1.21.4.sql

# grep -l -r zmfilte .
./README.txt
./web/zm_funcs.php
./scripts/ZoneMinder/lib/ZoneMinder/ConfigAdmin.pm.in
./scripts/ZoneMinder/lib/ZoneMinder/ConfigAdmin.pm
./scripts/Makefile.am
./scripts/zmdc.pl
./scripts/zmpkg.pl
./scripts/Makefile.in
./scripts/zmfilter.pl
./db/zm_create.sql.in
./README.rtf
./README.html

# grep -l -r executeFilter .
./web/zm_html_view_events.php
./web/zm_funcs.php
./web/zm_html_view_filter.php



which means no calling of executeFilter from inside zma,
which means foreground filters are manual.

I think for arbitrary external AutoExecuteCmd this makes sense
since we dont know anything about the command in question.

For the email case however why not make this instant?


Tue Oct 23, 2007 8:59 am
Profile
User avatar

Joined: Wed Jan 17, 2007 11:29 am
Posts: 194
Location: Malmesbury, UK
Post 
Quote:
Sorry if i am missing smth, but isnt the idea of filters, to have the system do things for you, without your continuous monitoring/administering?


Yes, that is the purpose of setting fitlers to run in the background.

Quote:
The question is, and that goes to all ZM developers/users:
Does foreground filter execution actually work or not?


Absolutely, yes.

I think you might be getting confused with what 'foreground' and background filters actually are. (I've quoted 'foreground' because I don't think that term is explicitly defined, but it's obvious that they are not background filters).

Background filters are basically filters that run in the background i.e. running automatically periodically executing, checking for matches, and performing whatever actions you've defined.

'Foreground' filters, for all intents and purposes, are simply filters sat there dormant until you manually fire them. Perhaps you might have a filter set to match all events over 5 minutes long that occured in the last week - this sort of filter only really makes sense in the 'foreground' sense as you would only require it when observing events manually.

I really don't know why you can't get your filters to execute manually - perhaps someone with more knowledge than I can advise on how you go about debugging what's up.

Mathew


Tue Oct 23, 2007 10:21 am
Profile WWW

Joined: Tue Oct 02, 2007 10:38 am
Posts: 128
Location: Greece
Post 
Quote:
I really don't know why you can't get your filters to execute manually - perhaps someone with more knowledge than I can advise on how you go about debugging what's up.


I haven't tried that, but its not my issue if you have followed the whole conversation.

The mere question is :

How to do real time notifications about alarms/other events in the System?

Is http://www.zoneminder.com/wiki/index.ph ... tification stating things wrong?

In alarm systems, (i have a visonic powermax+) the system instantly triggers the notification upon an alarm or other event. It doesnt wait for the bulglary to complete and the burglar to leave the crime scene in fool safety!

Setting ZM_FILTER_EXECUTE_INTERVAL to lets say 5 secs of course solves the problem, but increases load.
Is that wanted/acceptable?
Do others have the same questions?


Tue Oct 23, 2007 11:09 am
Profile
User avatar

Joined: Wed Jan 17, 2007 11:29 am
Posts: 194
Location: Malmesbury, UK
Post 
With respect, I have been following the conversation (perhaps you missed the fact that it is only you and I talking here) and it was my understanding that you had been unsuccessful in getting manual filters to execute your script. My apologies if this misunderstanding is mine.

As for your question, yes, I think that wiki page is indeed wrong however whoever wrote it obviously doesn't think so and chances are they know far more than me so perhaps a word in their direction might reveal further advice! I can find nothing in the documentation that suggests automatic immediate filter firing is currently possible (and if the architecture was in place to do this then why would it be necessary to define how often the filters should be 'fired' anyway?)

Perhaps something like this may suit your needs better? It also operates in a reactionary capacity as opposed to being actively initiated but may well produce less of a load.

Mathew


Last edited by MJN on Tue Oct 23, 2007 2:21 pm, edited 2 times in total.



Tue Oct 23, 2007 11:37 am
Profile WWW

Joined: Tue Oct 02, 2007 10:38 am
Posts: 128
Location: Greece
Post 
I'll take a look at the Perl module.
Thanx!

However i am still curious as to why such an essential function is missing out of the box in ZM.


Tue Oct 23, 2007 1:41 pm
Profile

Joined: Tue Oct 02, 2007 10:38 am
Posts: 128
Location: Greece
Post 
I tried the code in http://www.zoneminder.com/wiki/index.ph ... n_alarm.3F
It works.
However mysql lets the user to do mistakes, and then gives unreliable results.

Code:
select M.*, max(E.Id) as LastEventId from Monitors as M left join Events as E on M.Id = E.MonitorId where M.Function != 'None' group by (E.MonitorId)

Is wrong both semantically, formally and effectively.

PostgreSQL wouldn;t even allow such a query to run.

well, changing the above to
Code:
select M.*, max(E.Id) as LastEventId from Monitors as M left outer join Events as E on M.Id = E.MonitorId where M.Function != 'None' group by (M.Id)


(althouh formally wrong too), gives the right camera results.
The right thing would be to include all M.* in the group by,
but mysql lets you get away with this.

I'll do it this way.
However i am still puzzled as of why not to have something similar but much lighter than zmfilter scheduling, that would do the obvious
task that every alarm system has:
Instant Notification!
Why not triggered from inside zma?

One would like to call a security center upon alarm and not after 1 minute.
Also it puzzles me, how none of the chief developers commented on that.
But again it could very well discussed to death, without me knowing it.
You know, just this perl script dont look like an official way to to
instant notification upon alarm.

Mathew, thanx for the help/pointer/your company.
Sorry if i overreacted, but i was talking about phone notification
from the very first line. What would be the use of a manual way to call my own mobile? No use at all, except to locate it in the house, if lost as usual!


Tue Oct 23, 2007 11:02 pm
Profile

Joined: Tue Oct 02, 2007 10:38 am
Posts: 128
Location: Greece
Post 
Just for the record, i tried yesterday night to fire zmfilter.pl interactively
by hitting the Execute button, and everything commands/short mail/email work brilliantly. People dont forget to define "from" for the emails!

However, please people enlighten me on that:

I see a lot of references on zmtrigger,zmx10 and i see the need of a lot of people to try to talk to ZoneMinder from external sources, manage cameras, react to X10 events, switch cameras to motion detection mode etc...

Now I think i can understand this need.

But since by the above perception ZM is considered as a peripheral
in the overall "Security" architecture as far as initiation is concerned, wouldn't someone want to also view ZM as a peripheral in the case of alarm?

I mean, ok, someone arms his alarm system, and wants to trigger the ZM cameras to start motion detection, just like any other PIR, contact, fire detector, etc...
Would not be ideal if the same "alarm" console was receiving alarms from ZM, seeing it ideally as N additional zones?
(or just one ZM zone in the more brute force approach)

This way, there could be *one* point of monitoring. The alarm console would do the job, communicate with some security center, and do all the things that alarm consoles know how to do best.

Is there a way to "connect" ZM by wire to the console as an additional zone?

(i've heard x10 is not that reliable, and also does not work in case of power outage, (which the burglar will definately try)).


Thu Oct 25, 2007 8:17 am
Profile

Joined: Wed Apr 26, 2006 1:39 am
Posts: 234
Location: Boston USA
Post 
Has there been any update to this issue/feature?

I've been hoping for instant audible alarms for a long time and it might actually be in ZM by now, but I'm not sure where to look for it.

Thanks!

_________________
MRD


Fri Jan 02, 2009 4:27 pm
Profile

Joined: Sat Jan 19, 2013 6:58 pm
Posts: 20
Post Re: ZM and phone notifications
I have come to this post from wiki page. The information presented is contradicting:
  • Wiki page says that zmfilter can sound an audible alarm on the server. By looking at this post (use of Modem::Voice) I understand that intention is to dial some number using the attached modem and play a message over the line. However I don't see any such option in ZoneMinder configuration.
  • Is it possible to execute external program on alarm event? All already present functionality (send email / send message / control X10) is very impressive, but I think that covering all kind of communications is hardly possible. I think there should be a basic module that can create messages based on templates and execute commands (making also substitution of parameters) seeding the message to STDIN (attachments can be saved as temporary files). Everything else is done by external program: mailing is already present (mail, sendmail, mutt), sending SMS is done via gammu; adapters for other ways of communication can be easily written.

I refer ZoneMinder 1.25.0.


Wed Feb 06, 2013 11:35 am
Profile

Joined: Wed Apr 26, 2006 1:39 am
Posts: 234
Location: Boston USA
Post Re: ZM and phone notifications
Hi,

ZM can do everything you have suggested already by using custom scripts that execute based on a filter. The only issue I have had with that method for audio alerts is that there is too much of a delay. I've written a perl deamon that watches the ZM logs for the start of an event and sends an audio alert and it is much quicker than waiting for the filter to be triggered.

It is discussed here:
http://www.zoneminder.com/forums/viewtopic.php?f=8&t=5414

_________________
MRD


Wed Feb 06, 2013 4:28 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 17 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group