Short script to monitor and restart your MMM-RTSPStreams
Here is a super short Python script that checks the status of your streams using pm2, then if it detects a stream is down, it restarts the streams. Not elegant, but it works.
import os if "stopped" in os.popen("pm2 status | grep \"stopped\"").read(): os.popen("pm2 start 1 2 3 4")
I saved it as streamMonitor.py in my home directory. I run it once per minute using crontab. This is the entry I put in:
* * * * * python3 ~/streamMonitor.py
Here is the script in action:
And here is the crontab job:
neat. Sadly, OMX had so much trouble getting the streams running, I had to switch to FFMPeg.
If VLC would boot correctly under node (it won’t), I’d use that, but between syntax errors in the code and node.js not allowing VLC to run correctly, I can’t get it to work.