mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 18:07:20 +00:00
- added ntp plugins for precision and tolerance graphing
- merged timing directories see last pull request: https://github.com/munin-monitoring/contrib/pull/112
This commit is contained in:
parent
fd2a8b3bb1
commit
7ed1f35266
3 changed files with 0 additions and 0 deletions
|
@ -1,90 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to parse Chrony Tracking Output
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-config)
|
||||
#
|
||||
# $log$
|
||||
# Revision 0.1 2008/08/23 13:06:00 joti
|
||||
# First version only chronyc tracking, autodetection included.
|
||||
#
|
||||
# Revision 0.2 2008/10/11 16:09:00 joti
|
||||
# Added scaling of other values to match with frequency, added more description to fields
|
||||
#
|
||||
# Magic markers (optional - used by munin-config and installation
|
||||
# scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
|
||||
#Modify this to fit other chronyc path
|
||||
CHRONYC=/usr/bin/chronyc
|
||||
|
||||
#Frequency has extremely higher values than other. Therefore they are fitted by scaling. Adjust the factor here
|
||||
FACTOR=1000
|
||||
#fieldfactors="1000 1 1000 100 1000 1000"
|
||||
fieldfactors="1000 1 100 100 1000 1000"
|
||||
#Fields to catch and graph, second line is friendly name
|
||||
fields="systime frequency residualfreq skew rootdelay rootdispersion"
|
||||
fieldnames="System Time (seconds,x=Frequency (seconds,x=Residual Freq (ppm,x=Skew (ppm,x=Root delay(seconds,x=Root dispersion (seconds,x"
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if [ -f "$CHRONYC" ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
else
|
||||
echo "no (no $CHRONYC)"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
|
||||
echo 'graph_title Chrony Tracking Stats'
|
||||
echo 'graph_args --base 1000 -l 0'
|
||||
#echo 'graph_vlabel seconds / ${graph_period}'
|
||||
echo 'units (seconds,ppm)'
|
||||
#echo 'graph_total total'
|
||||
echo 'graph_category NTP'
|
||||
i=0
|
||||
for a in $fields ; do
|
||||
i=$(expr $i + 1);
|
||||
#echo "i=$i"
|
||||
word=`echo $fieldnames | cut -f $i -d '='`;
|
||||
factor=`echo $fieldfactors | cut -f $i -d ' '`;
|
||||
echo "$a.label $word$factor)";
|
||||
echo "$a.type GAUGE";
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
#Remove superflous whitespace (hinders cut), remove non-needed output lines, remove more space,cut out final result value, scale values to factor if needed, output values in munin-required format
|
||||
j=0
|
||||
chronyc tracking | \
|
||||
sed "s/ */ /g" | \
|
||||
sed "1,3d" | \
|
||||
# grep -v "Frequency" | \
|
||||
sed "s/ : /:/g" | \
|
||||
cut -f 2 -d ':' | \
|
||||
cut -f 1 -d ' ' | \
|
||||
while read LINE; do
|
||||
j=$(expr $j + 1);
|
||||
measure=`echo $fields | cut -f $j -d ' '`;
|
||||
factor=`echo $fieldfactors | cut -f $j -d ' '`;
|
||||
echo -en "$measure.value ";
|
||||
# if [ "$measure" = "frequency" ]; then
|
||||
#measure is frequency do not enlarge numbers
|
||||
# echo $LINE | xargs printf "%1.2f";
|
||||
# else
|
||||
#measure is not frequency, enlarge numbers to make them showable together with frequency
|
||||
echo $LINE*$factor | bc | xargs printf "%1.2f";
|
||||
# fi
|
||||
#echo $LINE*100 | bc | xargs printf "%1.2f";
|
||||
echo;
|
||||
done
|
||||
|
|
@ -1,189 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
# Plugin to monitor offsets to multiple NTP peers.
|
||||
# NB currently only works for IPv4 peers
|
||||
#
|
||||
# (c)2008 Chris Hastie: chris (at) oak (hyphen) wood (dot) co (dot) uk
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-node-configure)
|
||||
#
|
||||
# Config variables:
|
||||
#
|
||||
# ntpq - path to ntpq program
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Change log
|
||||
# v1.0.0 2008-07-21 Chris Hastie
|
||||
# initial release
|
||||
# v1.0.1 2009-06-05 Tony Hoyle
|
||||
# ipv6 support. Remove dns lookups.
|
||||
#
|
||||
#
|
||||
# Magic markers - optional - used by installation scripts and
|
||||
# munin-node-configure:
|
||||
#
|
||||
#%# family=contrib
|
||||
#%# capabilities=autoconf
|
||||
#
|
||||
|
||||
use strict;
|
||||
|
||||
my $NTPQ = $ENV{ntpq} || "ntpq";
|
||||
my $COMMAND = "$NTPQ -nc associations";
|
||||
|
||||
my $statedir = $ENV{statedir} || '/usr/local/var/munin/plugin-state';
|
||||
my $statefile = "$statedir/ntp_peers.state";
|
||||
|
||||
# autoconf
|
||||
if ($ARGV[0] and $ARGV[0] eq "autoconf") {
|
||||
`$NTPQ -c help >/dev/null 2>/dev/null`;
|
||||
if ($? eq "0") {
|
||||
if (`$NTPQ -np | wc -l` > 0) {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
} else {
|
||||
print "no (unable to list peers)\n";
|
||||
exit 1;
|
||||
}
|
||||
} else {
|
||||
print "no (ntpq not found)\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
my %peers;
|
||||
|
||||
# get data from ntpq
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Could not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
if(/^\s*\d+\s+(\d+)\s+/) {
|
||||
my ($name, $offset) = &lookupip($1);
|
||||
$peers{$name} = $offset;
|
||||
}
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
# config
|
||||
if ($ARGV[0] and $ARGV[0] eq 'config') {
|
||||
print "graph_title NTP peer offsets\n";
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_vlabel ms\n";
|
||||
print "graph_category ntp\n";
|
||||
print "graph_info Offset (in ms) to the server's NTP peers\n";
|
||||
print "graph_order ";
|
||||
foreach my $key (sort keys %peers) {
|
||||
print &sanitize_field($key) . " ";
|
||||
}
|
||||
print "\n";
|
||||
foreach my $peer (keys %peers) {
|
||||
print &sanitize_field($peer) . ".label " . $peer . "\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# send output
|
||||
foreach my $peer (keys %peers) {
|
||||
print &sanitize_field($peer) . ".value " . &getpeeroffset($peer) . "\n";
|
||||
}
|
||||
|
||||
# create a valid munin field name from the hostname
|
||||
sub sanitize_field () {
|
||||
my $field = shift;
|
||||
|
||||
# replace illegal characters with an underscore
|
||||
$field =~ s/[^A-Za-z0-9_]/_/g;
|
||||
# prepend an underscore if name starts with a number
|
||||
$field =~ s/^([^A-Za-z_])/_$1/;
|
||||
|
||||
# truncate to 19 characters
|
||||
if (length($field) > 19) {
|
||||
$field = substr($field, 0, 19);
|
||||
}
|
||||
return $field
|
||||
}
|
||||
|
||||
# get an IP address from the underscore escaped
|
||||
# value of env.hostname_<key>
|
||||
sub desanitize_field () {
|
||||
my $field = shift;
|
||||
$field =~ s/_/\./g;
|
||||
return $field
|
||||
}
|
||||
|
||||
# Get name, offset info for peers
|
||||
# It would be more efficient to use mrv here to avoid rerunning ntpq
|
||||
sub lookupip() {
|
||||
my $assocID = shift;
|
||||
my $CMD = "$NTPQ -c \"rv $assocID srcadr,offset\"";
|
||||
my $addr="";
|
||||
my $offset="";
|
||||
|
||||
# get data from ntpq
|
||||
open(SERVICE2, "$CMD |")
|
||||
or die("Could not execute '$CMD': $!");
|
||||
|
||||
while(<SERVICE2>) {
|
||||
if(/^srcadr=([^\s]+),\soffset=(.+)$/) {
|
||||
$addr = $1;
|
||||
$offset = $2;
|
||||
}
|
||||
}
|
||||
close(SERVICE2);
|
||||
return ($addr, $offset);
|
||||
}
|
||||
|
||||
# returns the offset, or U if it is undefined
|
||||
sub getpeeroffset() {
|
||||
my $name = shift;
|
||||
my $rtn = 'U';
|
||||
if (exists($peers{$name})) {
|
||||
$rtn = $peers{$name};
|
||||
}
|
||||
return $rtn
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=head1 Description
|
||||
|
||||
ntp_peers - A munin plugin to monitor offsets to multiple NTP peers and
|
||||
graph them on a single graph
|
||||
|
||||
=head1 Parameters understood:
|
||||
|
||||
config (required)
|
||||
autoconf (optional - used by munin-node-configure)
|
||||
|
||||
=head1 Configuration variables:
|
||||
|
||||
All configuration parameters are optional
|
||||
|
||||
ntpq - path to ntpq program
|
||||
statedir - directory in which to place state file
|
||||
hostname_<key> - override hostname for peer <key>. <key> is
|
||||
an IPv4 address with dots replaced by underscores.
|
||||
Useful for reference clocks, eg
|
||||
env.hostname_127_127_43_0 .GPS.
|
||||
|
||||
=head1 Known issues
|
||||
|
||||
ntp_peers will not monitor IPv6 peers
|
||||
|
||||
=cut
|
|
@ -1,150 +0,0 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
# Plugin to monitor ntp queries
|
||||
# (c)2009 Chris Hastie: chris (at) oak (hyphen) wood (dot) co (dot) uk
|
||||
#
|
||||
# Parameters understood:
|
||||
#
|
||||
# config (required)
|
||||
# autoconf (optional - used by munin-node-configure)
|
||||
#
|
||||
# Config variables:
|
||||
#
|
||||
# ntpdc - path to ntpdc program
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Change log
|
||||
# v1.0.0 2009-03-11 Chris Hastie
|
||||
# initial release
|
||||
#
|
||||
#
|
||||
#
|
||||
# Magic markers - optional - used by installation scripts and
|
||||
# munin-node-configure:
|
||||
#
|
||||
#%# family=contrib
|
||||
#%# capabilities=autoconf
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Socket;
|
||||
|
||||
my $NTPDC = $ENV{ntpdc} || "ntpdc";
|
||||
my $COMMAND = "$NTPDC -c sysstats";
|
||||
|
||||
|
||||
# autoconf
|
||||
if ($ARGV[0] and $ARGV[0] eq "autoconf") {
|
||||
`$NTPDC -c help >/dev/null 2>/dev/null`;
|
||||
if ($? eq "0") {
|
||||
if (`$NTPDC -c sysstats | wc -l` > 0) {
|
||||
print "yes\n";
|
||||
exit 0;
|
||||
} else {
|
||||
print "no (unable to list system stats)\n";
|
||||
exit 1;
|
||||
}
|
||||
} else {
|
||||
print "no (ntpdc not found)\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
my $queries = 0;
|
||||
my $packrcv;
|
||||
my $packproc;
|
||||
|
||||
|
||||
# get data from tc
|
||||
open(SERVICE, "$COMMAND |")
|
||||
or die("Could not execute '$COMMAND': $!");
|
||||
|
||||
while (<SERVICE>) {
|
||||
if (/^packets received:\s*(\d*)/) {
|
||||
$packrcv = $1;
|
||||
}
|
||||
if (/^packets processed:\s*(\d*)/) {
|
||||
$packproc = $1;
|
||||
}
|
||||
if (/^current version:\s*(\d*)/) {
|
||||
$queries += $1;
|
||||
}
|
||||
if (/^previous version:\s*(\d*)/) {
|
||||
$queries += $1;
|
||||
}
|
||||
if (/^bad version:\s*(\d*)/) {
|
||||
$queries += $1;
|
||||
}
|
||||
# if (/^access denied:\s*(\d*)/) {
|
||||
# $queries += $1;
|
||||
# }
|
||||
# if (/^bad length or format:\s*(\d*)/) {
|
||||
# $queries += $1;
|
||||
# }
|
||||
# if (/^bad authentication:\s*(\d*)/) {
|
||||
# $queries += $1;
|
||||
# }
|
||||
# if (/^rate exceeded:\s*(\d*)/) {
|
||||
# $queries += $1;
|
||||
# }
|
||||
|
||||
}
|
||||
close(SERVICE);
|
||||
|
||||
$queries = $queries - $packproc;
|
||||
|
||||
# config
|
||||
if ($ARGV[0] and $ARGV[0] eq 'config') {
|
||||
print "graph_title NTP Queries\n";
|
||||
print "graph_args --base 1000\n";
|
||||
print "graph_vlabel qps\n";
|
||||
print "graph_category ntp\n";
|
||||
print "graph_info Queries to the NTP server\n";
|
||||
print "queries.label Queries per second\n";
|
||||
print "queries.type DERIVE\n";
|
||||
print "queries.min 0\n";
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
# send output
|
||||
|
||||
print "queries.value $queries\n";
|
||||
|
||||
##################################
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head1 Description
|
||||
|
||||
ntp_queries - A munin plugin to monitor queries handled by NTP
|
||||
|
||||
=head1 Parameters understood:
|
||||
|
||||
config (required)
|
||||
autoconf (optional - used by munin-node-configure)
|
||||
|
||||
=head1 Configuration variables:
|
||||
|
||||
All configuration parameters are optional
|
||||
|
||||
ntpdc - path to ntpdc program
|
||||
|
||||
|
||||
=head1 Known issues
|
||||
|
||||
|
||||
=cut
|
Loading…
Add table
Add a link
Reference in a new issue