having issues getting hooks going

Discussion topics related to mobile applications for ZoneMinder
User avatar
asker
Posts: 1413
Joined: Sun Mar 01, 2015 12:12 pm

Re: having issues getting hooks going

Post by asker » Thu Aug 20, 2020 2:32 pm

Yes, correct. I've made that change.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

lorenjz
Posts: 24
Joined: Fri Feb 28, 2020 12:25 am

Re: having issues getting hooks going

Post by lorenjz » Fri Aug 21, 2020 2:52 am

Any thoughts as to why neither event_start_hook_notify_userscript or event_end_hook_notify_userscript are getting called. I double checked both scripts (I copied the example.py and renamed it and have the end userscript variable pointing to it) are owned by www-data and are executable. I also did a test run manually executing the script and it inserted the line into the log. Neither executed when motion was triggered by a camera. Thoughts?

User avatar
asker
Posts: 1413
Joined: Sun Mar 01, 2015 12:12 pm

Re: having issues getting hooks going

Post by asker » Fri Aug 21, 2020 10:58 am

lorenjz wrote:
Fri Aug 21, 2020 2:52 am
Any thoughts as to why neither event_start_hook_notify_userscript or event_end_hook_notify_userscript are getting called. I double checked both scripts (I copied the example.py and renamed it and have the end userscript variable pointing to it) are owned by www-data and are executable. I also did a test run manually executing the script and it inserted the line into the log. Neither executed when motion was triggered by a camera. Thoughts?
Can't say without seeing zmeventnotification logs (with debug level enabled) on what happens when an applicable event triggers. My guess would be if hooks are on, no objects are detected.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

lorenjz
Posts: 24
Joined: Fri Feb 28, 2020 12:25 am

Re: having issues getting hooks going

Post by lorenjz » Sun Aug 30, 2020 3:39 pm

I had a little more time this morning to try and troubleshoot this. I can see where the logs say that they start example.py and lzhomeseer.py. Both scripts run without any errors when executed manually as the www-data user. example.py hasn't been changed. lzhomeseer.py is a copy of example.py with a few lines to send a push notification to my phone via pushover.

Attached is a log that I saved according to the guidance on the wiki page. It should contain all of event 10099 on monitor 12. Any help or insight that you could provide at your earliest convenience would certainly be appreciated. If I need to clarify any details or add more information I'm happy to do so. Again many thanks for all of your help and guidance!

Loren
Attachments
eid10099zmeventnotification.log
(164.87 KiB) Downloaded 28 times

User avatar
asker
Posts: 1413
Joined: Sun Mar 01, 2015 12:12 pm

Re: having issues getting hooks going

Post by asker » Sun Aug 30, 2020 8:22 pm

I don't quite understand the issue. Both your event start and event end scripts are being called according to your logs.

Code: Select all

08/30/2020 09:39:17.171694 zmeventnotification[9887].DBG [main:935] [|----> FORK:Small Room Sub (12), eid:10099 invoking user start notification script '/var/lib/zmeventnotification/contrib/example.py' 1 10099 12 "Small Room Sub" "" "[]"  "/var/cache/zoneminder/events/12/2020-08-30/10099"]
08/30/2020 09:39:21.239339 zmeventnotification[9887].DBG [main:935] [|----> FORK:Small Room Sub (12), eid:10099 invoking user end notification script '/var/lib/zmeventnotification/contrib/lzHomeseer.py' 0 10099 12 "Small Room Sub" "Motion: All" "[]"  "/var/cache/zoneminder/events/12/2020-08-30/10099"]
Note however, this log:

Code: Select all

08/30/2020 09:39:19.219835 zmeventnotification[9887].DBG [main:935] [|----> FORK:Small Room Sub (12), eid:10099 should NOT send alarm as Monitor 12 is excluded]
I don't know what your script are doing, but summary:
a) They are being called
b) the ES itself is not sending a push as Monitor 12 is excluded (likely not selected in zmNinja)
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

lorenjz
Posts: 24
Joined: Fri Feb 28, 2020 12:25 am

Re: having issues getting hooks going

Post by lorenjz » Mon Aug 31, 2020 2:35 am

asker wrote:
Sun Aug 30, 2020 8:22 pm
I don't quite understand the issue. Both your event start and event end scripts are being called according to your logs.

Code: Select all

08/30/2020 09:39:17.171694 zmeventnotification[9887].DBG [main:935] [|----> FORK:Small Room Sub (12), eid:10099 invoking user start notification script '/var/lib/zmeventnotification/contrib/example.py' 1 10099 12 "Small Room Sub" "" "[]"  "/var/cache/zoneminder/events/12/2020-08-30/10099"]
08/30/2020 09:39:21.239339 zmeventnotification[9887].DBG [main:935] [|----> FORK:Small Room Sub (12), eid:10099 invoking user end notification script '/var/lib/zmeventnotification/contrib/lzHomeseer.py' 0 10099 12 "Small Room Sub" "Motion: All" "[]"  "/var/cache/zoneminder/events/12/2020-08-30/10099"]
Note however, this log:

Code: Select all

08/30/2020 09:39:19.219835 zmeventnotification[9887].DBG [main:935] [|----> FORK:Small Room Sub (12), eid:10099 should NOT send alarm as Monitor 12 is excluded]
I don't know what your script are doing, but summary:
a) They are being called
There is an entry in the log that says they are being called. However zmeventnotification_userscript_example.log has no evidence that they are (aside from the two manual attempts that I made today). Thoughts?

example.py looks like this fyi:

Code: Select all

import sys
import pyzm.ZMLog as zmlog
import http.client, urllib
import json

# Arguments:
# All scripts invoked with the xxx_userscript tags
# get the following args passed
#   ARG1: Hook result - 0 if object was detected, 1 if not.
#         Always check this FIRST  as the json/text string
#         will be empty if this is 1
#
#   ARG2: Event ID
#   ARG3: Monitor ID
#   ARG4: Monitor Name
#   ARG5: object detection string
#   ARG6: object detection JSON string
#   ARG7: event path (if hook_pass_image_path is yes)




zmlog.init(name='zmeventnotification_userscript_example')
zmlog.Info ("This is a dummy script. Only for your testing. I got {} as arguments".format(sys.argv[1:]))
and zmeventnotification_userscript_example.log:

Code: Select all

08/30/20 17:12:04 zmeventnotification_userscript_example[6066] INF example.py:25 [This is a dummy script. Only for your testing. I got ['0', '1', '2', '3', '4', '5', '6', '7'] as arguments]
08/30/20 17:13:56 zmeventnotification_userscript_example[6160] INF example.py:24 [This is a dummy script. Only for your testing. I got ['0', '1', '2', '3', '4', '5', '6', '7'] as arguments]

User avatar
asker
Posts: 1413
Joined: Sun Mar 01, 2015 12:12 pm

Re: having issues getting hooks going

Post by asker » Mon Aug 31, 2020 12:37 pm

There could be several things.

1. I noticed your script doesn't have "#!/usr/bin/python" or wherever python is located at the top
2. When running in daemon mode, make sure your script has permissions of www-data.
3. When you executed it manually, what was the exact command you used?
4. Make sure your script has execute permissions

the ES will call the script. The rest is upto your script and how it behaves.
--
My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

lorenjz
Posts: 24
Joined: Fri Feb 28, 2020 12:25 am

Re: having issues getting hooks going

Post by lorenjz » Tue Sep 01, 2020 3:11 am

asker wrote:
Mon Aug 31, 2020 12:37 pm
1. I noticed your script doesn't have "#!/usr/bin/python" or wherever python is located at the top

Good catch. That was it Again thanks a ton!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests