ZoneMinder 1.32.3 Freenas API Failure

Forum for questions and support relating to the 1.32.x releases only.
everettcomstock
Posts: 3
Joined: Thu Mar 28, 2019 10:11 pm

ZoneMinder 1.32.3 Freenas API Failure

Post by everettcomstock »

Hi,

I recently installed ZoneMinder using the FreeNAS-11.2-U2.1 plugin. Pretty much everything is working fine except for the ZoneMinder API. When I attempt to load the /zm/api/host/getVersion.json page as instructed in the API Validation instructions, I receive the following error:

Code: Select all

Warning (2): mkdir(): Permission denied [CORE/Cake/Log/Engine/FileLog.php, line 106]
Warning (2): mkdir() [<a href='http://php.net/function.mkdir'>function.mkdir</a>]: Permission denied [CORE/Cake/Log/Engine/FileLog.php, line 106]
Warning (2): mkdir() [<a href='http://php.net/function.mkdir'>function.mkdir</a>]: Permission denied [CORE/Cake/Log/Engine/FileLog.php, line 106]
Warning (2): ini_set() [<a href='http://php.net/function.ini-set'>function.ini-set</a>]: Headers already sent. You cannot change the session module's ini settings at this time [CORE/Cake/Model/Datasource/CakeSession.php, line 581]
Warning (2): mkdir() [<a href='http://php.net/function.mkdir'>function.mkdir</a>]: Permission denied [CORE/Cake/Log/Engine/FileLog.php, line 106]
Warning (2): mkdir() [<a href='http://php.net/function.mkdir'>function.mkdir</a>]: Permission denied [CORE/Cake/Log/Engine/FileLog.php, line 106]
Warning (2): file_put_contents(/var/log/zm/cake_error.log) [<a href='http://php.net/function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: No such file or directory [CORE/Cake/Log/Engine/FileLog.php, line 142]
Warning (2): mkdir() [<a href='http://php.net/function.mkdir'>function.mkdir</a>]: Permission denied [CORE/Cake/Log/Engine/FileLog.php, line 106]
Warning (2): file_put_contents(/var/log/zm/error.log) [<a href='http://php.net/function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: No such file or directory [CORE/Cake/Log/Engine/FileLog.php, line 142]
Warning (2): ini_set() [<a href='http://php.net/function.ini-set'>function.ini-set</a>]: Headers already sent. You cannot change the session module's ini settings at this time [CORE/Cake/Model/Datasource/CakeSession.php, line 581]{ "success": false, "data": { "code": 500, "name": "Unable to configure the session, setting session.use_trans_sid failed.", "message": "Unable to configure the session, setting session.use_trans_sid failed.", "url": "\/zm\/api\/host\/getVersion.json?p=%2Fhost%2FgetVersion.json", "exception": { "class": "CakeSessionException", "code": 500, "message": "Unable to configure the session, setting session.use_trans_sid failed.", "trace": [ "#0 \/usr\/local\/www\/zoneminder\/api\/lib\/Cake\/Model\/Datasource\/CakeSession.php(619): CakeSession::_configureSession()", "#1 \/usr\/local\/www\/zoneminder\/api\/lib\/Cake\/Model\/Datasource\/CakeSession.php(632): CakeSession::_cookieName()", "#2 \/usr\/local\/www\/zoneminder\/api\/lib\/Cake\/Model\/Datasource\/CakeSession.php(404): CakeSession::_hasSession()", "#3 \/usr\/local\/www\/zoneminder\/api\/lib\/Cake\/Controller\/Component\/SessionComponent.php(69): CakeSession::read('user')", "#4 \/usr\/local\/www\/zoneminder\/api\/app\/Controller\/AppController.php(70): SessionComponent->read('user')", "#5 \/usr\/local\/www\/zoneminder\/api\/lib\/Cake\/Event\/CakeEventManager.php(243): AppController->beforeFilter(Object(CakeEvent))", "#6 \/usr\/local\/www\/zoneminder\/api\/lib\/Cake\/Controller\/Controller.php(677): CakeEventManager->dispatch(Object(CakeEvent))", "#7 \/usr\/local\/www\/zoneminder\/api\/lib\/Cake\/Routing\/Dispatcher.php(189): Controller->startupProcess()", "#8 \/usr\/local\/www\/zoneminder\/api\/lib\/Cake\/Routing\/Dispatcher.php(167): Dispatcher->_invoke(Object(HostController), Object(CakeRequest))", "#9 \/usr\/local\/www\/zoneminder\/api\/app\/webroot\/index.php(107): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))", "#10 {main}" ] }, "queryLog": [] } }
Can anyone suggest a starting point for troubleshooting?

Thanks,
Everett
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by knight-of-ni »

The messages you posted are just warnings. They are not fatal, so that might not be the root cause of the API not working.

In any case, from what you posted, verify the files and folders mentioned in the message:
- /var/log/zm exists
- /var/log/zm is owned by the web account user
- /var/log/zm/cake_error.log exists
- /var/log/zm/cake_error.log is owned by the web account user
- /var/log/zm/error.log exists
- /var/log/zm/error.log is owned by the web account user

Once you establish that, if the API still does not work, check to see what it wrote to error.log and/or cake_error.log, and that will likely be what the real problem is.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
everettcomstock
Posts: 3
Joined: Thu Mar 28, 2019 10:11 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by everettcomstock »

Knight, thanks for your reply.

I attempted to check the log files but realized those folders do not exist. I'm not great with FreeBSD, and I'm not sure if the directory structure is the same as Linux. I checked the root/var/log directory and there is no zm directory, and no log files that look as if they are related to zoneminder. I also checked the root/usr/local/var directory, but there is no logs directory, and no zm folder or logs.

This may just be a FreeBSD vs. Linux issue, and I may just be looking in the wrong location, or maybe the "www" account in my FreeBSD jail does not have the correct permissions to create the logs.

I'm going to continue my research. If you have any additional suggestions, I'll take all the help I can get.

Thanks!
Everett
everettcomstock
Posts: 3
Joined: Thu Mar 28, 2019 10:11 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by everettcomstock »

Knight,

I just wanted to follow up. My issues turned out to be related to incomplete configuration. I had not configured a server on the servers page, and I believe my HTTPS / Reverse Proxy configuration was confusing a few parts of the app.

However, as soon as I created a server entry, the API started working (and an issue with events not showing on the monitor view was also resolved).

Thank you very much for your help!
Everett
tsr966
Posts: 1
Joined: Tue Dec 10, 2019 4:17 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by tsr966 »

How did you set up the server info to get the API to work?
oizo
Posts: 1
Joined: Fri Feb 14, 2020 9:11 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by oizo »

Hi,

just wanted to leave som input. In my case, I tried using ZMninja from iOS and Mac OS. The APIs were not working.

I read what knight-of-ni posted and the /var/log/zm directory was missing. I created the directory and changed ownership to www:www, with

Code: Select all

chown -R www:www /var/log/zm
and restarted Zoneminder, now everything works relating to ZMNinja.

I get a strange URL-rewrite error when checking out http://<myserver>/zm/api. I don't mind as long as everything else works =)
inis
Posts: 4
Joined: Sun Mar 04, 2018 10:47 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by inis »

oizo wrote: Fri Feb 14, 2020 9:17 pm Hi,

just wanted to leave som input. In my case, I tried using ZMninja from iOS and Mac OS. The APIs were not working.

I read what knight-of-ni posted and the /var/log/zm directory was missing. I created the directory and changed ownership to www:www, with

Code: Select all

chown -R www:www /var/log/zm
and restarted Zoneminder, now everything works relating to ZMNinja.

I get a strange URL-rewrite error when checking out http://<myserver>/zm/api. I don't mind as long as everything else works =)
I'm getting the same error, did the directory for zm and changed ownership. Still not getting zmninja to work.
Did you get any further with the URL-rewrite error?
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by rockedge »

the url http://<myserver>/zm/api for checking the API function is not correct and will not work.

In a browser login to ZM open another tab and enter the url

Code: Select all

http://<myserver>/zm/api/host/getVersion.json
you should see the API and ZM version as a reponse
bignellrp
Posts: 19
Joined: Sun Dec 22, 2019 12:37 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by bignellrp »

Im having similar issues but zmninja closed my forum post saying this was a zoneminder issue due to it running in a jail.

Ive moved to a new NAS. I used to have Ubuntu with ZM 1.34 and the API worked fine. Now in ZMNinja the API fails.

It says ZMController.php not found but ZmController.php doesnt exist and didnt exist in the working config either.

I found a similar post here: https://github.com/pliablepixels/zmNinja/issues/300

Here is the output from the page

CakePHP: the rapid development php framework
Missing Controller
Error: ZmController could not be found.

Error: Create the class ZmController below in file: app/Controller/ZmController.php

<?php
class ZmController extends AppController {

}
Notice: If you want to customize this error message, create app/View/Errors/missing_controller.ctp

Stack Trace
APP/webroot/index.php line 107 → Dispatcher->dispatch(CakeRequest, CakeResponse)
CakePHP: the rapid development php framework
CakePHP 2.10.8



root@zoneminder:/usr/local/www/zoneminder/api/app/Controller # ls -la
total 129
drwxr-xr-x 3 www www 19 Mar 11 13:26 .
drwxr-xr-x 11 www www 12 Mar 13 11:44 ..
-rw-r--r-- 1 www www 3694 Dec 8 2018 AppController.php
drwxr-xr-x 2 www www 6 Mar 11 13:26 Component
-rw-r--r-- 1 www www 3270 Dec 8 2018 ConfigsController.php
-rw-r--r-- 1 www www 1353 Dec 8 2018 ControlsController.php
-rw-r--r-- 1 www www 12162 Dec 8 2018 EventsController.php
-rw-r--r-- 1 www www 2516 Dec 8 2018 FramesController.php
-rw-r--r-- 1 www www 3472 Dec 8 2018 GroupsController.php
-rw-r--r-- 1 www www 5584 Dec 8 2018 HostController.php
-rw-r--r-- 1 www www 2383 Dec 8 2018 LogsController.php
-rw-r--r-- 1 www www 11289 Dec 8 2018 MonitorsController.php
-rw-r--r-- 1 www www 2123 Dec 8 2018 PagesController.php
-rw-r--r-- 1 www www 3697 Dec 8 2018 ServersController.php
-rw-r--r-- 1 www www 3646 Dec 8 2018 StatesController.php
-rw-r--r-- 1 www www 3776 Dec 8 2018 StorageController.php
-rw-r--r-- 1 www www 3777 Dec 8 2018 UsersController.php
-rw-r--r-- 1 www www 2654 Dec 8 2018 ZonePresetsController.php
-rw-r--r-- 1 www www 4608 Dec 8 2018 ZonesController.php


Im running 1.32.3 in a Freenas 11.3 jail built as a plugin.

Everything else works just no API.

I followed the other suggestions in this post and fixed the errors regarding the logs and disabled the rewrites but still get the error above about the controller php.

Any ideas welcome.
bignellrp
Posts: 19
Joined: Sun Dec 22, 2019 12:37 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by bignellrp »

Can anyone help here please? Im currently stuck without ZMNinja working at all.
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by Bluemax »

There is not much one can do on a custom build like yours from outside. I would recommend to contact the maintainer of the freenas package.

As a wild guess, i would say your rewrite is necessary and shouldn't be removed (but fixed instead). I have an explicit entry as well (nginx):

Code: Select all

location /zm/api/ {
	rewrite	^/zm/api(.+)$ /zm/api/app/webroot/index.php last;
	}
But it all depends on your individual folder structure and how things are set up.

And again, this is just a wild guess.
bignellrp
Posts: 19
Joined: Sun Dec 22, 2019 12:37 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by bignellrp »

Thanks. I tried your rewrite instead of mine and it didnt make a difference. Still getting the same error about a missing php file.

Is it not strange its looking in /zm/api/app..... shouldnt it be /usr/local/www/zm/api/app......

I've raised it with the package maintainer of the plugins on github

https://github.com/freenas/iocage-ix-plugins

Im also attempting a portupgrade in the jail although i forsee this breaking it more based on my limited freebsd knowledge

e.g.

portsnap fetch
portsnap extract
cd /usr/ports/lang/perl5.30/ && make reinstall # to upgrade to 5.30.2
cd /usr/ports/ports-mgmt/portupgrade
make install clean
portupgrade -R zoneminder # press enter 50 million times
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by Bluemax »

bignellrp wrote: Fri Mar 20, 2020 8:35 pm Is it not strange its looking in /zm/api/app..... shouldnt it be /usr/local/www/zm/api/app......
'/usr/local/www' is the base/root folder of the webserver. It should be defined somewhere. You work relative to that.
Also note that my rewrite is an nginx command. Most ZM installs use Apache i guess. But its a wild guess nevertheless. I'm not sure if that's really related to your bug at all.
bignellrp
Posts: 19
Joined: Sun Dec 22, 2019 12:37 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by bignellrp »

Im sure you are on the right lines Bluemax.

I finished the upgrade to 1.34.6 and the error has now changed to

Error: The requested address '/zm/api/' was not found on this server.

Im certain the nginx rewrite is just not rewriting. Maybe its not built with rewrite enabled?

If i look in my ngnix error.log i see the following:

2020/03/21 21:04:09 [error] 34948#101801: *2 open() "/usr/local/www/zoneminder/api/img/cake.power.gif" failed (2: No such file or directory), client: 192.168.0.23, server: _, request: "GET /zm/api/img/cake.power.gif HTTP/1.1", host: "192.168.x.xx", referrer: "http://192.168.x.xx/zm/api/"

So i checked the conf

vi /usr/local/etc/nginx/conf.d/zoneminder.conf

location /zm/api {
rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php last;

What else can i check?
bignellrp
Posts: 19
Joined: Sun Dec 22, 2019 12:37 pm

Re: ZoneMinder 1.32.3 Freenas API Failure

Post by bignellrp »

Ps this page discusses rewrite but i tried their config and its the same.

https://forums.freebsd.org/threads/maki ... 585/page-2
Post Reply