stevepedwards.com/DebianAdmin linux mint IT admin tips info

Mint 17.2 Zoneminder Nightmares

The zoneminder.com docs for Debian3 !! are 2005 so useless. Look at the site for an overview though. I couldn't find what I wanted so researched/tried to get on myself - bad idea...? Probably. I just could not find a simple, straightforward How To anywhere...don't look here for that either! But you will have a good understanding of ZM after if you follow this...good luck with that.

-------------------------------------------------------------------------------------------------

Days later....Try this one:

http://www.linuxuser.co.uk/tutorials/zoneminder-cctv-tutorial

Use my info for v4l to find camera specs, not the zm line in that how to, as it just says:

zmu -d /dev/video0 -q -v

Error, failed to enumerate standard 0: Success

for EVERY camera I tried with it ( 2x Picams and 5 webcams - the Optia WORKS in Mint ZM too -  so this cmd tells you nothing, yet the PiCams (Noir particularly, InfraRed) is VERY capable for many formats, and this is a Creative Optia specs.

root@PiBlanc:~# v4l2-ctl -d /dev/video1 --list-formats
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'MJPG' (compressed)
Name : MJPEG

Index : 1
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUV 4:2:2 (YUYV)

----------------------------------------------------------------------------------------------

I got Zoneminder working on a Mint PC with an Optia webcam at work, after 2 days solid research and messing about with settings and permissions - a trial and error, lap of the gods nightmare. First I'll recap, document and try to remember all I did on the work PC, then try to fix the 3 home PCs I have, using the same camera. Hopefully some procedural consistency will emerge to find the final steps that gets ZM working.

A REAL shame all this, as it is great once running, but you do NOT want to have to reboot and go through all this each time! What a farce! Why ZM does not set all its required directory perms at install I don't know... unless Mint is different for it - someone needs to get fixing things that's for sure.

I just hope its Raspian Implementation works after buying another 2 Pis for work and home surveillance experiments.

That's the next Post - Pi and ZM as a complete new install.

------------------------------------------------------------------------------------------------------------------------

Forum Info

1) Keep the default zone apache.conf without the ScriptAlias.

2) Stop both zoneminder and apache2

sudo service apache2 stop

sudo service zoneminder stop

2) Remove any stale sockets from /tmp/zm (default location):

sudo rm -vf /tmp/zm/*.*

3) sudo a2enmod cgi

4) Start zoneminder

sudo service zoneminder start

5) Start apache2

sudo service apache2 start

I found out that the order was important for step 4 and 5, otherwise it doesn't work.

------------------------------------------------------------------------------------------------------------------------

First, as a recap from Dellmint with that Creative Optia webcam, and the forum info above, I'll try and fix ZM on Dellmint:

DellMint stevee # service zoneminder stop

Stopping ZoneMinder: success

DellMint stevee # service apache2 stop

* Stopping web server apache2

Note that /tmp belongs to root, so ZM can't write sockets there yet, and there are no stale ones.

ls -als /tmp/zm/

total 16

4 drwx------ 2 www-data www-data 4096 Aug 7 20:06 .

12 drwxrwxrwt 11 root root 12288 Aug 7 20:09 ..

a2enmod cgi

Enabling module cgi.

To activate the new configuration, you need to run:

service apache2 restart

The default ZM directory from its conf file in:

vi /etc/zm/zm.conf

# Path to installed data directory, used mostly for finding DB upgrade scripts

ZM_PATH_DATA=/usr/share/zoneminder

has to be added to the apache2 sites file:

vi /etc/apache2/sites-enabled/000-default.conf

ServerAdmin webmaster@localhost

DocumentRoot /usr/share/zoneminder/

Now you need to try to get the ZM localhost browser page again, by following the forum tip starting order above:

4) Start zoneminder

sudo service zoneminder start

5) Start apache2

sudo service apache2 start

I found out that the order was important for step 4 and 5, otherwise it doesn't work.

DellMint stevee # service zoneminder start

Starting ZoneMinder: success

DellMint stevee # service apache2 start

* Starting web server apache2

Check Dellmint remotely in the browser:

Console Success!

Now check the Webcam setup and that it streams. A major tip here is use the log window top right when you make changes - it's very comprehensive and you should get clues like perms access failures etc. if you don't get a webcam picture. I have at least the luxury of knowing the defaults palette works with this webcam after all day at work trying, so anything else should be group additions and perms issues.

Open the log window - not good:

First main problem is the perms for /dev/video0:

DellMint stevee # ls -als /dev/video0

0 crw-rw----+ 1 root video 81, 0 Aug 7 19:48 /dev/video0

What sort of linux filesystem device begins with a "c"??? Hmm..later.

You see that /dev/video0 belongs to root and the video group, so the zm binary needs to be added to that group. Also, it may help to add any required users to the video group also.

I found it easier to type it straight in to the group file - the clue was that the motion binary was already there:

vi /etc/group

video:x:44:motion,zm,stevee

www-data:x:33:stevee

Look at the ZM log again, refresh it and see if that fault has gone - yep 10 mins ago since last.

So what complaints are left? Ah, the sockets problem mentioned earlier:

getStreamCmdResponse stream error: socket_sendto( /tmp/zm/zms-822130s.sock ) failed: No such file or directory - checkStreamForErrors()

I'm going to mark and delete the Monitor1 instance before checking the /tmp/zm perms and going through the stale sockets routine again:

DellMint stevee # ls -als /tmp/zm/

total 20

4 drwx------ 3 www-data www-data 4096 Aug 7 20:36 .

12 drwxrwxrwt 11 root root 12288 Aug 7 20:39 ..

0 srwxr-xr-x 1 www-data www-data 0 Aug 7 20:17 zmdc.sock

4 drwxr-xr-x 2 www-data www-data 4096 Aug 7 20:36 zmswap-m1

The sockets and dir are owned by www-data user and group, so let's make it's group video for zm access:

DellMint stevee # chgrp video -R /tmp/zm/

Going through the forum stale sockets and restart procedure again:

1) Keep the default zone apache.conf without the ScriptAlias.

2) Stop both zoneminder and apache2

sudo service apache2 stop

sudo service zoneminder stop

2) Remove any stale sockets from /tmp/zm (default location):

sudo rm -vf /tmp/zm/*.*

3) sudo a2enmod cgi

4) Start zoneminder

sudo service zoneminder start

5) Start apache2

sudo service apache2 start

I found out that the order was important for step 4 and 5, otherwise it doesn't work.

Oops, I didn't check the ScriptAlias part before - but I didn't change that earlier today either and it worked, so I don't think its relevant, and the /zm is the same alias as

DocumentRoot /usr/share/zoneminder/

in the apache2 sites conf - best to comment out anyway from the forum list at this point:

vi /etc/zm/apache.conf

#Alias /zm /usr/share/zoneminder

<Directory /usr/share/zoneminder>

php_flag register_globals off

Options Indexes FollowSymLinks

<IfModule mod_dir.c>

DirectoryIndex index.php

</IfModule>

</Directory>

Remove the old sockets:

DellMint stevee # service apache2 stop

DellMint stevee # service zoneminder stop

DellMint stevee # rm -vr /tmp/zm/*

removed /tmp/zm/zmdc.sock

removed directory: /tmp/zm/zmswap-m1

DellMint stevee # ls -als /tmp/zm/

total 16

4 drwx------ 2 www-data video 4096 Aug 7 20:58 .

12 drwxrwxrwt 11 root root 12288 Aug 7 20:58 ..

DellMint stevee # a2enmod cgi

Module cgi already enabled

DellMint stevee # service zoneminder start

Starting ZoneMinder: success

DellMint stevee # service apache2 start

* Starting web server apache2

DellMint stevee # ls -als /tmp/zm/

total 16

4 drwx------ 2 www-data video 4096 Aug 7 21:03 .

12 drwxrwxrwt 11 root root 12288 Aug 7 21:03 ..

0 srwxr-xr-x 1 www-data www-data 0 Aug 7 21:03 zmdc.sock

That socket still belongs to www-data group! I changed that to video earlier!?

The log is waiting to go, so add a new Monitor:


 


 


I had lost the plot by the 3rd PC and 6 hrs later, as to what the critical step was I did of those above and below...

238 rm -vr /tmp/zm/zmdc.sock

239 ls -las /tmp/zm/

240 a2enmod cgi

241 service zoneminder stop

242 service apache2 stop

243 service zoneminder start

244 lsusb

245 service apache2 start

246 apt-get install v4l-utils

247 vi /etc/group

248 service apache2 stop

249 service zoneminder stop

250 service zoneminder start

251 service apache2 start

252 mysql -u root -p

253 service zoneminder restart

254 service apache2 stop

255 service zoneminder stop

256 vi /etc/zm/apache.conf

257 rm -vr /tmp/zm/*

258 rm -vr /dev/shm/*

259 ls -als /dev/shm/

260 service zoneminder start

261 service apache2 start

262 echo 536870912 >/proc/sys/kernel/shmmax

263 service zoneminder restart

264 ls -als /dev/shm/

265 chgrp video /dev/shm/ -R

266 ls -als /dev/shm/

267 chown www-data /dev/shm/ -R

268 ls -als /dev/shm/

269 service zoneminder restart

270 ls -als /dev/video0

271 chown www-data -R /dev/video0

272 ls -als /dev/video0

And back to the same old shit in the log!


The permissions issue is gone, but I'm going to reboot and see what happens as there is a memory map issue now:

Memory map file '/dev/shm/zm.mmap.3' should have been 896 but was instead 0

Seems there is something well broken with this install - even after an update, upgrade and reboot.

I'll use another PC. I'll whizz through again on that, if it doesn't work I must have forgotten something I did at work earlier.

MintPC stevee # lsusb

Bus 001 Device 002: ID 041e:4057 Creative Technology, Ltd Live! Cam Optia

The clues for the cgi command earlier, and other paths are shown in the options link, and there a many that you want to be familiar with for sending alerts etc:

I remembered that Mint has not got ffmpeg so avconv may need to be entered into the images tab path instead as the stream converter:

ls -als /dev/video0

0 crw-rw----+ 1 root video 81, 0 Aug 7 21:40 /dev/video0

MintPC stevee # chown www-data /dev/video0

MintPC stevee # ls -als /dev/video0

0 crw-rw----+ 1 www-data video 81, 0 Aug 7 21:40 /dev/video0

MintPC stevee # chmod 755 -R /dev/video0

MintPC stevee # ls -als /dev/video0

0 crwxr-xr-x+ 1 www-data video 81, 0 Aug 7 21:40 /dev/video0

Check for a zm DB in MYSQL:

MintPC stevee # mysql -u root -p

Enter password:

mysql> show databases ;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| zm |

+--------------------+

4 rows in set (0.06 sec)

chgrp www-data /dev/video0

Something I emailed myself from work:

MintServer stevee # chmod 755 /dev/video0

MintServer stevee # ls -als /dev/video0

0 crwxr-xr-x+ 1 root www-data 81, 0 Aug  7 14:59 /dev/video0

Checking the log again:

Memory map file '/dev/shm/zm.mmap.7' should have been 896 but was instead 0

MintPC stevee # ls -als /dev/shm/

total 11960

0 drwxrwxrwt 2 root root 140 Aug 7 22:40 .

0 drwxr-xr-x 30 root root 980 Aug 7 21:58 ..

68 -rwx------ 1 stevee stevee 67108904 Aug 7 21:45 pulse-shm-1538099436

632 -rwx------ 1 stevee stevee 67108904 Aug 7 21:46 pulse-shm-3845721138

4 -rwx------ 1 stevee stevee 67108904 Aug 7 21:46 pulse-shm-4031484825

4 -rwx------ 1 stevee stevee 67108904 Aug 7 21:45 pulse-shm-4048084406

11252 -rw------- 1 www-data www-data 11521760 Aug 7 22:40 zm.mmap.6

Why do I own those /dev pulse files completely?

MintPC stevee # chown www-data:video -R /dev/shm/*

MintPC stevee # service zoneminder stop

Stopping ZoneMinder: success

MintPC stevee # service apache2 stop

* Stopping web server apache2 *

MintPC stevee # ls -als /dev/shm/

total 708

0 drwxrwxrwt 2 root root 120 Aug 7 22:45 .

0 drwxr-xr-x 30 root root 980 Aug 7 21:58 ..

68 -rwx------ 1 www-data video 67108904 Aug 7 21:45 pulse-shm-1538099436

632 -rwx------ 1 www-data video 67108904 Aug 7 21:46 pulse-shm-3845721138

4 -rwx------ 1 www-data video 67108904 Aug 7 21:46 pulse-shm-4031484825

4 -rwx------ 1 www-data video 67108904 Aug 7 21:45 pulse-shm-4048084406

No go on that PC either - what's missing???!!!

3rd PC!!! A look at the Options;

HPMINT stevee # chown www-data -R /dev/video0

Untick the fatal condition box in the Options:

FINALLY - 6 hrs later again!!

A nice white log below, and capturing at 10 fps

8/8/15 HERE WE GO AGAIN!!

I know I'll be back to square one after a reboot, and this seems so, as permissions have reverted to default, just from looking at:

HPMINT stevee # ls -als /dev/shm/pulse-shm-*

4 -rwx------ 1 stevee stevee 67108904 Aug 8 07:47 /dev/shm/pulse-shm-2416674735

4 -rwx------ 1 stevee stevee 67108904 Aug 8 07:47 /dev/shm/pulse-shm-2671128406

712 -rwx------ 1 stevee stevee 67108904 Aug 8 07:47 /dev/shm/pulse-shm-281344266

68 -rwx------ 1 stevee stevee 67108904 Aug 8 07:47 /dev/shm/pulse-shm-929417037

I'll leave /dev/shm as is to see if ZM picks these files straight up from yesterday.

ZM is off so needs a restart - which is out of order with Apache so no doubt will be a problem.

HPMINT stevee # service zoneminder status

ZoneMinder is stopped

HPMINT stevee # service apache2 status

* apache2 is running

HPMINT stevee # a2enmod cgi

Module cgi already enabled

No stale sockets yet of course, as ZM is off and not run yet.

HPMINT stevee # ls -als /mnt/

total 8

4 drwxr-xr-x 2 root root 4096 Apr 10 2014 .

4 drwxr-xr-x 26 root root 4096 Aug 6 16:09

The perms of /dev/video0 are:

0 crw-rw----+ 1 root video 81, 0 Aug 8 07:46 /dev/video0

All I can do is stop apache, restart ZM then apache and see what happens.

If it is not working again, then go back through yesterday's history list backwards and see what step counts. Tedious.

HPMINT stevee # service zoneminder start

Starting ZoneMinder: success

HPMINT stevee # service apache2 start

* Starting web server apache2


As expected - NO VIDEO AGAIN!

238 rm -vr /tmp/zm/zmdc.sock

239 ls -las /tmp/zm/

240 a2enmod cgi

241 service zoneminder stop

242 service apache2 stop

243 service zoneminder start

244 lsusb

245 service apache2 start

246 apt-get install v4l-utils

247 vi /etc/group

248 service apache2 stop

249 service zoneminder stop

250 service zoneminder start

251 service apache2 start

252 mysql -u root -p

253 service zoneminder restart

254 service apache2 stop

255 service zoneminder stop

256 vi /etc/zm/apache.conf

257 rm -vr /tmp/zm/*

258 rm -vr /dev/shm/*

259 ls -als /dev/shm/

260 service zoneminder start

261 service apache2 start

262 echo 536870912 >/proc/sys/kernel/shmmax

263 service zoneminder restart

264 ls -als /dev/shm/

265 chgrp video /dev/shm/ -R

266 ls -als /dev/shm/

267 chown www-data /dev/shm/ -R

268 ls -als /dev/shm/

269 service zoneminder restart

270 ls -als /dev/video0

271 chown www-data -R /dev/video0

272 ls -als /dev/video0

Starting last, as root owns /dev/video0 again, let's change ownership back to www-data in the video group, make it 755 and delete all old Monitors and /dev/shm/* and create a new Monitor:

HPMINT stevee # chown www-data -R /dev/video0

HPMINT stevee # chmod 755 -R /dev/video0

HPMINT stevee # ls -als /dev/video0

0 crwxr-xr-x+ 1 www-data video 81, 0 Aug 8 07:46 /dev/video0

HPMINT stevee # rm -vr /dev/shm/*

removed â/dev/shm/pulse-shm-2416674735â

removed â/dev/shm/pulse-shm-2671128406â

removed â/dev/shm/pulse-shm-281344266â

removed â/dev/shm/pulse-shm-929417037â

removed â/dev/shm/zm.mmap.4â

HPMINT stevee # rm -vr /tmp/zm/*

removed â/tmp/zm/zmdc.sockâ

removed directory: â/tmp/zm/zmswap-m4â

This really is a joke! Next history commands:

HPMINT stevee # chown www-data /dev/shm/ -R

HPMINT stevee # chgrp video /dev/shm/ -R

HPMINT stevee # ls -als /dev/shm/

0 drwxrwxrwt 2 www-data video 40 Aug 8 08:30 .

HPMINT stevee # service zoneminder restart

Starting ZoneMinder: success

Still got the memory map problems:

Memory map file '/dev/shm/zm.mmap.7' should have been 896 but was instead 0

HPMINT stevee # echo 536870912 >/proc/sys/kernel/shmmax

Thanks to that Spanish guy on whatever forum it was! Gracias!

 

OK - a reboot has to be done again, just to see if all the other perms/ownership stuff was necessary or just that one memory map issue is the cause (can't see that myself due to perms complaints in the logs also), but if you have to go through all this each boot then ZM or Mint needs a major rewrite!

First I want to test the Android phone App by IP on the local network - ZmView. My phone did not work too well (locks up so the delete/tools don't work), but my work colleagues did. No - I have a java exception issue - Sony shit.

Rebooted, restarted ZM - no video:

HPMINT stevee # echo 536870912 >/proc/sys/kernel/shmmax

Failed to open video device /dev/video0: Permission denied    

Yep - you have to go through ALL the same shit again...!

(No - you don't - see later Posts as I learned more - 10 min ZM install))

Comments are closed.

Post Navigation