From ecad87d725b67f5238fb852981a5ad9acae6c680 Mon Sep 17 00:00:00 2001 From: vvitkov Date: Wed, 31 Oct 2018 16:11:19 +0200 Subject: [PATCH] check_mk agent plugin extension --- .../check_mk-agent/count-streams.cfg | 2 + .../check_mk-agent/count-streams.sh | 39 +++++++++++++++++++ .../check_mk-agent/count-streams.xsl | 7 ++++ 3 files changed, 48 insertions(+) create mode 100644 monitoring/custom-scripts/check_mk-agent/count-streams.cfg create mode 100644 monitoring/custom-scripts/check_mk-agent/count-streams.sh create mode 100644 monitoring/custom-scripts/check_mk-agent/count-streams.xsl diff --git a/monitoring/custom-scripts/check_mk-agent/count-streams.cfg b/monitoring/custom-scripts/check_mk-agent/count-streams.cfg new file mode 100644 index 0000000..75232ec --- /dev/null +++ b/monitoring/custom-scripts/check_mk-agent/count-streams.cfg @@ -0,0 +1,2 @@ +# config file for count-streams.sh +STREAMERS=http://stream.openfest.org/stats \ No newline at end of file diff --git a/monitoring/custom-scripts/check_mk-agent/count-streams.sh b/monitoring/custom-scripts/check_mk-agent/count-streams.sh new file mode 100644 index 0000000..94ec82d --- /dev/null +++ b/monitoring/custom-scripts/check_mk-agent/count-streams.sh @@ -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 "<<>>" +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 \ No newline at end of file diff --git a/monitoring/custom-scripts/check_mk-agent/count-streams.xsl b/monitoring/custom-scripts/check_mk-agent/count-streams.xsl new file mode 100644 index 0000000..1038540 --- /dev/null +++ b/monitoring/custom-scripts/check_mk-agent/count-streams.xsl @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file