Hello!
Since the child is already at that age when he goes to school and comes out of it on his own, while having a broken training schedule, it has become a task of monitoring, as he does his lessons, how long the piano and other educational tasks are involved.
But there is not much money to buy any specialized solutions, so it was decided to scrape the rubble in the server room and, with the permission of the management, drag the Xblitz iSee P2P IP WiFi IP camera home.
')
Xblitz iSee P2P IP WiFi CameraONVIF support was announced in the camera, which automatically suggested that you need to install ZoneMinder and control the device through it.
I installed it, but as it turned out, this camera did not want to work with it for any settings.
In the web interface of the camera, it turned out that the manufacturer of the camera before branding for the Polish market is the Chinese manufacturer netcam360.
Camera web interface

After determining the real manufacturer, through a search engine, it turned out that not only I have problems with the above format. And not only I could not configure to work with the specified protocol. Apparently, the inclusion of ONVIF in the interface is nothing more than a joke from programmers from China.
Enable ONVIF in the interface

It was decided that I will capture through RTSP. Fortunately, this method worked.
But, since I became interested in the topic of writing a service in systemd, I decided not to make a simple bash script for capturing a stream, but to create such a service.
As it turned out, writing a service is a very simple procedure. Here is the code for a simple service called “camera @ .service”, which is located in / etc / systemd / system
Service "Camera"
[Unit] Description=Camera Service on %I After=network.target [Service] Type=simple KillSignal=HUP User=camera SyslogIdentifier=camera_%i ExecStart=/bin/bash -a -c '</dev/tcp/%i/10554 && source /etc/camera.conf && mkdir -p /home/camera/%i && cd /home/cam era/%i && exec /usr/bin/openRTSP -D 5 -F $DATE -K -4 -P 3600 -l -b 200000 rtsp://%i:10554/udp/av0_0' Restart=always RestartSec=10
As you can see, the service is started with the “systemctl start camera @ IP-address” command.
In /etc/camera.conf just one line, it was done in order to comply with the canons of the Linux-service
The contents of the configuration file
DATE=$(date "+%Y_%m_%d_%H_%M_%S")
For convenience, I registered the name "eye01" in / etc / hosts on this IP.
It is assumed that in the future there may be three cameras.
It remains only to add to cron the deletion of obsolete files, since one hour of recording is about 1.5 GB of file.
find /home/camera/eye01 -mtime +2 -delete
And you can safely monitor.
But after a few days I found out that the camera sometimes stops responding and the video stops.
I had to schedule the cron to check the camera with the help of the script, to inform about it in slack and to restart the camera. Empirically determined that it can hang once in 10-12 hours. Therefore, the scheduler checks whether the camera writes once every half hour. The loss of half an hour is not critical for me.
Camera check script
Camera restart script
Actually everything. I hope someone else will help my solution to quickly and affordably organize video surveillance.
I would be grateful for any criticism and suggestions for its improvement.
References and publications used
RepositorySlackcat integration with slackcatHow to write a systemd serviceThanks for attention.