From e37060b702a7be3a627685ee1503f540dcc3ac8c Mon Sep 17 00:00:00 2001 From: vvitkov Date: Wed, 31 Oct 2018 17:11:51 +0200 Subject: [PATCH] polish --- .../check_mk-agent/check_rtmp.sh | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/monitoring/custom-scripts/check_mk-agent/check_rtmp.sh b/monitoring/custom-scripts/check_mk-agent/check_rtmp.sh index 797b9c4..8a4d451 100644 --- a/monitoring/custom-scripts/check_mk-agent/check_rtmp.sh +++ b/monitoring/custom-scripts/check_mk-agent/check_rtmp.sh @@ -47,28 +47,26 @@ if [ -e $MK_CONFDIR/check_rtmp.cfg ] ; then fi # Proces de parametres -while getopts ":u:t:h" Option -do - case $Option in - u ) URLS=$OPTARG;; - t ) TIMEOUT=$OPTARG;; - h ) print_help;; - * ) echo "unimplemented option";; - esac +while getopts ":u:t:h" Option ; do + case $Option in + u ) URLS=$OPTARG;; + t ) TIMEOUT=$OPTARG;; + h ) print_help;; + * ) echo "unimplemented option";; + esac done -if [ ! $URLS ] ; then +if [ -z "${URLS}" ] ; then echo "Stream_UNKNOWN ${STATE_UNKNOWN} No URL's defined" - fi for _uri in ${URLS} ; do # 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 # 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=$? # Retorn de resultats @@ -77,15 +75,17 @@ for _uri in ${URLS} ; do if [ -z "$CONNECTA" ] then echo "echo Stream_${_uri} ${STATE_CRITICAL} Cannot Connect" + continue else ERROR=`grep "INFO: Metadata:" $ERR` if [ ! -z "$ERROR" ] then echo "Stream_${_uri} ${STATE_OK} Stream is normal" - fi - echo "Stream_${_uri} ${STATE_CRITICAL} Stream is not broadcasting" + continue + fi + echo "Stream_${_uri} ${STATE_CRITICAL} Stream is not broadcasting" + continue fi echo "Stream_${_uri} ${STATE_UNKNOWN} Unknown output from stream check. Manual check is advised" - exit $STATE_UNKNOWN done \ No newline at end of file