SUSE Support

Here When You Need Us

How to enabe ntp statistics

This document (7012021) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 11 Service Pack 2
SUSE Linux Enterprise Server 11 Service Pack 1
SLES

Situation

How to enabe ntp statistics

Error in ntp log
20 Mar 15:24:21 ntpd[11158]: can't open /ntpstats/peerstats.20120320: Permission denied

Resolution

Edit the /etc/ntp/conf
unrem the following lines  (remove #)
and add the statistics line
Create the /ntpstats directory at  /var/lib/ntp/ntpstats" owned by "ntp". This directory can be a symbolic link to somewhere beneath /var/lib/ntp.

Example:
 statistics loopstats peerstats clockstats
 statsdir /ntpstats/            # directory for statistics files
 filegen peerstats  file peerstats  type day enable
 filegen loopstats  file loopstats  type day enable
 filegen clockstats file clockstats type day enable

mkdir /var/lib/ntp/ntpstats
chown ntp:ntp /var/lib/ntp/ntpstats

If Apparmor is enabled set the ntp profile to complain
aa-complain places a profile into complain mode. aa-complain /etc/apparmor.d/usr.sbin.ntpd
or use YaST

If the ntp service needs to remain as enforce then in the /etc/apparmor.d/usr.sbin.ntpd make the ntpstats and files in the ntpstats rwl
  /var/lib/ntp/ntpstats rwl,
  /var/lib/ntp/ntpstats/loopstats* rwl,
  /var/lib/ntp/ntpstats/peerstats* rwl,

Cause

ntpd is chrooted to /var/lib/ntp/
For the default configuration for SLES the chroot for ntp is /var/lib/ntp

To verify this do ps -ef | grep ntpd and look for the -c <conf file> which will point to the conf file.  The directory path before the -c (conf file) is the chroot for ntpd

Example for output for this command
/usr/sbin/ntpd -p /var/run/ntp/ntpd.pid -g -u ntp:ntp -i /var/lib/ntp -c /etc/ntp.conf

Additional Information

Popular options are
peerstats - Record peer statistics with one line appended to the peerstats file set each NTP packet or reference clock update
loopstats - Record clock discipline loop statistics . One line is appended to the loopstats file set each system clock update
clockstats - Record reference clock statistics with one line appended to the clockstats file set each update received from a reference clock driver
sysstats - Record system statistics with one line appended to the sysstats file each hour
Example:
 statistics loopstats peerstats clockstats sysstats
 statsdir /ntpstats/            # directory for statistics files
 filegen peerstats  file peerstats  type day enable
 filegen loopstats  file loopstats  type day enable
 filegen clockstats file clockstats type day enable
 filegen sysstats file sysstats type day enable

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7012021
  • Creation Date: 25-Mar-2013
  • Modified Date:03-Mar-2020
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.