#!/bin/sh
# -*- sh -*-

: <<EOF

=head1 NAME

ntp_kernel_err - Plugin to monitor the PLL estimated error for the
kernel NTP status

=head1 CONFIGURATION

No configuration

=head1 AUTHORS

Unknown author

=head1 LICENSE

Unknown license

=head1 MAGIC MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=cut

EOF

# $Id: ntp_kernel_err.in,v 1.1.1.1 2006/06/04 20:53:57 he Exp $

if [ "$1" = "autoconf" ]; then
    # Not all ntpdc's are equal
    ntpdc -c kern 2>/dev/null | 
    awk 'BEGIN { ev=1; }
         /^estimated error:/ { ev=0; } 
         END { if (ev == 0) { print "yes";} else { print "no"; } exit ev; }'
    exit 0
fi

if [ "$1" = "config" ]; then
    echo 'graph_title NTP kernel PLL estimated error (secs)'
    echo 'graph_vlabel est. err (secs)'
    echo 'graph_category time'
    echo 'graph_info The kernels estimated error for the phase-locked loop used by NTP'
    echo 'ntp_err.label est-error'
    echo 'ntp_err.info Estimated error for the kernel PLL'
    exit 0
fi

echo -n 'ntp_err.value '
ntpdc -c kern | awk '/^estimated error:/ { print $3 }'
