Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Linux - How Do I Determine NTP Stratum Level

Posted on 2009-04-22
Medium Priority
Last Modified: 2013-12-15

I'm running CentOs 5.2, in a local closed network with several other NTP
servers running (each with a different stratum level).
My main processor is set up as a local time server (,
and ntpd seems to be running OK. In my C application, I need to know
the stratum level of the time server currently in use - this is because
this legacy application relies on the unique statum level to determine
the server's ID.

So - is there an easy way to determine the stratum level at runtime - or
should I adopt another method to determine the server ID?

Question by:dbCnc
  • 2
  • 2
LVL 13

Expert Comment

ID: 24210179
ntpq -p

The third column is the stratum level of the servers you are connecting to.

Author Comment

ID: 24214610


Yes I've been able to determine the stratum level interactively from the command line using ntpq-p as you mentioned.
What I'm trying to do is to determine the stratum from within my C application at runtime.
Is there an easy way to do this, or do I have to code up an NTP client to receive the data from the server?

LVL 13

Accepted Solution

WizRd-Linux earned 2000 total points
ID: 24220096
You are able to do this, but all you will be doing is re-writing ntpq.  If you have a desire to do this you will need to download the source of ntpd and review the source code for ntpq, specifically when the -p flag is called.  This will give you the code to extract the stratum and use in your application.

Unfortunately there isn't a method to achieve the results you are after.

Author Closing Comment

ID: 31573288

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question