I'm rolling out a new Zoneminder 1.27 server with a set of Ubiquiti AirCams and they're working reasonably well except for one issue - whenever one of them goes down, the server never reestablishes a connection to it unless I manually go into the Console, select the Source, and then save it. Looking at the logs, it appears that the system is trying to automatically reestablish the connection but might not be correctly detecting whether it's actually connected or not. I have the cameras set to use libvlc, which appears to be otherwise rock solid.

Came up with a quick and dirty "solution" of sorts after noticing that the very bug I posted about in here already has a small bounty attached and hasn't gone anywhere (you'll have to search for it - the forum thinks the off-site link is "spamy" even though the link went straight to the Zoneminder Bountysource page). While troubleshooting the problem, I noticed that Zoneminder automatically starts a zmc daemon for each camera (zmc -m CameraNumber), which, if it successfully connects to an IP camera, spawns additional threads to process the stream. If it isn't successful, however, the daemon just sits and doesn't spawn any threads. So, I used that behavior to my advantage and wrote a script that, when plugged into cron and set to run periodically (I went with once every five minutes - note that it takes approximately 6-10 seconds for the daemon to stop and start, so time it accordingly), would check to see if there are any zmc daemons without threads (status "S" instead of "Sl") and, if there are, restart them:

I'll be the first to admit that this won't win any coding awards - error checking is nonexistent and there's probably a cleaner way to get the data out of ps than what I went with, but it works. If somebody has a better implementation, I'll happily try it.

I'm having the same issue with one of my cameras, except the ps commands above seem to return S for most of the working ones too. So instead I'm just going to directly restart the camera in question using the start and stop commands.

EDIT: I ended up using the script as is, using pcpu == 0.0 instead of stat = S.