kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

NTP log 记录每次发包

vim /etc/ntp.conf

logfile /var/log/ntp.log

修改rpm

https://rpmfind.net/linux/RPM/centos/7.9.2009/x86_64/Packages/ntp-4.2.6p5-29.el7.centos.2.x86_64.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/libntp/humandate.c b/libntp/humandate.c
index 705f4c8..ece409e 100644
--- a/libntp/humandate.c
+++ b/libntp/humandate.c
@@ -26,9 +26,14 @@ humanlogtime(void)

  LIB_GETBUF(bp);

+/*
  snprintf(bp, LIB_BUFLENGTH, "%2d %s %02d:%02d:%02d",
       tm->tm_mday, months[tm->tm_mon],
       tm->tm_hour, tm->tm_min, tm->tm_sec);
+*/
+ snprintf(bp, LIB_BUFLENGTH, "%04d-%02d-%02d %02d:%02d:%02d",
+      tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+      tm->tm_hour, tm->tm_min, tm->tm_sec);

  return bp;
 }
diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c
index 89b1e96..46d1692 100644
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3191,6 +3191,9 @@ sendpkt(
      DPRINTF(2, ("%ssendpkt(%d, dst=%s, src=%s, ttl=%d, len=%d)\n",
              ismcast ? "\tMCAST\t***** " : "", src->fd,
              stoa(dest), stoa(&src->sin), ttl, len));
+     msyslog(LOG_INFO, "%ssendpkt(%d, dst=%s, src=%s, ttl=%d, len=%d)\n",
+             ismcast ? "\tMCAST\t***** " : "", src->fd,
+             stoa(dest), stoa(&src->sin), ttl, len);
 #ifdef MCAST
      /*
       * for the moment we use the bcast option to set multicast ttl

tail -f /var/log/ntp.log

1
2024-08-09 17:23:14 ntpd[45933]: sendpkt(19, dst=106.55.184.199, src=192.168.100.80, ttl=0, len=48)

system, base

« NTP服务配置 textarea自动调整高宽 »