Re: having issues getting hooks going
Posted: Thu Aug 20, 2020 2:32 pm
Yes, correct. I've made that change.
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.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?
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"]
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]
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?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.Note however, this log: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"]
I don't know what your script are doing, but summary: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]
a) They are being called
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:]))
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]
Code: Select all
sudo -u http /usr/bin/zmeventnotification.pl --debug
Code: Select all
chown -R http:http /var/lib/zmeventnotification/push
Code: Select all
tail -F /var/log/zoneminder/zmesdetect*.log
Code: Select all
tail -f /var/log/zoneminder/zmeventnotification.log
Code: Select all
5/12/2020 11:55:32.462774 zmeventnotification[617].DBG [main:964] [PARENT: checkEvents() new events found=1]
05/12/2020 11:55:32.462796 zmeventnotification[617].DBG [main:964] [PARENT: There are 1 new Events to process]
05/12/2020 11:55:32.463656 zmeventnotification[617].DBG [main:964] [PARENT: ---------->Tick END<--------------]
05/12/2020 11:55:32.466944 zmeventnotification[1351].DBG [main:964] [PARENT: Forked process:1351 to handle alarm eid:21055]
05/12/2020 11:55:32.467343 zmeventnotification[1351].DBG [ZoneMinder::Object:115] [Loading ZoneMinder::Event from Events WHERE Id = 21055]
05/12/2020 11:55:32.468685 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 Adding event path:/var/lib/zoneminder/events/2/2020-12-05/21055 to hook for image storage]
05/12/2020 11:55:32.468723 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 Invoking hook on event start:'/var/lib/zmeventnotification/bin/zm_event_start.sh' 21055 2 "Interno-1" "Motion Ingresso-1" "/var/lib/zoneminder/events/2/2020-12-05/21055"]
05/12/2020 11:55:32.626111 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 parse of hook: and []]
05/12/2020 11:55:32.626179 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 hook start returned with text: json:[] exit:1]
05/12/2020 11:55:32.626268 zmeventnotification[1351].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178562048 for 2]
05/12/2020 11:55:32.626413 zmeventnotification[1351].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 2: 1]
05/12/2020 11:55:34.627035 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 rules: Checking rules for alarm caused by eid:21055, monitor:2, at: Sat Dec 5 11:55:34 2020 with cause:Motion Ingresso-1]
05/12/2020 11:55:34.627141 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 rules: No rules found for Monitor, allowing:2]
05/12/2020 11:55:34.627250 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 Matching alarm to connection rules...]
05/12/2020 11:55:34.627399 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 Checking alarm conditions for token ending in:...stRS-Lnn6v]
05/12/2020 11:55:34.627598 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 Monitor 2 event: should send out as 39.5858800411224 is >= interval of 0]
05/12/2020 11:55:34.627661 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 shouldSendEventToConn returned true, so calling sendEvent]
05/12/2020 11:55:34.628256 zmeventnotification[1351].DBG [main:964] [|----> FORK:Interno-1 (2), eid:21055 isAllowedChannel: got type:event_start resCode:1]
05/12/2020 11:55:34.628777 zmeventnotification[1351].INF [main:976] [|----> FORK:Interno-1 (2), eid:21055 Not sending over FCM as notify filters are on_success:all and on_fail:none]
05/12/2020 11:55:34.966403 zmeventnotification[1351].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178562048 for 2]
05/12/2020 11:55:34.966646 zmeventnotification[1351].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 2: 1]
05/12/2020 11:55:36.966829 zmeventnotification[1351].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178562048 for 2]
05/12/2020 11:55:36.966917 zmeventnotification[1351].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 2: 1]
05/12/2020 11:55:37.239375 zmeventnotification[617].DBG [main:964] [PARENT: ---------->Tick START<--------------]
05/12/2020 11:55:37.239728 zmeventnotification[617].DBG [main:964] [PARENT: After tick: TOTAL: 1, ES_CONTROL: 0, FCM+WEB: 0, FCM: 1, WEB: 0, MQTT:0, invalid WEB: 0, PENDING: 0]
05/12/2020 11:55:37.241008 zmeventnotification[617].DBG [main:964] [PARENT: RAW TEXT-->timestamp--TYPE--1607165491.91697--SPLIT--2--SPLIT--1607165734.62769]
05/12/2020 11:55:37.241245 zmeventnotification[617].DBG [main:964] [PARENT: Job: Update last sent timestamp of monitor:2 to 1607165734.62769 for id:1607165491.91697]
05/12/2020 11:55:37.241451 zmeventnotification[617].DBG [main:964] [PARENT: There are 1 active child forks...]
05/12/2020 11:55:37.241693 zmeventnotification[617].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178562048 for 2]
05/12/2020 11:55:37.242032 zmeventnotification[617].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 2: 1]
05/12/2020 11:55:37.242566 zmeventnotification[617].DBG [main:964] [PARENT: We've already worked on Monitor:2, Event:21055, not doing anything more]
05/12/2020 11:55:37.242697 zmeventnotification[617].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178541568 for 7]
05/12/2020 11:55:37.242880 zmeventnotification[617].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 7: 1]
05/12/2020 11:55:37.243156 zmeventnotification[617].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178557952 for 3]
05/12/2020 11:55:37.243332 zmeventnotification[617].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 3: 1]
05/12/2020 11:55:37.243593 zmeventnotification[617].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178549760 for 5]
05/12/2020 11:55:37.243765 zmeventnotification[617].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 5: 1]
05/12/2020 11:55:37.243968 zmeventnotification[617].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178553856 for 4]
05/12/2020 11:55:37.244137 zmeventnotification[617].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 4: 1]
05/12/2020 11:55:37.244369 zmeventnotification[617].DBG [ZoneMinder::Memory::Mapped:84] [zmMemAttach already attached at 139910178545664 for 6]
05/12/2020 11:55:37.244533 zmeventnotification[617].DBG [ZoneMinder::Memory:300] [Shared data appears valid for monitor 6: 1]
05/12/2020 11:55:37.244761 zmeventnotification[617].DBG [main:964] [PARENT: checkEvents() new events found=0]
Code: Select all
sudo -u http '/var/lib/zmeventnotification/bin/zm_event_start.sh' 21055 2 "Interno-1" "Motion Ingresso-1" "/var/lib/zoneminder/events/2/2020-12-05/21055"
Code: Select all
sudo -u http '/var/lib/zmeventnotification/bin/zm_event_start.sh' 21055 2 "Interno-1" "Motion Ingresso-1" "/var/lib/zoneminder/events/2/2020-12-05/21055"
[a] detected:truck:39% --SPLIT--[{"type": "object", "label": "truck", "box": [802, 539, 1006, 675], "confidence": "38.84%"}]
Code: Select all
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.9/site-packages/
No. /var/log/zoneminder/zmesdetect*.log were not updated at all, when running in daemon mode.
I added more then one, to log some informations (for example, the output of whoami, the hour in which the script is runned, and the values of the various variables). The one that made me understand the problem was this:
Code: Select all
...
DETECTION_SCRIPT=(/var/lib/zmeventnotification/bin/zm_detect.py --monitorid $2 --eventid $1 --config "${CONFIG_FILE}" --eventpath "${EVENT_PATH}" --reason "${REASON}" )
DS_OUTPUT=$("${DETECTION_SCRIPT[@]}" 2>&1)
echo "$DS_OUTPUT" >> $LOGFILE
RESULTS=$("${DETECTION_SCRIPT[@]}" | grep "detected:")
...