Closed DanielBorgesOliveira closed 4 years ago
Thanks for opening your first issue here! Just a reminder, this forum is for Bug Reports only. Be sure to follow the issue template!
Nice. You might want to post this in the User Contributions forum
Yeah I think this belongs in the User Contributions forum.
Okay. I will post it in the user forum.
Thank you pals.
@DanielBorgesOliveira
Hi @caddik5,
I just updated the code. Please, get the last version here. The setup is pretty straight forward. I thought the provided instructions were sufficient. Can you describe what is the problem are you facing?
Hi @DanielBorgesOliveira Thanks for posting and updating. My issues are probably more to do with my skills rather than your explanations. I have have another go this week at your update.
Change line 78 with your bot token; Change line 79 with your chat ID; Change line 74 with the path where the videos are stored. hello you find them or is it online?
I already have a telegram bot my request is that I understand how you install your script
You have to download the telegram.py, watchdog_events_zm.py and watchdog_logging.py from here.
In line 78 of the file watchdog_events_zm.py you have to change the variable TelegramToken to your Bot Token, In line 79 of the file watchdog_events_zm.py you have to change the variable TelegramChatID to the chat ID of the chat where the bot has to send messages. In line 74 of the file watchdog_events_zm.py you have to change the variable path to point to the path where zoneminder stores the video files. This is usually "/var/cache/zoneminder/events".
The last thing you should do is call the file watchdog_events_zm.py like this:
/usr/bin/python3 watchdog_events_zm.py
The last thing you should do is call the file watchdog_events_zm.py like this: /usr/bin/python3 watchdog_events_zm.py'
hello, I do not understand what to do? do I have to rename it or place it in the directory? and the three downloaded file I put them where?
Hi @titof2375
The last thing you should do is call the file watchdog_events_zm.py like this: /usr/bin/python3 watchdog_events_zm.py'
This video shows how to run python from Windows: https://www.youtube.com/watch?v=Qi28uPKaH_A. This video shows how to run python from Linux: https://www.youtube.com/watch?v=asnGiNwo4RU.
hello, I do not understand what to do? do I have to rename it or place it in the directory? and the three downloaded file I put them where?
Download all the files. Put it in some folder you choose. Lastly, you have to run the code.
Hello Daniel, thanks for this useful script. How about filters? I have set a filter for send Videos via email for out off ofice time. Your script seems send every event and ignore filters.
Hi @sbethge,
That is true. I did this script to send files that are created in a specific situation. In this case, I used zones to defined what is filmed. This is a real-time delivery system. I made the script to send the video as fast as possible. Because of this, I think that filters are not applicable.
for some reason script send to me 2 videos. first one /events/1/2022-12-30/7987/7987-video.mp4.incomplete (video dosent work) and second /events/1/2022-12-30/7987/7987-video.mp4...
So i fixed it by adding line not '.incomplete' in event.src_path: # This avoid send file than once.
my Dockerfile
FROM python:3
WORKDIR /app
RUN apt update && apt install lsof -y
COPY requirements.txt .
RUN pip3 install -r requirements.txt
COPY *.py .
CMD python3 -u watchdog_events_zm.py
requirements.txt
watchdog
requests
docker-compose.yaml
version: '3.1'
services:
zoneminder:
container_name: zoneminder
image: zoneminderhq/zoneminder:latest-el7
restart: unless-stopped
ports:
- 8883:443/tcp
- 9000:9000/tcp
- 80:80
network_mode: "bridge"
privileged: false
shm_size: 7G
environment:
- TZ=Europe/Warsaw
- PUID=99
- PGID=100
- MULTI_PORT_START=0
- MULTI_PORT_END=0
volumes:
- /dockerdata/zoneminder/events:/var/lib/zoneminder/events
- /dockerdata/zoneminder/mysql:/var/lib/mysql
- /dockerdata/zoneminder/logs:/var/log/zm
watchdog:
container_name: watchdog
build: watchdog/.
networks:
- monitor-net
volumes:
- /dockerdata/zoneminder/events:/events
environment:
- TZ=Europe/Warsaw
privileged: true
networks:
monitor-net:
driver: bridge
Hi @ysechynskyy,
Thank you very much for the contribution.
Hello Daniel. Please write in the description that the screen script must be run under sudo. Otherwise, lsof will not have access to the event.src_path file.
Hi guys,
I would like to share a python script I created and proved to be very useful for me. This script monitors the video folder and sends the created videos to telegram, in case of some alarm be triggered.
Here some instructions to make it work:
pip3 install watchdog requests
Create a screen session: `/usr/bin/screen -S WATCHDOG
Run the command: 'sudo /usr/bin/python3 /root/watchdog/watchdog_events_zm.py'`
PS: as pointed out by @leonopulo the script has to be executed under sudo. Otherwise the lsof command will not work as expected.
The code can be found here .
Sorry if this should not be posted here. If that the case, please deleted this post.
Thank you.