Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 May 2007 20:40:16 +0200 (CEST)
From:      Oliver Fromme <olli@secnetix.de>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        Oliver Fromme <olli@secnetix.de>
Subject:   conf/112604: New file: /etc/periodic/daily/480.status-ntp
Message-ID:  <200705111840.l4BIeGGo086849@lurza.secnetix.de>
Resent-Message-ID: <200705111900.l4BJ0BPZ000627@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         112604
>Category:       conf
>Synopsis:       New file: /etc/periodic/daily/480.status-ntp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 11 19:00:10 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Oliver Fromme
>Release:        FreeBSD 6.2-STABLE i386
>Organization:
secnetix GmbH & Co. KG
		http://www.secnetix.de/bsd
>Environment:
FreeBSD 6-stable + 7-current

>Description:

The script below adds an optional status report for NTP
to the daily periodic output.  It exits with return code 0
if the local ntpd is successfully synchronized.  It exits
with return code 1 if the local ntpd is currently not
synchronized, or if ntpd isn't running at all, or if it's
refusing connections from localhost.

>How-To-Repeat:

Save the script below as /etc/periodic/daily/480.status-ntp
and add this line to /etc/periodic.conf:
daily_status_ntp_enable="YES"

Suggested default entry for /etc/defaults/periodic.conf:
# 480.status-ntp
daily_status_ntp_enable="NO"			# Check NTP status

>Fix:

#!/bin/sh
#
# $FreeBSD$
#

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

rc=0

case "$daily_status_ntp_enable" in
    [Yy][Ee][Ss])
	echo ""
	echo "NTP status:"

	synchronized=$(ntpq -p | tee /dev/stderr | grep '^\*')
	if [ -z "$synchronized" ]; then
		rc=1
	fi
	;;
esac

exit $rc
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705111840.l4BIeGGo086849>