zmu fails with 'ERR-zm_monitor.cpp/572 [Can't open memory map file...Permission denied

Forum for questions and support relating to 1.35.x development only.
Post Reply
jimw
Posts: 2
Joined: Thu Dec 31, 2020 3:15 am

zmu fails with 'ERR-zm_monitor.cpp/572 [Can't open memory map file...Permission denied

Post by jimw » Thu Dec 31, 2020 4:31 am

Hi!

I've run ZM (don't know version) for past two years with 3 cameras with no problems. The disk on the machine (an old HP CoreI5 laptop, 4GB mem running Ubuntu 18.0.4) failed, with no backup (my fault). Did clean install of Ubuntu 20.0.4 and ZM 1.35.16 a week ago. The machine is dedicated to ZM.

Restarting from scratch, I've successfully configured the same 3 cameras, and can record videos (still images, Record mode) and can access ZM and see the cameras from a browser on my local network. I want to do 2 things: Trigger slow video recording (2FPS) on motion detect on 2 of the cameras; grab a still image from all 3 cameras every 2 minutes. Not a big load. I haven't configured motion detect yet, but expect that will be OK.

The problem is getting images every (say) 2 minutes. It looks like zmu should help. I don't remember how I had it set up before, but zmu sounds familiar. Unfortunately every time I try to run it - say as root with 'zmu -l' - it fails with a stanza of this for each camera:

Code: Select all

12/30/20 21:11:24.204474 zmu[220524].ERR-zm_monitor.cpp/572 [Can't open memory map file /dev/shm/zm.mmap.1, probably not enough space free: Permission denied]
I've tried running as root and as a normal user, and various -U users.

Some info:

Code: Select all

root@JimsHpLinux:/dev/shm# ls -l
total 239600
-rw-rw---- 1 www-data www-data  42168888 Dec 30 21:38 zm.mmap.1
-rw-rw---- 1 www-data www-data 104863288 Dec 30 00:02 zm.mmap.2
-rw-rw---- 1 www-data www-data  98309688 Dec 30 00:30 zm.mmap.3

root@JimsHpLinux:/dev/shm# lsipc -m
KEY        ID     PERMS OWNER SIZE NATTCH STATUS CTIME CPID   LPID COMMAND
0x00000000 7  rw-------   jim 512K      2 dest   Dec28 1829   1061 /snap/snap-store/
0x00000000 8  rw-------   jim 512K      2 dest   Dec28 1829   1061 /snap/snap-store/
0x00000000 11 rw-------   jim 512K      2 dest   Dec28 2832 177569 update-notifier
root@JimsHpLinux:/dev/shm# cat /proc/sys/kernel/shmmax
18446744073692774399
root@JimsHpLinux:/dev/shm# cat /proc/sys/kernel/shmall
18446744073692774399
root@JimsHpLinux:/dev/shm#
Looks like the error in zm_monitor.cpp is right after an open() on the shm file. I think the "probably not enough space free" is not relevant, but "Permission denied" is, as it comes directly from errno. In desperation, I even did chmod 777 on the shm files, but still same error.

I assume if zmu -l fails like this, no other zmu command is likely to work.

Until I set up motion detect and turn off Record mode, I have a perl script that can grab my 2-minute snapshots. But when I turn off Record mode, those still images won't be there to pick up (OK, except during triggered events).

Can anyone offer insight into what is going on with zmu, or suggest next troubleshooting steps?

Thanks!

Jim

Magic919
Posts: 409
Joined: Wed Sep 18, 2013 6:56 am

Re: zmu fails with 'ERR-zm_monitor.cpp/572 [Can't open memory map file...Permission denied

Post by Magic919 » Thu Dec 31, 2020 11:24 am

Try it as www-data user.

jimw
Posts: 2
Joined: Thu Dec 31, 2020 3:15 am

Re: zmu fails with 'ERR-zm_monitor.cpp/572 [Can't open memory map file...Permission denied

Post by jimw » Thu Dec 31, 2020 9:05 pm

Thanks. I'd tried that very reasonable sounding approach as well, but www-data isn't a real user:

Code: Select all

root@JimsHpLinux:/dev/shm# su www-data
This account is currently not available.
root@JimsHpLinux:/dev/shm# grep www-data /etc/passwd
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
And since I'd tried as root, shouldn't that have trumped any perms? But inspired to due diligence by your suggestion, I modified her profile to remove nologin, and got farther:

Code: Select all

root@JimsHpLinux:/etc# vi passwd
root@JimsHpLinux:/etc# su www-data
www-data@JimsHpLinux:/etc$ zmu -l
12/31/20 13:31:13.876115 zmu[243364].ERR-zm_logger.cpp/406 [fopen() for /var/log/zm/zmu.log, error = Permission denied]

Logging to file, but failed to open it

  Id Func State TrgState    LastImgTim RdIdx WrIdx LastEvt FrmRate
   1    2     0        0 1609443071.47    -1     6       0    0.33
   2    4     4        0 1609443058.62    11    11     202    0.01
   3    4     4        0 1609443005.70     8     8     200    0.01
www-data@JimsHpLinux:/etc$
Whoa! Of course the log failed because I wasn't root - fine. Tried to grab an image - my real goal:

Code: Select all

www-data@JimsHpLinux:/tmp$ zmu -m3 -i
12/31/20 13:48:18.153367 zmu[243897].ERR-zm_logger.cpp/406 [fopen() for /var/log/zm/zmu.log, error = Permission denied]

Logging to file, but failed to open it

www-data@JimsHpLinux:/tmp$ ls -l *3.jpg
-rw-rw-r-- 1 www-data www-data 142981 Dec 31 13:48 Monitor3.jpg
www-data@JimsHpLinux:/tmp$
It worked! This is great - I can figure out how to get what I want now. Thank you so much!

<does some more reading, returns www-data to nologin> Oh. To run zmu as www-data I tried su www-data. Shoulda just done sudo -u www-data. That works even as my normal user. And now I don't have to wonder why I needed to do an unholy hack to /etc/passwd to run an ordinary utility. :D

Thanks again. And Happy New Year!

Magic919
Posts: 409
Joined: Wed Sep 18, 2013 6:56 am

Re: zmu fails with 'ERR-zm_monitor.cpp/572 [Can't open memory map file...Permission denied

Post by Magic919 » Thu Dec 31, 2020 9:26 pm

Sounds like you have it all under control.

Paranoid
Posts: 129
Joined: Thu Feb 05, 2009 10:40 pm

Re: zmu fails with 'ERR-zm_monitor.cpp/572 [Can't open memory map file...Permission denied

Post by Paranoid » Tue Jan 19, 2021 1:08 pm

Execute the following command:

Code: Select all

sudo sysctl fs.protected_regular=0
and zmu will work. You may need to add/edit an entry in /etc/sysctl.conf or one of the files under /etc/sysctl.d/ to preserve the setting after a reboot.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest