Révision 3ef6c0a7
add ntp_pool_score
| plugins/time/ntp_pool_score_ | ||
|---|---|---|
| 1 |
#!/bin/bash |
|
| 2 |
# -*- bash -*- |
|
| 3 |
|
|
| 4 |
: << =cut |
|
| 5 |
|
|
| 6 |
=head1 NAME |
|
| 7 |
|
|
| 8 |
ntp_pool_score_ - Wildcard plugin to monitor the score assigned to a server |
|
| 9 |
from pool.ntp.org . This is achieved by fetching the cvs data from |
|
| 10 |
http://www.pool.ntp.org/scores/IP_ADDRESS/log?limit=1 using wget. |
|
| 11 |
|
|
| 12 |
=head1 CONFIGURATION |
|
| 13 |
|
|
| 14 |
This is a wildcard plugin. The wildcard suffix link will be the server to be |
|
| 15 |
monitored. |
|
| 16 |
|
|
| 17 |
This plugin uses the following configuration variables: |
|
| 18 |
|
|
| 19 |
[ntp_pool_score_*] |
|
| 20 |
env.warning - score below which a warning will be triggered |
|
| 21 |
env.critical - score below which the value becomes critical |
|
| 22 |
|
|
| 23 |
=head2 DEFAULT CONFIGURATION |
|
| 24 |
|
|
| 25 |
The default configuration is to set warning to 15 and critical to 10. |
|
| 26 |
|
|
| 27 |
=head2 EXAMPLE WILDCARD USAGE |
|
| 28 |
|
|
| 29 |
C<ln -s /usr/share/munin/plugins/ntp_pool_score_ /etc/munin/plugins/ntp_pool_score_SERVER_IP |
|
| 30 |
|
|
| 31 |
...will monitor the score of the server with ip address SERVER_IP |
|
| 32 |
|
|
| 33 |
=head1 AUTHOR |
|
| 34 |
|
|
| 35 |
Tocho Tochev |
|
| 36 |
tocho AT tochev DOT net |
|
| 37 |
|
|
| 38 |
=head1 LICENSE |
|
| 39 |
|
|
| 40 |
GNU General Public License, version 2 |
|
| 41 |
http://www.gnu.org/licenses/gpl-2.0.html |
|
| 42 |
|
|
| 43 |
=head1 MAGIC MARKERS |
|
| 44 |
|
|
| 45 |
#%# family=manual |
|
| 46 |
|
|
| 47 |
=cut |
|
| 48 |
|
|
| 49 |
target=`basename $0 | sed 's/^ntp_pool_score_//g'` |
|
| 50 |
|
|
| 51 |
if [ "$target"x = "x" ]; then |
|
| 52 |
echo "Please call using ntp_pool_score_IP" >&2 |
|
| 53 |
exit 1 |
|
| 54 |
fi |
|
| 55 |
|
|
| 56 |
# Check if config was requested |
|
| 57 |
if [ "$1" = "config" ]; then |
|
| 58 |
|
|
| 59 |
# Configure graph |
|
| 60 |
echo "graph_title NTP Pool Score for $target" |
|
| 61 |
echo 'graph_args -l -25 -u 25' |
|
| 62 |
echo 'graph_vlabel Score' |
|
| 63 |
echo 'graph_category time' |
|
| 64 |
echo "graph_info NTP Pool Score for $target" |
|
| 65 |
echo "score.warning ${warning:-15}":
|
|
| 66 |
echo "score.critical ${critical:-10}":
|
|
| 67 |
echo "score.info Score for $target" |
|
| 68 |
echo "score.label score" |
|
| 69 |
|
|
| 70 |
exit 0 |
|
| 71 |
fi |
|
| 72 |
|
|
| 73 |
|
|
| 74 |
# Get the score |
|
| 75 |
# the score can be a bit outdated but do not worry about that |
|
| 76 |
SCORE=$(wget "http://www.pool.ntp.org/scores/$target/log?limit=1" \ |
|
| 77 |
--timeout=30 -O - 2>/dev/null \ |
|
| 78 |
| tail -n 1 | awk -F ',' '{print $5}')
|
|
| 79 |
|
|
| 80 |
if echo "$SCORE" | grep -q '^[0-9.]\+$'; then |
|
| 81 |
echo "score.value $SCORE" |
|
| 82 |
else |
|
| 83 |
echo "score.value U" |
|
| 84 |
fi |
|
| 85 |
|
|
Formats disponibles : Unified diff