API monitor status

Forum for questions and support relating to the 1.29.x releases only.
Locked
User avatar
Basildane
Posts: 108
Joined: Mon Sep 16, 2013 1:09 pm

API monitor status

Post 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.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API monitor status

Post 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
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Basildane
Posts: 108
Joined: Mon Sep 16, 2013 1:09 pm

Re: API monitor status

Post by Basildane »

That is exactly what I needed, thanks!
BiloxiGeek
Posts: 271
Joined: Tue Feb 11, 2014 2:04 pm

Re: API monitor status

Post 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.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API monitor status

Post 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"
}
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Basildane
Posts: 108
Joined: Mon Sep 16, 2013 1:09 pm

Re: API monitor status - does not work

Post 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.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API monitor status

Post by asker »

That's why there is a status text - which I referred to in my post - that will change. status shows true.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Basildane
Posts: 108
Joined: Mon Sep 16, 2013 1:09 pm

Re: API monitor status

Post by Basildane »

I just explained it does not change. I have it on my screen right now.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API monitor status

Post by asker »

You explained status remains true. I am referring to statustext not status.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Basildane
Posts: 108
Joined: Mon Sep 16, 2013 1:09 pm

Re: API monitor status

Post by Basildane »

Statustext did not change at all.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API monitor status

Post 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.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Basildane
Posts: 108
Joined: Mon Sep 16, 2013 1:09 pm

Re: API monitor status

Post 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.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: API monitor status

Post 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.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Basildane
Posts: 108
Joined: Mon Sep 16, 2013 1:09 pm

Re: API monitor status

Post by Basildane »

OK thanks.

Even more useful would be to have ffmpeg and libvlc automatically recover from soft faults.
User avatar
iconnor
Posts: 2880
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: API monitor status

Post 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.
Locked