[ntp:questions] use ntpd, how to know unsync status on linux system

赵颖科 zhaoyingke at sf-auto.com
Mon Aug 9 09:33:58 UTC 2010


        I`m using ntpd(ntp4.2.6p1) as client in linux(2.6.26). I have some questions about my user app how to know the ntp client sync status.

        1. I use ntp_gettime, is there other way?
        2. If there is no server alive, when I start ntp client, why ntptime show :ntp_gettime() returns code 0, but not code 5?
         I trace the  function loop_config in the file ntpd/ntp_loopfilter.c :

                        case LOOP_DRIFTINIT:
#ifndef LOCKCLOCK
#ifdef KERNEL_PLL
                if (mode_ntpdate)
                        break;

                pll_control = 1;
                memset(&ntv, 0, sizeof(ntv));
                ntv.modes = MOD_BITS;
                ntv.status = STA_PLL;
                ntv.maxerror = MAXDISPERSE;
                ntv.esterror = MAXDISPERSE;
                ntv.constant = sys_poll;

        I think it should be :
                ntv.maxerror = (u_int32)(MAXDISPERSE * 1e6);
                ntv.esterror = (u_int32)(MAXDISPERSE * 1e6);

        or not?

        3. If ntp server no answer for 1h or shortter time, ntpd can mark unsync stat? how could I config ntpd?





本电子邮件及附件都属机密文件,并且仅供标明地址的个人或团体使用。
如果本电子邮件与您无关,请删除全部原始信息(包括任何原始信息的备份),并通知发件人。
This email and its attachments may be confidential and are intended solely for the use of the individual to whom it is addressed.
If you are not the intended recipient of this email and its attachments, you must take no action based upon them, nor must you copy or show them to anyone. Please contact the sender if you believe you have received this email in error.



More information about the questions mailing list