From 3ef6c0a74f79cd0f2e445777a697df989059afd3 Mon Sep 17 00:00:00 2001 From: Tocho Tochev Date: Fri, 30 May 2014 02:23:26 +0300 Subject: [PATCH 1/3] add ntp_pool_score --- plugins/time/ntp_pool_score_ | 85 ++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 plugins/time/ntp_pool_score_ diff --git a/plugins/time/ntp_pool_score_ b/plugins/time/ntp_pool_score_ new file mode 100755 index 00000000..c206b9ab --- /dev/null +++ b/plugins/time/ntp_pool_score_ @@ -0,0 +1,85 @@ +#!/bin/bash +# -*- bash -*- + +: << =cut + +=head1 NAME + +ntp_pool_score_ - Wildcard plugin to monitor the score assigned to a server +from pool.ntp.org . This is achieved by fetching the cvs data from +http://www.pool.ntp.org/scores/IP_ADDRESS/log?limit=1 using wget. + +=head1 CONFIGURATION + +This is a wildcard plugin. The wildcard suffix link will be the server to be +monitored. + +This plugin uses the following configuration variables: + + [ntp_pool_score_*] + env.warning - score below which a warning will be triggered + env.critical - score below which the value becomes critical + +=head2 DEFAULT CONFIGURATION + +The default configuration is to set warning to 15 and critical to 10. + +=head2 EXAMPLE WILDCARD USAGE + +C&2 + exit 1 +fi + +# Check if config was requested +if [ "$1" = "config" ]; then + + # Configure graph + echo "graph_title NTP Pool Score for $target" + echo 'graph_args -l -25 -u 25' + echo 'graph_vlabel Score' + echo 'graph_category time' + echo "graph_info NTP Pool Score for $target" + echo "score.warning ${warning:-15}": + echo "score.critical ${critical:-10}": + echo "score.info Score for $target" + echo "score.label score" + + exit 0 +fi + + +# Get the score +# the score can be a bit outdated but do not worry about that +SCORE=$(wget "http://www.pool.ntp.org/scores/$target/log?limit=1" \ + --timeout=30 -O - 2>/dev/null \ + | tail -n 1 | awk -F ',' '{print $5}') + +if echo "$SCORE" | grep -q '^[0-9.]\+$'; then + echo "score.value $SCORE" +else + echo "score.value U" +fi + From d885efee2d9264577ddf7ecf7fff4f89d4888b85 Mon Sep 17 00:00:00 2001 From: tochev Date: Fri, 30 May 2014 03:23:51 +0300 Subject: [PATCH 2/3] ntp_pool_score: switch to /bin/sh --- plugins/time/ntp_pool_score_ | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/time/ntp_pool_score_ b/plugins/time/ntp_pool_score_ index c206b9ab..be3218c9 100755 --- a/plugins/time/ntp_pool_score_ +++ b/plugins/time/ntp_pool_score_ @@ -1,5 +1,5 @@ -#!/bin/bash -# -*- bash -*- +#!/bin/sh +# -*- sh -*- : << =cut From 20a713f6c2d155d3144464b775adcded7d2e3c32 Mon Sep 17 00:00:00 2001 From: tochev Date: Fri, 30 May 2014 15:26:43 +0300 Subject: [PATCH 3/3] ntp_pool_score: fix negative values --- plugins/time/ntp_pool_score_ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/time/ntp_pool_score_ b/plugins/time/ntp_pool_score_ index be3218c9..1e5ce7d4 100755 --- a/plugins/time/ntp_pool_score_ +++ b/plugins/time/ntp_pool_score_ @@ -77,7 +77,7 @@ SCORE=$(wget "http://www.pool.ntp.org/scores/$target/log?limit=1" \ --timeout=30 -O - 2>/dev/null \ | tail -n 1 | awk -F ',' '{print $5}') -if echo "$SCORE" | grep -q '^[0-9.]\+$'; then +if echo "$SCORE" | grep -q '^-\?[0-9.]\+$'; then echo "score.value $SCORE" else echo "score.value U"