2018/monitoring/custom-scripts/check_mk-agent/count-streams.sh

39 lines
1005 B
Bash
Raw Normal View History

2018-10-31 16:11:19 +02:00
#!/bin/sh
#
# This check can be used to count the number of streams from nginx
STREAMERS=http://stream.openfest.org/stats
if [ -e $MK_CONFDIR/count-streams.cfg ] ; then
. $MK_CONFDIR/count-streams.cfg
fi
if [ ! -r $MK_CONFDIR/count-streams.xsl ] ; then
_res=3
_data="UNKNOWN: Stylesheet not found"
fi
echo "<<<stream_count>>>"
for STREAMER in ${STREAMERS} ; do
stream_count=`curl -sfq -m1 ${STREAMER} | xsltproc $MK_CONFDIR/count-streams.xsl -`
_warn=${1:-3}
_crit=${2:-6}
if [ $stream_count -ge $_crit ] ; then
_data="OK - stream count $stream_count"
_res=0
fi
if [ $stream_count -ge $_crit -a $stream_count -le $_warn ] ; then
_data="WARN - stream count $stream_count, less than expected. Min $_crit, needed $_warn"
_res=1
fi
if [ $stream_count -lt $_crit ] ; then
_data="CRITICAL - Streams lower than $_crit"
_res=2
fi
echo Streamcount_${STREAMER} ${_res} ${_data}
done