Saturday, July 04, 2009

Linux video surveillance, part 2

Because my first go at Linux-based home video surveillance was successful, I went to Fry's and bought components for a dedicated machine. I went with a MicroATX Gigbyte motherboard, small Antec Case, a 64-bit dual-core AMD X2 processor, 2 GB Kingston RAM, and a Seagate 750GB SATA drive. I figured this system wouldn't need an optical drive after the OS was installed, so I didn't bother buying one. The total for the system was about $300, and the most expensive part was the Antec case (about $100).

The best part is that my wife, Anna, assembled the whole system and installed Xubuntu Jaunty 9.04. She isn't very into this stuff, but she did it with very little direction and no physical help. What a sport!

After she installed the OS, I installed the packages needed for video surveillance:
sudo apt-get update
sudo apt-get install zoneminder

This doesn't get you 100% there--you have to enable ZoneMinder in Apache like so:
sudo ln -s /etc/zm/apache.conf /etc/apache2/sites-available/zoneminder
sudo a2ensite zoneminder

Now ZoneMinder was reachable at http://localhost/zm and I started configuration. I added the Panasonic camera as an external source (the same one from my last post), but the camera's page in ZoneMinder had no image. Going directly to the camera worked, so I knew I had a problem somewhere on my new system.

I enabled debugging in the "Options" section of the web interface and restarted Zoneminder:
sudo /etc/init.d/zoneminder restart

And found this in the debug logs located in /tmp:
07/04/09 09:21:11.757615 zmc_m2[32546].DB1-zm_monitor.cpp/259 [monitor purpose=1]
07/04/09 09:21:11.757662 zmc_m2[32546].DB1-zm_monitor.cpp/266 [shm.size=36865516]
07/04/09 09:21:11.757723 zmc_m2[32546].ERR-zm_monitor.cpp/270 [Can't shmget, probably not enough shared memory space free: Invalid argument]

Google found me an answer in the ZoneMinder FAQ:
sudo sysctl kernel.shmmax=36869516
sudo sysctl kernel.shmall=46869516

To make this permanent, I created /etc/sysctl.d/60-shmem.conf and added:
# Needed for zoneminder camera buffer
kernel.shmall = 46869516
kernel.shmmax = 36869516
kernel.shmmni = 4096

My one camera is working great, but I'm anxiously awaiting 2 more that should arrive next week. I installed my BlueCherry video capture card and will post again when I've hooked up my other cameras.



datSilencer said...

Hello. Thanks for the shared memory tweaking tip. It seems as if the siteminder faq pages are gone though :P, since that siteminder link just takes me to the main homepage.

Thanks again. Cheers!

Aaron Smith said...

Thanks, datSilencer! Link updated.