This commit is contained in:
vvitkov 2018-10-31 17:11:51 +02:00
parent d038a86783
commit e37060b702
1 changed files with 15 additions and 15 deletions

View File

@ -47,28 +47,26 @@ if [ -e $MK_CONFDIR/check_rtmp.cfg ] ; then
fi fi
# Proces de parametres # Proces de parametres
while getopts ":u:t:h" Option while getopts ":u:t:h" Option ; do
do case $Option in
case $Option in u ) URLS=$OPTARG;;
u ) URLS=$OPTARG;; t ) TIMEOUT=$OPTARG;;
t ) TIMEOUT=$OPTARG;; h ) print_help;;
h ) print_help;; * ) echo "unimplemented option";;
* ) echo "unimplemented option";; esac
esac
done done
if [ ! $URLS ] ; then if [ -z "${URLS}" ] ; then
echo "Stream_UNKNOWN ${STATE_UNKNOWN} No URL's defined" echo "Stream_UNKNOWN ${STATE_UNKNOWN} No URL's defined"
fi fi
for _uri in ${URLS} ; do for _uri in ${URLS} ; do
# Construir noms de fitxers temporals # Construir noms de fitxers temporals
NAME=`echo $URL | sed -e s/[^A-Za-z0-9.]/_/g` NAME=`echo $_uri | sed -e s/[^A-Za-z0-9.]/_/g`
ERR=/tmp/check_rtmp_err_$NAME.tmp ERR=/tmp/check_rtmp_err_$NAME.tmp
# Testejant # Testejant
( $RTMPDUMP -m 4 --live -r $URL --stop $TIMEOUT > /dev/null 2> $ERR ) & sleep 5; kill $! 2> /dev/null ( $RTMPDUMP -m 4 --live -r $_uri --stop $TIMEOUT > /dev/null 2> $ERR ) & sleep 3; kill $! 2> /dev/null
_data=$? _data=$?
# Retorn de resultats # Retorn de resultats
@ -77,15 +75,17 @@ for _uri in ${URLS} ; do
if [ -z "$CONNECTA" ] if [ -z "$CONNECTA" ]
then then
echo "echo Stream_${_uri} ${STATE_CRITICAL} Cannot Connect" echo "echo Stream_${_uri} ${STATE_CRITICAL} Cannot Connect"
continue
else else
ERROR=`grep "INFO: Metadata:" $ERR` ERROR=`grep "INFO: Metadata:" $ERR`
if [ ! -z "$ERROR" ] if [ ! -z "$ERROR" ]
then then
echo "Stream_${_uri} ${STATE_OK} Stream is normal" echo "Stream_${_uri} ${STATE_OK} Stream is normal"
fi continue
echo "Stream_${_uri} ${STATE_CRITICAL} Stream is not broadcasting" fi
echo "Stream_${_uri} ${STATE_CRITICAL} Stream is not broadcasting"
continue
fi fi
echo "Stream_${_uri} ${STATE_UNKNOWN} Unknown output from stream check. Manual check is advised" echo "Stream_${_uri} ${STATE_UNKNOWN} Unknown output from stream check. Manual check is advised"
exit $STATE_UNKNOWN
done done