check_mk agent plugin extension

This commit is contained in:
vvitkov 2018-10-31 16:11:19 +02:00
parent fc4020b477
commit ecad87d725
3 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,2 @@
# config file for count-streams.sh
STREAMERS=http://stream.openfest.org/stats

View File

@ -0,0 +1,39 @@
#!/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

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:value-of select="count(/rtmp/server/application/live/stream)"/>
</xsl:template>
</xsl:transform>