LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   use monit monitor ffmpeg start stop restart (https://www.linuxquestions.org/questions/linux-newbie-8/use-monit-monitor-ffmpeg-start-stop-restart-4175625170/)

scan73 03-07-2018 07:13 PM

use monit monitor ffmpeg start stop restart
 
Hi,
can anyone advise help trouble shoot this script. i using monit monitor start stop restart ffmpeg .

ubuntu 16.04 ( below is the script)

Thank



------------------------------------------------------------
/etc/init.d/monitoring.sh

---------------------------------------------------------
#!/bin/sh
pid_file="/var/run/ffmpeg.pid"

case "$1" in
restart)
/etc/init.d/monitoring stop
/etc/init.d/monitoring start
;;

start)
rm $pid_file
ffmpeg -f v4l2 -f alsa -ac 1 -ar 44100 -i hw:0,0 -c:v libx264 -crf 23 -tune zerolatency -preset ultrafast -c:a aac -strict experimental -f flv "rtmp://10.0.0.112:1935/live/myStream live=true pubUser=user pubPasswd=password"
ch_pid=$!
echo "Start monitoring: ffmpeg = $ch_pid";
echo $ch_pid > $pid_file
;;
stop)
echo "Stop monitoring";
kill `cat $pid_file` &> /dev/null
;;

*)
echo "Usage: /etc/init.d/monitoring {start|stop|restart}"
exit 1
;;
esac
exit 0
echo $pid_file

-----------------------------------------------------------------------------------------
Here is my monit configuration

--------------------------------------------------------------------------------------
check process ffmpeg with pidfile /var/run/ffmpeg.pid
nogroup
start program = "/etc/init.d/monitoring.sh start"
stop program = "/etc/init.d/monitoring.sh stop"
if failed host localhost port 1935 type tcp with timeout 15 seconds for 5 cycles then restart


-----------------------------------------------------------------------------------------

AwesomeMachine 03-08-2018 11:01 PM

Is there another script called monitoring that you're calling from monitoring.sh?

scan73 03-09-2018 01:04 AM

ffmpeg
 
hi
the script i call monitor.sh. i want monitor restart stop start ffmpeg when ffmpeg disconnector. the script got problem it can turn on start ffmpeg when it disconnector can anyone help to correct the problem. i using Monit to monitor ffmpeg.

AwesomeMachine 03-09-2018 01:25 AM

what is this in red
Code:

ase "$1" in
restart)
/etc/init.d/monitoring stop
/etc/init.d/monitoring start


ondoho 03-10-2018 03:24 AM

shouldn't the script be called either 'monitoring' or 'monitoring.sh', and not both?

AwesomeMachine 03-10-2018 12:07 PM

The script is named monitoring.sh. I don't know what monitoring without the sh is. But it looks like maybe the OP is trying to recursively call monitoring.sh, but he forgot the sh on the end.

scan73 03-13-2018 03:17 AM

Hi anyone can rewrite a script monitor ffmpeg pid . ffmpeg disconnector can auto start and restart ffmpeg. my script cannot work can anyone share the script.


All times are GMT -5. The time now is 10:50 PM.