Zoneminder on FreeNAS

Status
Not open for further replies.

petr

Contributor
Joined
Jun 13, 2013
Messages
142
Hi, on my configuration (9.3 Stable) I have so far no problem with any instability.

.. did you also have a config running on 9.3? I would probably not go with it, as the whole point of a jail for me is to have separation.. if ZM is unable to run on it, then I will need to find other solution.
 

SinDeus

Explorer
Joined
Sep 3, 2013
Messages
65
I would like to add a big, fat warning here - really do a LOT of testing before finalising the setup. The thing is, the

Code:
allow.sysvipc=1


can have quite wide security/stability implications. My system is now locking up after a few hours of use, and the only change is really the zm jail with the sysipc enable (I've removed any tunables earlier). To clarify, locking-up is not the best term. The web service stops working, I cannot SSH in anymore but other services like file sharing still work. I was also able to get up a physical machine but it does not respond to reboot commands and the apache process (within jail) cannot be killed.. which I consider concerning at least!

I do not think it was explicitly said in this thread but I recommend utmost caution when giving jails too much privileges.. The main worrying part for me is that it made the whole system lock up / unstable...

Sources:
http://serverfault.com/questions/15...ions-of-using-allow-sysvipc-in-a-freebsd-jail
https://www.freebsd.org/doc/en/books/arch-handbook/jail-restrictions.html

Strange, I do not have these locks on my build.

Wait! Maybe I know, for I have experienced similar issues, but not due to this tunable. My web server stopped responding to anything, I couldn't log into the jail, because I limited the jail storage.
What's happening is ZoneMinder is constantly saving events, which take up more and more space, until reaching 100% of the jail storage... thus preventing a whole bunch of programs to work (including the webserver).

My advice: set up an automatic filter on ZoneMinder to clean events if the available space goes below 5-10%.

Keep me posted on this issue.
 

petr

Contributor
Joined
Jun 13, 2013
Messages
142
Strange, I do not have these locks on my build.

Wait! Maybe I know, for I have experienced similar issues, but not due to this tunable. My web server stopped responding to anything, I couldn't log into the jail, because I limited the jail storage.
What's happening is ZoneMinder is constantly saving events, which take up more and more space, until reaching 100% of the jail storage... thus preventing a whole bunch of programs to work (including the webserver).

My advice: set up an automatic filter on ZoneMinder to clean events if the available space goes below 5-10%.

Keep me posted on this issue.

I think my storage should be OK - it's on the main pool with around 8TB free at this moment, and I've also configured ZM to store events to a mounted directory to be able to back them up more easily from other machines.

As I've said, I've managed to get local console on the "locked up" machine using IPMI. The top command yielded a 100% CPU for httpd process inside of the jail. Which would have been OK if it was a normal restricted jail I suppose.

What the allow.sysvipc=1 did however was to somehow interact with the rest of the system, consequence of which was following:
  • the main freenas webserver was unresponsive
  • unable to connect to local SSH
  • nfs/cifs still seemed to be running OK
  • virtualbox VMs in testing were OK as well, also other processes that were running before the "event" worked OK
  • most importantly - kill -9 jails_http_id did not do the job - it simply could not be killed.
My assumption is that allowing the sysvipc allowed some leakage of messages between privileged accounts in the jail and them main system - and the system did not like it. To be hones, it really was my bad - I was assuming that jails were isolated, otherwise I would never allow sysvipc in the first place, I prefer to have FreeNAS as "pure" as possible for sanity reasons..
 

SinDeus

Explorer
Joined
Sep 3, 2013
Messages
65
Damn. Regarding the 100% CPU charge, you could try to lower the cam FPS...
I ran a top command on my jail too, and here it is:
Code:
PID USERNAME    THR PRI NICE   SIZE    RES STATE   C   TIME   WCPU COMMAND
57644 www           1  24    0   243M 48484K select  0  46:39  8.50% zmc
57646 www           1  22    0   243M 48240K nanslp  1  23:55  3.27% zma
9768 mysql        30  20    0   300M  9756K sbwait  0   2:07  0.00% mysqld
57622 www           1  20    0 75132K  2508K select  1   0:14  0.00% perl
9889 root          1  20    0   290M   492K select  1   0:13  0.00% httpd
9853 postfix       1  20    0 27216K   824K kqread  0   0:04  0.00% qmgr
92504 www           1  20    0   310M  1416K lockf   0   0:03  0.00% httpd
92530 www           1  20    0   318M  1080K kqread  0   0:03  0.00% httpd
9851 root          1  20    0 27220K   532K kqread  0   0:02  0.00% master
92527 www           1  20    0   306M   752K lockf   1   0:02  0.00% httpd
31443 www           1  20    0   310M   752K lockf   0   0:02  0.00% httpd
57652 www           1  20    0 75132K  3320K nanslp  1   0:02  0.00% perl
92503 www           1  20    0   310M   772K lockf   0   0:02  0.00% httpd
57650 www           1  20    0 81284K  9068K nanslp  1   0:01  0.00% perl
9294 root          1  20    0 12092K   492K select  0   0:01  0.00% syslogd
57648 www           1  20    0 95672K  7004K nanslp  1   0:01  0.00% perl


The httpd is pretty low, as you can see. I wonder what's happening...
 

petr

Contributor
Joined
Jun 13, 2013
Messages
142
Damn. Regarding the 100% CPU charge, you could try to lower the cam FPS...
I ran a top command on my jail too, and here it is:
Code:
PID USERNAME    THR PRI NICE   SIZE    RES STATE   C   TIME   WCPU COMMAND
57644 www           1  24    0   243M 48484K select  0  46:39  8.50% zmc
57646 www           1  22    0   243M 48240K nanslp  1  23:55  3.27% zma
9768 mysql        30  20    0   300M  9756K sbwait  0   2:07  0.00% mysqld
57622 www           1  20    0 75132K  2508K select  1   0:14  0.00% perl
9889 root          1  20    0   290M   492K select  1   0:13  0.00% httpd
9853 postfix       1  20    0 27216K   824K kqread  0   0:04  0.00% qmgr
92504 www           1  20    0   310M  1416K lockf   0   0:03  0.00% httpd
92530 www           1  20    0   318M  1080K kqread  0   0:03  0.00% httpd
9851 root          1  20    0 27220K   532K kqread  0   0:02  0.00% master
92527 www           1  20    0   306M   752K lockf   1   0:02  0.00% httpd
31443 www           1  20    0   310M   752K lockf   0   0:02  0.00% httpd
57652 www           1  20    0 75132K  3320K nanslp  1   0:02  0.00% perl
92503 www           1  20    0   310M   772K lockf   0   0:02  0.00% httpd
57650 www           1  20    0 81284K  9068K nanslp  1   0:01  0.00% perl
9294 root          1  20    0 12092K   492K select  0   0:01  0.00% syslogd
57648 www           1  20    0 95672K  7004K nanslp  1   0:01  0.00% perl


The httpd is pretty low, as you can see. I wonder what's happening...

Already lowered - it was not a normal situation.. everything would start up normally, with httpd not showing much activity and each camera just showing a few % usage. Then, after a few hours/minutes/random period, everything would lock up. It was using hardly any resources in normal mode!

I have fairly weak connection to some of the cameras so they are 640x480 and max FPS at 5...

Anyway - I am not trying to de-value your work - I am still very grateful for the tutorial, I would just like to advise caution on what are people actually setting up - that they should also pay attention to the jail's security and good passwords etc.
 

SinDeus

Explorer
Joined
Sep 3, 2013
Messages
65
Anyway - I am not trying to de-value your work - I am still very grateful for the tutorial, I would just like to advise caution on what are people actually setting up - that they should also pay attention to the jail's security and good passwords etc.
You did good, and (of course) no offense taken.
 

freenas4n00b

Explorer
Joined
Dec 23, 2013
Messages
52
Kind of thinking out loud here:
With the virtualbox images being more stable; wouldnt it be easier to use virtualbox vm with the version of OS that Zoneminder supports?
I expect that would be faster in getting zoneminder updates and getting help from the zoneminder community

I havent built my zoneminder environment but i plan to just bring up an latest and greatest ubuntu image and follow the instructions on their site https://github.com/ZoneMinder/ZoneMinder

Is there something that i am missing?
 
Last edited:

stroked

Cadet
Joined
Feb 8, 2015
Messages
3
Hello,
I know this is a few months old, but I am having some issues with shared memory. The box is a quad core xeon with 6 gigs of ram (for now).

Build FreeNAS-9.3-STABLE-201501212031
Platform Intel(R) Xeon(R) CPU E5430 @ 2.66GHz
Memory 6118MB

The jail is setup as a standard jail and the install is basically the same as some of the previous posts here but I had to figure it out the hard way before I found this :)

I keep getting these errors:
root@Zoneminder:~ # tail -F /var/log/messages
Feb 11 03:31:35 Zoneminder zmdc[53116]: ERR ['zma -m 1' exited abnormally, exit status 255]
Feb 11 03:31:35 Zoneminder zmdc[53116]: ERR ['zmfilter.pl ' exited abnormally, exit status 9]
Feb 11 03:31:50 Zoneminder zmwatch[53154]: ERR [Can't get shared memory id '7a6d0001', 1: Function not implemented]
Feb 11 03:31:50 Zoneminder zmwatch[53154]: ERR [Can't get shared memory id '7a6d0001', 1: Function not implemented]
Feb 11 03:31:55 Zoneminder zmc_m1[53170]: ERR [Can't shmget, probably not enough shared memory space free: Function not implemented]
Feb 11 03:31:55 Zoneminder zmdc[53116]: ERR ['zmc -m 1' exited abnormally, exit status 255]
Feb 11 03:31:55 Zoneminder zma_m1[53171]: ERR [Can't shmget, probably not enough shared memory space free: Function not implemented]
Feb 11 03:31:55 Zoneminder zmdc[53116]: ERR ['zma -m 1' exited abnormally, exit status 255]
Feb 11 03:31:55 Zoneminder zmdc[53116]: ERR ['zmfilter.pl ' exited abnormally, exit status 9]
Feb 11 03:32:00 Zoneminder zmwatch[53154]: ERR [Can't get shared memory id '7a6d0001', 1: Function not implemented]


[root@freenas] ~# sysctl -a | grep shm | grep -v Zonemind
kern.ipc.shm_allow_removed: 0
kern.ipc.shm_use_phys: 0
kern.ipc.shmall: 33554432
kern.ipc.shmseg: 128
kern.ipc.shmmni: 192
kern.ipc.shmmin: 1
kern.ipc.shmmax: 2457600001
kern.features.sysv_shm: 1
kern.features.posix_shm: 1
 

SinDeus

Explorer
Joined
Sep 3, 2013
Messages
65
Try installing the package for libmime-tools-perl, which seems to be that one.
When I switched to 9.3 a few weeks ago, I had to rebuild my whole ZoneMinder jail, and some libraries were missing... But I had to do this really quick, so I didn't wrote them down to improve this thread. Sorry guys :(
Anyway, try installing this package (either via ports or pkg), and keep us posted.
 

stroked

Cadet
Joined
Feb 8, 2015
Messages
3
Installed that and restarted the service but no change in the logs. Still the shared memory logs.


root@Zoneminder:~ # pkg install p5-MIME-Tools
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 4 packages will be affected (of 0 checked):

New packages to be INSTALLED:
p5-MIME-Tools: 5.505_1,2
p5-Mail-Tools: 2.13_1
p5-TimeDate: 2.30_2,1
p5-Convert-BinHex: 1.123_1

The process will require 0 MiB more space.
0 MiB to be downloaded.

Proceed with this action? [y/N]: y
[Zoneminder] Fetching p5-MIME-Tools-5.505_1,2.txz: 100% 215 KiB 220.2kB/s 00:01
[Zoneminder] Fetching p5-Mail-Tools-2.13_1.txz: 100% 77 KiB 79.6kB/s 00:01
[Zoneminder] Fetching p5-TimeDate-2.30_2,1.txz: 100% 34 KiB 35.5kB/s 00:01
[Zoneminder] Fetching p5-Convert-BinHex-1.123_1.txz: 100% 35 KiB 36.5kB/s 00:01
Checking integrity... done (0 conflicting)
[Zoneminder] [1/4] Installing p5-TimeDate-2.30_2,1...
[Zoneminder] [1/4] Extracting p5-TimeDate-2.30_2,1: 100%
[Zoneminder] [2/4] Installing p5-Mail-Tools-2.13_1...
[Zoneminder] [2/4] Extracting p5-Mail-Tools-2.13_1: 100%
[Zoneminder] [3/4] Installing p5-Convert-BinHex-1.123_1...
[Zoneminder] [3/4] Extracting p5-Convert-BinHex-1.123_1: 100%
[Zoneminder] [4/4] Installing p5-MIME-Tools-5.505_1,2...
[Zoneminder] [4/4] Extracting p5-MIME-Tools-5.505_1,2: 100%
root@Zoneminder:~ # /usr/local/etc/rc.d/zoneminder restart
Starting zoneminder.


root@Zoneminder:~ # tail -F /var/log/messages
Feb 11 10:25:40 Zoneminder zmdc[68536]: ERR ['zmfilter.pl ' exited abnormally, exit status 9]
Feb 11 10:25:46 Zoneminder zmwatch[68574]: ERR [Can't get shared memory id '7a6d0001', 1: Function not implemented]
Feb 11 10:26:16 Zoneminder last message repeated 7 times
Feb 11 10:26:20 Zoneminder zma_m1[68604]: ERR [Can't shmget, probably not enough shared memory space free: Function not implemented]
Feb 11 10:26:20 Zoneminder zmdc[68536]: ERR ['zma -m 1' exited abnormally, exit status 255]
Feb 11 10:26:20 Zoneminder zmc_m1[68605]: ERR [Can't shmget, probably not enough shared memory space free: Function not implemented]
Feb 11 10:26:20 Zoneminder zmdc[68536]: ERR ['zmc -m 1' exited abnormally, exit status 255]
Feb 11 10:26:20 Zoneminder zmdc[68536]: ERR ['zmfilter.pl ' exited abnormally, exit status 9]
Feb 11 10:26:26 Zoneminder zmwatch[68574]: ERR [Can't get shared memory id '7a6d0001', 1: Function not implemented]
Feb 11 10:27:06 Zoneminder last message repeated 8 times
Feb 11 10:27:36 Zoneminder last message repeated 7 times
Feb 11 10:27:40 Zoneminder zma_m1[68623]: ERR [Can't shmget, probably not enough shared memory space free: Function not implemented]
Feb 11 10:27:40 Zoneminder zmdc[68536]: ERR ['zma -m 1' exited abnormally, exit status 255]
Feb 11 10:27:40 Zoneminder zmc_m1[68624]: ERR [Can't shmget, probably not enough shared memory space free: Function not implemented]
Feb 11 10:27:40 Zoneminder zmdc[68536]: ERR ['zmc -m 1' exited abnormally, exit status 255]
Feb 11 10:27:40 Zoneminder zmdc[68536]: ERR ['zmfilter.pl ' exited abnormally, exit status 9]
 

SinDeus

Explorer
Joined
Sep 3, 2013
Messages
65
Well, you could try to actually increase your kern.ipc.shmmax.
According to this wiki page and this one, the correct formula for this value is:
Code:
ring buffer size * image width * image height * 3 (for 24 bit images) + a bit of overhead

The ring buffer is the storage space where the last ‘n’ images are kept, ready to be resurrected on an alarm or just kept waiting to be analysed (see the documentation).
Perhaps a greater value will help fix your issue.
 

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
Guys,

I am a bsd/unix noob and setting this up was a nightmare. I haven't got my cameras connected yet so I don't even know if this is fully working, but at least I got the zoneminder console working.

The problem, as mentioned earlier, is that this guide is not up-to-date for version 9.3 of freenas.

There are several packages required that aren't installed by default.

First off, I don't use the ports, I used pkgng and installed all packages using "pkg install <pkgname>" command. It actually makes things easier, though again, certain additional packages are required.

I couldn't even start apache b/c it was missing dependencies. So after I install all of standard packages in the guide, I ran
Code:
pkg upgrade


That seemed to update all of the dependencies needed to start my apache server.

THEN, I had a problem importing the zm_create.sql file. It was located in /usr/local/share/doc/zoneminder/zm_create.sql.

I was getting errors related to the sql syntax. Didn't write them down, but I edited the file and kept trying to fix them but I'm not skilled enough to solve all the errors that kept popping up.

Out of frustration, I went online and searched for an alternative zm_create.sql. I found one, but got different errors. The errors with that file were easier to solve, and I FINALLY got it to load.
I attached the file, just c/p it into a .sql file and place in your zm jail.

So that was all enough to actually see the zoneminder console from the <jailip>/zoneminder address. But zoneminder wasn't started :(

Tried to start zoneminder from inside the jail and got missing pkg errors.

Here are additional packages I needed in addition to what is shown in the guide:
Code:
p5-DBI
p5-DBD-mysql
p5-libwww



Lastly, I got a really annoying error trying to start zoneminder service, with an error stating column 'Pid' in 'Logs' is out of range. Googled it and found a russian site with a solution
http://www.tune-it.ru/en/web/pakhom/home/-/blogs/zoneminder-out-of-range-value-for-column-pid-;jsessionid=e2ffb9dbaa97940d4b583d6f194f?p_p_auth=sPZs0zGG&_33_redirect=http://www.tune-it.ru/en/web/pakhom/home;jsessionid=e2ffb9dbaa97940d4b583d6f194f?p_p_auth=sPZs0zGG&p_p_id=33&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1

I translated that from russian to english. Looks like Pid is declared as a "smallint" with a very small range. Need to redefine it as an "int".

Steps:
show columns table in Logs

Code:
SHOW COLUMNS FROM Logs;


Pid is set to "smallint"

Change it to "int"

Code:
ALTER TABLE Logs MODIFY Pid int;


Now it has much larger range of (-2147483648 to 2147483647)

After all of that, I FINALLY got the zm console to show "running". PHEW. If I run into further issues, I will post them here. If someone wants something more detailed, I made a wiki to keep track of what I did to get this working, I can post it here (when you are a newb like me, I can't do this kind of stuff w/o keeping track of what I am doing, step-by-step).
 

Attachments

  • zm_create2.zip
    34.9 KB · Views: 274

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
one additional thing I forgot:

I had tphp errors all over the place. By default you have no php.ini after you install apache. So do this:
Code:
cd /usr/local/etc/
cp php.ini-production php.ini


Now you have a valid php.ini file. Again, this is all stuff obvious to experienced freenas/sys admins, but not to someone who does this as a side hobby.
 

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
okay guys
I ran into other issues. mysql had an issue with
STRICT_TRANS_TABLES being enabled. Didn't like NULL entries. So I had to delete that entry from /usr/local/my.cnf.

But now, I am getting the shared memory issue that another user here is experiencing. :(

I added the sysctl just as was shown in the tutorial. But nothing. Since I'm not the only one having this issue, I am hoping someone steps up and solves it, since I have a feeling this is impacting users that built this on freenas 9.3.
 

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
welp I give up.

Here is what my log says:


Feb 16 22:36:45 zoneminder zmdc[55198]: ERR ['zmfilter.pl ' exited abnormally, exit status 9]
Feb 16 22:36:45 zoneminder zmc_m1[55640]: FAT [Unable to open input rtsp://192.168.0.201:554/live due to: Inappropriate ioctl for device]
Feb 16 22:36:45 zoneminder zmdc[55198]: ERR ['zmc -m 1' exited abnormally, exit status 255]
Feb 16 22:36:53 zoneminder zmu[55646]: WAR [Shared data not initialised by capture daemon, some query functions may not be available or produce invalid results]
Feb 16 22:37:01 zoneminder zmwatch[55228]: ERR [Can't get shared memory id '7a6d0001', 1: No such file or directory]
Feb 16 22:37:04 zoneminder zmu[55677]: WAR [Shared data not initialised by capture daemon, some query functions may not be available or produce invalid results]


If anyone has any ideas, let me know. I've googled my ass off, but can't find an answer. I added the sysctls to my tunables, and enabled sysvipc for the jail.

when i run sysctl -a | grep 'sysvipc' I get
Code:
security.jail.param.allow.sysvipc: 0
security.jail.sysvipc_allowed: 1


That is what I want, right? I don't know, I've spent almost all day on this and I need to take a break. Any help or tips are appreciated.
 

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
nobody responded to me, so I doubt anyone cares. But I will say anyway.

I gave up on zoneminder and just made a virtualbox jail, installed windows server 2008, and put blue iris on there. I always felt that zoneminder was a compromise to the more robust solutions like blue iris, but now I have everything I need. The process of setting up the jail, installing server 2008, and initially setting it up with blue iris was maybe 1 hour, at most. It worked right away without any hassle. It's somewhat resource heavy, but my 32GB xeon server is more than up to the task.

If you care about having video surveillance software I highly recommend going the virtualbox route. You avoid the hassle of dealing with outdated software revisions that were ported over from other OSes. Perhaps someone will eventually develop a zoneminder pbi and avoid all this hassle.
 

ericv

Explorer
Joined
Mar 21, 2015
Messages
56
nobody responded to me, so I doubt anyone cares. But I will say anyway.

I gave up on zoneminder and just made a virtualbox jail, installed windows server 2008, and put blue iris on there. I always felt that zoneminder was a compromise to the more robust solutions like blue iris, but now I have everything I need. The process of setting up the jail, installing server 2008, and initially setting it up with blue iris was maybe 1 hour, at most. It worked right away without any hassle. It's somewhat resource heavy, but my 32GB xeon server is more than up to the task.

If you care about having video surveillance software I highly recommend going the virtualbox route. You avoid the hassle of dealing with outdated software revisions that were ported over from other OSes. Perhaps someone will eventually develop a zoneminder pbi and avoid all this hassle.

I care. I don't believe I can help you but could probably benefit from some of your wisdom. I just posted this thread a few minutes ago. Recommendation: Install Zoneminder on FreeNAS in Jail or Separate Box

What about installing I guess I could also install virtualbox and install Ubuntu or just go the route you did.
 

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
Nice, glad I could help someone. I really see no major disadvantage to using Virtualbox VMs, other than the extra bit of work to mount storage, and to automate shutdown/startup. (and perhaps resource issues, tho if you built a proper freenas box this also shouldn't be an issue)

So once you get your vbox setup going, I recommend setting up autostart/shutdown in your rc.conf file so that your VM images are handled gracefully in the event you need to reboot the host.
https://forums.freenas.org/index.ph...-virtualbox-vms-on-freenas.26503/#post-189007

Once you do that, you really aren't losing any functionality over a standard freenas jail. I did the same thing when I tried to install freepbx on my freenas box. Gave up after a day of dealing with incompatibilities with my bsd jail, and ended up mounting the asterisknow iso on a fresh VM inside virtualbox. I was fully up and running within minutes.
 

Hisma

Explorer
Joined
Mar 23, 2013
Messages
87
And yes, I would go with blue iris over zoneminder.

blue iris has a really solid phone app, can automatically detect & set up your cams, easily pushes notifications to e-mail/phone/etc, and is just an overall polished product. Zoneminder is open source, so while its free, its going to be more painful get it all set up the way you want it. To me the only downside is that its windows only, and it is also fairly resource heavy. But with your system (i can see it in your signature), you'll have no issues whatsoever.

You can get find blue iris for around $30 on ebay.
 
Status
Not open for further replies.
Top