zma @ 100% per zone

Forum for questions and support relating to the 1.27.x releases only.
Locked
dkasak
Posts: 5
Joined: Fri Jun 20, 2014 12:05 am

zma @ 100% per zone

Post by dkasak »

Hi all.

I've just installed Zoneminder with a single Wanscam JW0011 IP camera ( I have another one to install, but I'm getting things stable first ). I basically have things configured properly, I think, but I have 1 major issue: zma rises to 100% CPU after a couple of minutes of operation.

My setup:

- quad-core AMD A8-5600K APU
- 16GB RAM
- 1 IP camera capturing @ 640x480, 24bit colour
- 3 zones, all at 'best, high sensitivity'

When I restart ( systemctl restart zoneminder ), I get 3 zma processes ( 1 per zone, I assume ), and they each consume between 2% to 5% of CPU resources. Then after a couple of minutes, they rise to 100%.

I've tried setting all zones to 'fast, low sensitivity', and this has no effect. Anyway, I doubt whether my system is insufficient for running 3 zones with max settings. I assume something is crashing or otherwise getting confused. Interestingly, motion detection and recording appears to continue as best it can ... but I get a lot of 'buffer overrun' errors. I currently have my buffer set to 100 frames.

Lastly, when I inspect the log, when things have gone haywire, I see:

Code: Select all

2014-06-22 10:56:22.339234	zma_m1	16046	INF	Monitor-1: 96000 - Processing at 250.00 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:21.662783	zma_m1	16010	INF	Monitor-1: 94000 - Processing at 333.33 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:21.575049	zma_m1	16052	INF	Monitor-1: 100000 - Processing at 333.33 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:20.583221	zmc_m1	16000	WAR	Buffer overrun at index 96, image 3196, slow down capture, speed up analysis or increase ring buffer size	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	2803
2014-06-22 10:56:20.440441	zmc_m1	16040	INF	Monitor-1: 3000 - Capturing at 9.62 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	2831
2014-06-22 10:56:19.987130	zma_m1	16046	WAR	Approaching buffer overrun, consider slowing capture, simplifying analysis or increasing ring buffer size	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1181
2014-06-22 10:56:19.134314	zma_m1	16010	WAR	Approaching buffer overrun, consider slowing capture, simplifying analysis or increasing ring buffer size	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1181
2014-06-22 10:56:18.567074	zma_m1	16046	INF	Monitor-1: 95000 - Processing at 333.33 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:18.160087	zma_m1	16052	INF	Monitor-1: 99000 - Processing at 333.33 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:18.110081	zma_m1	16010	INF	Monitor-1: 93000 - Processing at 250.00 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:15.322121	zma_m1	16046	INF	Monitor-1: 94000 - Processing at 250.00 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:15.096618	zma_m1	16052	INF	Monitor-1: 98000 - Processing at 250.00 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:14.771415	zma_m1	16010	INF	Monitor-1: 92000 - Processing at 250.00 fps	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1153
2014-06-22 10:56:14.557607	zma_m1	16052	WAR	Approaching buffer overrun, consider slowing capture, simplifying analysis or increasing ring buffer size	/var/tmp/portage/www-misc/zoneminder-1.27.0/work/ZoneMinder-1.27.0/src/zm_monitor.cpp	1181
It often claims to be processing at either 250 fps or 333.33 fps. I've set the max fps to 25.

Any ideas?
Last edited by dkasak on Tue Jun 24, 2014 10:39 pm, edited 2 times in total.
hesral
Posts: 44
Joined: Sun Apr 06, 2014 12:11 pm

Re: zma @ 100% per zone

Post by hesral »

What type of source do you use? remote or ffmpeg?

What happens to the ram while the cpu is running at full, and you are getting those buffer overrun errors?

My best guess:
I would think, that if you use a jpeg source on a remote source, and don't set fps in zoneminder, then zoneminder will try to get a new image as fast as possible. It has no way of knowing if a new frame is ready or not, even if the camera is set to use a framerate of 25fps. Have you set the Maximum frame rate options in monitor setup to something sensible? If you are using "remote" source, and the address is just to jpg image, try setting the Maximum frame rate options in monitor setup to 1, and see if you get the same behavior.
dkasak
Posts: 5
Joined: Fri Jun 20, 2014 12:05 am

Re: zma @ 100% per zone

Post by dkasak »

Thanks for the reply. Yes I forgot to mention - it was set to 25 fps by default. I set it to 10 fps. This has no effect at all.

It's a remote ( IP ) camera. I'm using the URL on the camera that hands out single-frame jpegs.

Also, memory usage remains constant:

Code: Select all

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                        
23883 apache    20   0  390776 106776  94396 R  96.2  0.8 308:56.52 zma                                                                                                                                            
29890 apache    20   0  390776 108816  94380 R  94.8  0.8   1:54.49 zma                                                                                                                                            
25167 apache    20   0  391076 107080  94396 R  84.9  0.8 243:34.30 zma                                                                                                                                            
11868 qemu      20   0 5386876 1.076g   5324 R   9.3  7.9   1220:10 qemu-system-x86
That's from the couple of hours since my last post. Actually it seems one process either wasn't at 100%, or was recently spawned :) Probably the latter.

I've also noticed that, with the default full-image zone, I don't get this behaviour. Perhaps the issue is with the splitting of the image into zones? I have 1 zone with 4 sides, 1 with 5, and 1 with 6. I'll experiment some more ...
dkasak
Posts: 5
Joined: Fri Jun 20, 2014 12:05 am

[SOLVED] Re: zma @ 100% per zone

Post by dkasak »

OK I have a theory about what was happening, though I haven't made any effort to test it yet.

/var/lib/zoneminder had 16GB worth of images, because when I originally set up zoneminder, I selected 'morecord', thinking this would mean 'record only when there is motion' ( and there was certainly no in-app documentation to suggest otherwise ).

I decided to remove the 'monitor' and start afresh, and this deleted all the images from /var/lib/zoneminder ( thank God ... it was taking forever to delete them from the events log ). Once this folder was cleaned up, my CPU usage dropped back down to around 10% per zone.

Perhaps there is an issue at the filesystem level, when there are a lot of files in a directory??? I'm using btrfs. When I get some time, I'll do some more testing of this hypothesis, and if I'm correct, I'll hassle btrfs people.
mikb
Posts: 661
Joined: Mon Mar 25, 2013 12:34 pm

Re: [SOLVED] Re: zma @ 100% per zone

Post by mikb »

dkasak wrote:when I originally set up zoneminder, I selected 'morecord', thinking this would mean 'record only when there is motion'
I guess you now know that 'record only when there is motion' is spelled m-o-d-e-c-t :)

morecord (mocord?) is record always, motion or not, but split the motion-bits from the non-motion-bits. That's going to be a LOT of JPGs to pick through.
dkasak
Posts: 5
Joined: Fri Jun 20, 2014 12:05 am

Re: zma @ 100% per zone

Post by dkasak »

Unfortunately, the issue is back. I've used the event log thing to delete all events, restarted everything, and now I get 2 zma processes obviously doing something wrong :(

Code: Select all

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                        
 7058 apache    20   0  480588 196604 184408 R  77.7  1.4  23:25.82 zma                                                                                                                                            
 7052 apache    20   0  480588 196600 184408 R  73.0  1.4  23:46.66 zma                                                                                                                                            
11868 qemu      20   0 5468804 1.141g   5268 S  12.3  8.4   1810:10 qemu-system-x86                                                                                                                                
 5021 apache    20   0  480424 192008 184392 S   5.0  1.3   2:06.06 zmc                                                                                                                                            
 5186 apache    20   0  480576 192276 184408 R   4.3  1.4   2:05.59 zmc                                                                                                                                            
 7680 dkasak    20   0 1059664 114148  40632 S   3.0  0.8   0:19.06 chrome
I'm also getting buffer overruns and other random errors. I'm guessing this isn't going to work for me until this is stabilised.
Locked