среда, 26 сентября 2012 г.

Starting with zoneminder

I've been recently considering the way to establish some sort of surveillance system for my holiday house, which is 80 km away from my city of residence and left unattended during cold winter months.

Being a little biased towards open source software I was really excited to find out that there is an open source alternative for CCTV servers, named Zoneminder.

I decided to test it on my laptop.
In ubuntu 12.04 zoneminder package comes with its latest version - 1.25.0-1. Zoneminder requires apache2 server and mysql in order to store and present its data, making it possible for an easy remote http access. So these dependencies got installed along with zoneminder itself.

After the installation apache, mysql and zoneminder services were started without problems. But when attempting to access http://localhost/zm I was getting 404 error. The solution was found in zoneminder wiki and was pretty simple:
$ln -s /usr/share/zoneminder /var/www/zm
this adds link to zoneminder directory inside apache2 contents directory.

After this operation page opens without errors, but... it is blank! Again wiki helps with the solution - set short_open_tag to on in /etc/php5/apache2/php.ini and restart apache. In my case it was already set, so restart was enough:
sudo service apache2 restart

Now zoneminder console was accessible via http://localhost/zm and I proceeded with adding my Venus USB2.0 camera.

I used zoneminder documentation to set values for monitor. Overall it was simple process, the only parameters that brought confusion were 'Device Format' and 'Capture Palette' on Source tab. It took some time to figure out the proper values for my camera, thanks to this article I found that correct combination for me was
Device Format = PAL
Capture Palette = YUYV

But even after setting the values I was unable to see video. Zoneminder log (accessible from main zoneminder window - console) showed me the error:
Failed to open video device /dev/video0: Permission denied

Pretty much obvious, ls -la /dev/video0 showed that device is owned by user root and group video, while zoneminder was trying to access it as user www-data. Thus the solution was to add www-data in group video:
sudo usermod -a -G video www-data

After that another two errors were still residing in logs:
Shared data size conflict in shared_data for monitor Monitor-1, expected 328, got 316
Got unexpected memory map file size 3073192, expected 9217192 

The first error is actually a bug in zoneminder and I solved it thanks to this article, the solution was to patch file /usr/share/perl5/ZoneMinder/Memory.pm at line 130:
-our $arch = int(3.2*length(~0));
+our $arch = 32;
For the second error the same guy helped with this article, the solution was to make linux kernel shmmax larger, for me 128MB was sufficient:
sudo sysctl -w kernel.shmmax=536870912

Obviously this value will be reset after reboot so to make it persistent add into /etc/sysctl.conf:

After solving all the issues I played a little bit with my cheap camera and zoneminder including motion detection and exporting events to download them as zip files. So far everything works great and I find zoneminder to be really easy to use.

1 комментарий: