免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1741 | 回复: 7
打印 上一主题 下一主题

[服务应用] NTP服务器 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-03-11 14:42 |只看该作者 |倒序浏览
请问在RHEL6上面还有ntptrace该命令吗?但我安装该服务器后没有找见该命令,我安装的是RPM包。如果有的话,在哪里呢?

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
2 [报告]
发表于 2013-03-11 14:59 |只看该作者
楼主看看有没有ntp-perl包,安装下

论坛徽章:
0
3 [报告]
发表于 2013-03-11 16:25 |只看该作者
回复 2# chenyx


    没有该软件包啊。下载一个吗?

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
4 [报告]
发表于 2013-03-11 16:37 |只看该作者
系统没有,只能自己下载了.

论坛徽章:
0
5 [报告]
发表于 2013-03-11 20:02 |只看该作者
在rhel6.3下面试了一下,应该是没有这个,需要自行安装:
[root@a1 ~]# ntp
ntpd        ntpdate     ntpdc       ntp-keygen  ntpq        ntpstat     ntptime

论坛徽章:
0
6 [报告]
发表于 2013-03-11 21:09 |只看该作者
就是个perl脚本

  1. #! /usr/bin/perl -w

  2. # John Hay -- John.Hay@icomtek.csir.co.za / jhay@FreeBSD.org

  3. use Socket;
  4. use Getopt::Std;
  5. use vars qw($opt_n $opt_m);

  6. $ntpq = "ntpq";

  7. $Getopt::Std::STANDARD_HELP_VERSION=1;
  8. getopts('nm:');

  9. $dodns = 1;
  10. $dodns = 0 if (defined($opt_n));

  11. $max_hosts = (defined($opt_m) ? $opt_m :  99);
  12. $max_hosts = 0 if ( $max_hosts !~ /^\d+$/ );
  13. $nb_host = 1;

  14. $host = shift;
  15. $host ||= "127.0.0.1";

  16. for (;;) {
  17.         $nb_host++;
  18.         $rootdelay = 0;
  19.         $rootdispersion = 0;
  20.         $stratum = 255;
  21.         $cmd = "$ntpq -n -c rv $host";
  22.         open(PH, $cmd . "|") || die "failed to start command $cmd: $!";
  23.         while (<PH>) {
  24.                 $stratum = $1 if (/stratum=(\d+)/);
  25.                 $peer = $1 if (/peer=(\d+)/);
  26.                 # Very old servers report phase and not offset.
  27.                 $offset = $1 if (/(?:offset|phase)=([^\s,]+)/);
  28.                 $rootdelay = $1 if (/rootdelay=([^\s,]+)/);
  29.                 $rootdispersion = $1 if (/rootdispersion=([^\s,]+)/);
  30.                 $refid = $1 if (/refid=([^\s,]+)/);
  31.         }
  32.         close(PH) || die "$cmd failed";
  33.         last if ($stratum == 255);
  34.         $offset /= 1000;
  35.         $syncdistance = ($rootdispersion + ($rootdelay / 2)) / 1000;
  36.         $dhost = $host;
  37.         # Only do lookups of IPv4 addresses. The standard lookup functions
  38.         # of perl only do IPv4 and I don't know if we should require extras.
  39.         if ($dodns && $host =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) {
  40.                 $iaddr = inet_aton($host);
  41.                 $name = (gethostbyaddr($iaddr, AF_INET))[0];
  42.                 $dhost = $name if (defined($name));
  43.         }
  44.         printf("%s: stratum %d, offset %f, synch distance %f",
  45.             $dhost, $stratum, $offset, $syncdistance);
  46.         printf(", refid '%s'", $refid) if ($stratum == 1);
  47.         printf("\n");
  48.         last if ($stratum == 0 || $stratum == 1 || $stratum == 16);
  49.         last if ($refid =~ /^127\.127\.\d{1,3}\.\d{1,3}$/);
  50.         last if ($nb_host > $max_hosts);

  51.         $cmd = "$ntpq -n -c \"pstat $peer\" $host";
  52.         open(PH, $cmd . "|") || die "failed to start command $cmd: $!";
  53.         $thost = "";
  54.         while (<PH>) {
  55.                 $thost = $1, last if (/srcadr=(\S+),/);
  56.         }
  57.         close(PH) || die "$cmd failed";
  58.         last if ($thost eq "");
  59.         last if ($thost =~ /^127\.127\.\d{1,3}\.\d{1,3}$/);
  60.         $host = $thost;
  61. }


复制代码

论坛徽章:
0
7 [报告]
发表于 2013-03-13 12:41 |只看该作者
用ntpd自动同步ntp服务器,或者使用ntpdate定期同步

论坛徽章:
0
8 [报告]
发表于 2013-03-13 14:12 |只看该作者
命令已去除了,早期的版本有
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP