ZoneMinder and FreeNAS 9.1.1

Forum for questions and support relating to the 1.25.x releases only.
Locked
duk242
Posts: 2
Joined: Tue Sep 24, 2013 8:18 am

ZoneMinder and FreeNAS 9.1.1

Post by duk242 »

Spent a while today trying to get ZoneMinder 1.25.0 running on my FreeNAS 9.1.1 box (HP MicroServer, 8gb Ram, 10tb Storage) in a Jail, I got part of the way there, however I'm rather stuck at the moment.

Compiling it seemed to work fine in a fresh new jail, Apache, MySQL, PHP and ZoneMinder installed without a hitch and I took some pretty extensive notes about the process (I was hoping to write a guide if I could get it working properly, as there was a lot of little tweaks that needed to be done (httpd.conf, php.ini, rc.d settings and so on)).
I installed ZoneMinder from /usr/ports/multimedia/zoneminder/ which *should* work in FreeBSD...

So, the web interface seems to work, it lets me add a camera, however the camera never connects properly. Going into the Log file I can see the following:

Code: Select all

2013-09-24 18:20:43.354210	zmwatch	32767	ERR	Can't get shared memory id '7a6d0001', 1: Function not implemented	zmwatch.pl	
2013-09-24 18:20:37.091510	zmdc	32767	ERR	'zmc -m 1' exited abnormally, exit status 255	zmdc.pl	
2013-09-24 18:20:37.089802	zmc_m1	32767	ERR	Can't shmget, probably not enough shared memory space free: Function not implemented	zm_monitor.cpp	381
2013-09-24 18:20:37.048010	zmdc	32767	INF	'zmc -m 1' started at 13/09/24 18:20:37	zmdc.pl	
2013-09-24 18:20:37.047660	zmdc	32767	INF	'zmc -m 1' starting at 13/09/24 18:20:37, pid = 59274	zmdc.pl	
2013-09-24 18:20:37.043680	zmdc	32767	INF	Starting pending process, zmc -m 1
So you can see the zmc command firing up then failing 0.04sec later. Googling this led me to see a whole bunch of other people with similar issues to do with the kernel shmmax values. I checked mine, it's on 536870912 (512MB) which should be plenty, but I doubled it just in case (since it's running in a jail, this was done through the FreeNAS tunables part).

Checking the debug log I get

Code: Select all

Sep 24 17:45:17 recorder zmc_m1[55873]: DB1 [LogOpts: level=DB9/DB9, screen=OFF, database=INF, logfile=DB9->/tmp/zm/zm_debug.log.55873, syslog=DB9]
Sep 24 17:45:17 recorder zmc_m1[55873]: DB1 [Got 1 monitors]
Sep 24 17:45:17 recorder zmc_m1[55873]: DB2 [Request: GET /videostream.cgi?user=zoneminder&pwd=nope HTTP/1.1^M User-Agent: ZoneMinder/1.25.0^M Host: 192.168.0.130^M ^M ]
Sep 24 17:45:17 recorder zmc_m1[55873]: DB1 [monitor purpose=1]
Sep 24 17:45:17 recorder zmc_m1[55873]: DB1 [mem.size=2305044]
That all seems fine too (doesn't even say anything failed there).

So, I figured it could still be a memory issue and I decided to recompile with the --enable-mmap=yes option set, however then it wouldn't compile and would throw me this error:

Code: Select all

zm_monitor.cpp: In constructor 'Monitor::Monitor(int, const char*, int, bool, const char*, Camera*, int, const char*, const char*, const Coord&, int, int, int, int, int, int, int, int, int, int, int, int, bool, Rgb, Monitor::Purpose, int, Zone**)':
zm_monitor.cpp:368: error: 'MAP_LOCKED' was not declared in this scope
*** [zm_monitor.o] Error code 1
mv -f .deps/zm_local_camera.Tpo .deps/zm_local_camera.Po
1 error
*** [all-recursive] Error code 1
1 error
*** [all] Error code 2
1 error
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** [do-build] Error code 1

Stop in /usr/ports/multimedia/zoneminder.
That looks to be because mmap on FreeBSD doesn't have the MAP_LOCKED option.

So: Has anyone got this working properly on FreeNAS in a jail yet, or have any suggestions as to what I can try next to get it working?

Thanks!

Ducky
josh4trunks
Posts: 2
Joined: Sun Sep 29, 2013 3:18 pm

Re: ZoneMinder and FreeNAS 9.1.1

Post by josh4trunks »

In the near future I am going to to convert one of my servers to FreeBSD and will have a jail on there dedicated to zoneminder. Hopefully we can work through and problems getting it working and have it documented for others to use.

I know FreeBSD jails have a problem accessing shared memory because it has security implecations between jails. You might want to try

Code: Select all

sysctl sysvipc_allow=1
in your FreeNAS host userland. then restart your plugin jail. If this works you'd want to put it in /boot/loader.conf. Problems is.. in FreeNAS I believe this is a ramdisk, so you edit a different file (from a readonly system partition). This partition gets copied over to ram during boot. You also need to do this anytime you upgrade your FreeNAS system.

####
Hope that works, I presume you are using IP cameras?
duk242
Posts: 2
Joined: Tue Sep 24, 2013 8:18 am

Re: ZoneMinder and FreeNAS 9.1.1

Post by duk242 »

Oh dude that's totally it!

On FreeNAS I had to do the following commands:

Code: Select all

[duck@zoe] /etc# jls
   JID  IP Address      Hostname                      Path
     2  -               thebrig                       /mnt/caprica/thebrig/thebrig
     3  -               recorder                      /mnt/caprica/thebrig/recorder
[duck@zoe] /etc# jail -m jid=3 allow.sysvipc=1
That's to give the jail the ability to use that sysvipc option.

I actually already started playing with another application called motion, so now I'm going to have to try them both out and compare between the two of them to decide what I want to do :P
When I decide what I'm going to do, I plan on writing up a FreeNAS security camera guide (if I haven't done it by the time you decide to do yours, send me a message and I'll give you my notes, there's a stack of little options that need setting to get it to work right).

Cheers!

Ducky
josh4trunks
Posts: 2
Joined: Sun Sep 29, 2013 3:18 pm

Re: ZoneMinder and FreeNAS 9.1.1

Post by josh4trunks »

I used motion a bunch before. It is way more barebones but can get the job done for a few cameras. Zoneminder is better when you want to start graphing out stuff / allow guest viewing access / more advanced functionality.
SinDeus
Posts: 2
Joined: Fri Sep 12, 2014 1:09 pm

Re: ZoneMinder and FreeNAS 9.1.1

Post by SinDeus »

Hi there!

Sorry for bringing this old topic back up, but I would be very interested in seeing your guides for setting up ZoneMinder on FreeNAS.
Actually, I already succeeded in making it work - except I can't see any video playing (static images are fine, though). That's why I wanted to know if anyone ever had this issue and/or how they solved it...

I installed ZonMinder 1.25.0 through ports, inside a jail with Apache/PHP/MySQL (MariaDB), and did every little necessary tweak (including the

Code: Select all

jail -m jid=3 allow.sysvipc=1
) until having my IP camera work.

When I try to launch a video, Cambozola shows up, and displays nothing (the controls are here though). When I try to view it without Cambozola, same issue: a blank image. When inspecting the events, an Apache 500 error seems to be the culprit, although I don't have any clue to how investigate its cause (nothing in /var/log/messages, nor in /var/log/httpd-error.log, neither in ZoneMinder log...).

Does anyone have any clue about this?
SinDeus
Posts: 2
Joined: Fri Sep 12, 2014 1:09 pm

Re: ZoneMinder and FreeNAS 9.1.1

Post by SinDeus »

I'm replying to myself, having found the issue.
As a matter of fact, the PHP socket extension wasn't installed - and every socket-based PHP methods were called with a leading '@' (suppressing every error / warning that could happen). Installing and enabling it was simply enough to get it working!
Locked