Linux - How Do I Determine NTP Stratum Level

Posted on 2009-04-22
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
    LVL 13

    Expert Comment

    ntpq -p

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

    Author Comment



    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

    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


    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
    It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now