Page 1 of 1

API monitor status

Posted: Thu Mar 10, 2016 9:36 pm
by Basildane
I'm trying to find a way to see a channel is running using the api. I can see if the zoneminder service itself is up, but I specifically want to monitor individual channels so they can be restarted when they fail.

I went thought the api examples and couldn't find anything.

Re: API monitor status

Posted: Fri Mar 11, 2016 12:53 am
by asker
what do you mean by channels? Do you mean monitors? If so, use

Code: Select all

<apiBase>+"/monitors/daemonStatus/id:"+<monId>+"/daemon:zmc.json"
This returns a status text parameter that I added a few months ago that reports the running status in text

Re: API monitor status

Posted: Fri Mar 11, 2016 12:56 am
by Basildane
That is exactly what I needed, thanks!

Re: API monitor status

Posted: Fri Mar 11, 2016 12:54 pm
by BiloxiGeek
asker wrote:what do you mean by channels? Do you mean monitors? If so, use

Code: Select all

<apiBase>+"/monitors/daemonStatus/id:"+<monId>+"/daemon:zmc.json"
This returns a status text parameter that I added a few months ago that reports the running status in text
Asker.... Could you give me an example URL to use with curl to get status from let's say monitorID 5? I'm fiddling with a few things but my head just isn't getting wrapped around this one so far.

Re: API monitor status

Posted: Fri Mar 11, 2016 2:01 pm
by asker

Code: Select all

curl http://<domain>/zm/api/monitors/daemonStatus/id:5/daemon:zmc.json
Produces

Code: Select all

{
    "status": true,
    "statustext": "'zmc -m 5' running since 16\/03\/11 08:45:22, pid = 19021"
}

Re: API monitor status - does not work

Posted: Thu Mar 17, 2016 5:55 pm
by Basildane
I fully tested this today. It does not work.
I took a monitor with an IP camera, checked the status "status: true". Good so far.
Then I killed the stream. I physically disconnected the camera.
I waited a full 20 minutes. The api continued to say "status: true".

I reconnected the camera. Monitor still dead. Monitor will not recover. API continues to say nothing is wrong.

Re: API monitor status

Posted: Thu Mar 17, 2016 6:00 pm
by asker
That's why there is a status text - which I referred to in my post - that will change. status shows true.

Re: API monitor status

Posted: Thu Mar 17, 2016 6:03 pm
by Basildane
I just explained it does not change. I have it on my screen right now.

Re: API monitor status

Posted: Thu Mar 17, 2016 6:10 pm
by asker
You explained status remains true. I am referring to statustext not status.

Re: API monitor status

Posted: Thu Mar 17, 2016 6:12 pm
by Basildane
Statustext did not change at all.

Re: API monitor status

Posted: Thu Mar 17, 2016 6:30 pm
by asker
In that case you have tested hastily, not fully.

Remember that this API is reporting the status of the monitor of ZM - not your camera. Monitor of ZM == zmc process
Pay attention to the PIDs

There is no way today to know if the actual camera is down, directly via APIs. You can only know if zmc is healthy.

Running:

Code: Select all

{
    "status": true,
    "statustext": "'zmc -m 5' running since 16\/03\/17 08:50:21, pid = 11765"
}
kill -9 11765

Code: Select all

{
    "status": true,
    "statustext": "'zmc -m 5' running since 16\/03\/17 14:14:30, pid = 14100"
}
Note the PID changed above - means zmc was restarted


Change monitor 5 to None in ZM

Code: Select all

{
    "status": false,
    "statustext": "'zmc -m 5' not running"
}

Changing monitor 5 to "disabled" does not kill zmc - it still runs, so API will report it is running

Pulling out camera 6:

Code: Select all

{
    "status": true,
    "statustext": "'zmc -m 6' running since 16\/03\/17 14:24:31, pid ="
}
Note no PID above

Doing it again in a few seconds

Code: Select all

{
    "status": true,
    "statustext": "'zmc -m 6' running since 16\/03\/17 14:28:37, pid = 14648"
}
Doing it again in a few seconds:

Code: Select all

{
    "status": true,
    "statustext": "'zmc -m 6' running since 16\/03\/17 14:28:37, pid = 14678"
}
This reflects the fact that zmc keeps restarting trying to talk to the camera and keeps failing.

Re: API monitor status

Posted: Thu Mar 17, 2016 6:39 pm
by Basildane
Clearly we are talking about different requirements.
I need to know when the monitor fails. I have a Nagios server that monitors my systems.

All wifi remote monitors fail - permanently - daily. This happens to me and many other people who reported on this forum. It would be nice if there was an api function that would show the fact that a monitor was down, rather then just have no events and a grey screen for 20 hours or so until someone accidentally discovers the problem.

The PID never changed when my camera dropped connection. This is a "real world" test, unlike using kill -9 on the zmc which is not something I am trying to protect against.

I can monitor the camera itself including the rtsp stream from Nagios - but this doesn't help because the camera is not the problem. The camera comes right back up. The problem is that zoneminder never recovers and displays a blank screen until the monitor is manually restarted.

Re: API monitor status

Posted: Thu Mar 17, 2016 6:44 pm
by asker
The APIs cannot be used to detect a blank screen situation, if it does not result in zmc restart.
If ZMC restarts you will see a PID change. If not, you won't know via APIs.

Yes, it would be useful to know, but there isn't a mechanism today.

Re: API monitor status

Posted: Thu Mar 17, 2016 6:47 pm
by Basildane
OK thanks.

Even more useful would be to have ffmpeg and libvlc automatically recover from soft faults.

Re: API monitor status

Posted: Tue Mar 22, 2016 1:20 pm
by iconnor
There is definitely work to be done in zmc to report a down camera. It will be trickling in over the next few releases.