LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-07-2018, 07:13 PM   #1
scan73
LQ Newbie
 
Registered: Aug 2007
Posts: 12

Rep: Reputation: 0
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


-----------------------------------------------------------------------------------------
 
Old 03-08-2018, 11:01 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Is there another script called monitoring that you're calling from monitoring.sh?
 
Old 03-09-2018, 01:04 AM   #3
scan73
LQ Newbie
 
Registered: Aug 2007
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 03-09-2018, 01:25 AM   #4
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
what is this in red
Code:
ase "$1" in
restart)
/etc/init.d/monitoring stop
/etc/init.d/monitoring start
 
Old 03-10-2018, 03:24 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 12,301
Blog Entries: 9

Rep: Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307
shouldn't the script be called either 'monitoring' or 'monitoring.sh', and not both?
 
Old 03-10-2018, 12:07 PM   #6
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
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.
 
Old 03-13-2018, 03:17 AM   #7
scan73
LQ Newbie
 
Registered: Aug 2007
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script monitor ffmpeg fail restart scan73 Linux - Newbie 8 02-22-2018 02:58 AM
How to setup Auditd to monitor Apache/httpd for stop and restart. Nemus Linux - Security 3 09-11-2014 06:19 PM
how can i start, stop or restart Paxmaster Slackware 3 11-27-2004 01:31 PM
how to stop/start/restart iptables? plan9 Linux - Newbie 8 08-06-2004 04:40 PM
Start Stop Restart Services Sifvion Slackware 6 09-14-2002 03:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration