chrony에서 logging 하기

리눅스 시스템에서 시간 동기화에 이용하는 서비스 중 하나인 chrony 가 제대로 동작하고 있는지 log를 기록하는 방법이다. 인터넷 검색을 해보면 chrony.conf 파일에서 다음의 문구를 추가해주는 것을 알려준다.

log measurements statistics tracking

이렇게 하면 /var/log/chrony에 3개의 로그 파일이 만들어진다. 그 중에서 현재 동기화된 서버와의 관계를 보여주는 것은 tracking.log 인 것 같다. 이 파일에 기록되는 항목은 다음과 같은 의미가 있다고 한다.

The columns are as follows (the quantities in square brackets are the values from the example line above) :

  1. Date [2017-08-22]
  2. Hour:Minute:Second. Note that the date-time pair is expressed in UTC, not the local time zone. [13:22:36]
  3. The IP address of the server or peer to which the local system is synchronised. [203.0.113.15]
  4. The stratum of the local system. [2]
  5. The local system frequency (in ppm, positive means the local system runs fast of UTC). [-3.541]
  6. The error bounds on the frequency (in ppm). [0.075]
  7. The estimated local offset at the epoch, which is normally corrected by slewing the local clock (in seconds, positive indicates the clock is fast of UTC). [-8.621e-06]
  8. Leap status (N means normal, + means that the last minute of this month has 61 seconds,  means that the last minute of the month has 59 seconds, ? means the clock is not currently synchronised.) [N]
  9. The number of combined sources. [2]
  10. The estimated standard deviation of the combined offset (in seconds). [2.940e-03]
  11. The remaining offset correction from the previous update (in seconds, positive means the system clock is slow of UTC). [-2.084e-04]
  12. The total of the network path delays to the reference clock to which the local clock is ultimately synchronised (in seconds). [1.534e-02]
  13. The total dispersion accumulated through all the servers back to the reference clock to which the local clock is ultimately synchronised (in seconds). [3.472e-04]
  14. The maximum estimated error of the system clock in the interval since the previous update (in seconds). It includes the offset, remaining offset correction, root delay, and dispersion from the previous update with the dispersion which accumulated in the interval. [8.304e-03]

주의할 점은 기록되는 tracking.log 같은 파일을 삭제하면 다시 생성이 되지 않는 것 같다. 매일마다 기록이 필요할 경우는 해당 파일을 복사한 후 파일은 유지하면서, 내용을 삭제하는 방법으로 하는 것이 좋을 것 같다.

echo '' > /var/log/chrony/tracking.log 

NTP를 이용하겠다는 사람은 당연히 알고 있어야 하는 것으로 NTP의 기준 시각은 UTC이다. 로그를 해석할 때 실수하지 않도록 하자.

나는 tracking 만을 이용할 것이기 때문에 다음 옵션만을 이용했다.

log tracking