うるう秒を観測しよう for Squeeze

■LeapIndicator

 午前2時頃にはLeapIndicator(LIフラグ)は受け取っていませんでしたが、
 午前9時頃に確認したときにはLIフラグが立っていました。
 いよいよなので、自サーバのうるう秒を観測する準備をしましょう。

 Debian Lenny/Squeezeでのうるう秒対策まとめ
 http://d.hatena.ne.jp/labunix/20120308/

■ログのサイズは1回当たり1KB程度。

$ echo 'associd=0 status=4615 leap_add_sec, sync_ntp, 1 event, clock_sync,
version="ntpd 4.2.6p2@1.2194-o Sun Oct 17 13:35:13 UTC 2010 (1)",
processor="x86_64", system="Linux/2.6.32-5-amd64", leap=01, stratum=2,
precision=-23, rootdelay=12.510, rootdisp=28.388, refid=133.243.238.164,
reftime=d398e51d.de6c4aa0  Sat, Jun 30 2012 11:38:21.868,
clock=d398e734.cd6175ce  Sat, Jun 30 2012 11:47:16.802, peer=38985,
tc=10, mintc=3, offset=0.211, frequency=-22.470, sys_jitter=0.613,
clk_jitter=0.409, clk_wander=0.029
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*133.243.238.164 .NICT.           1 u  535 1024  377   12.510    0.211   0.613
ntp_gettime() returns code 1 (INS)
  time d398e734.cf68d000  Sat, Jun 30 2012 11:47:16.810, (.810193),
  maximum error 294132 us, estimated error 408 us
ntp_adjtime() returns code 1 (INS)
  modes 0x0 (),
  offset 185.000 us, frequency -22.470 ppm, interval 1 s,
  maximum error 294132 us, estimated error 408 us,
  status 0x4011 (PLL,INS,MODE),
  time constant 10, precision 1.000 us, tolerance 500 ppm,
1341024436
Sat Jun 30 02:47:16 UTC 2012
' | wc -c
1187

■うるう秒のフラグ

leap=01
ntp_gettime() returns code 1 (INS)

1 TIME_INS	 正の閏秒の警告です。 この日の最後の 23:59:59 の後に追加の 1 秒が挿入されます。
 ※00:00:00(GMT+9時間がJST)

 うるう秒の検証に使えそう ntptime
 http://d.hatena.ne.jp/labunix/20120306/

■ブロックサイズの4KBとして一日分を予測。
 エラー等で急激に増加したりしなければ、CDに収まる程度。

$ echo "4 60 60 24" | awk '{print $1*$2*$3*$4"KB"}'
345600KB

■root権限が必要なコマンドもありますが、ノーチェックです。

$ cat leapindicator.sh
#!/bin/bash
ntpq -c rv -p -n
ntptime
date '+%s'
env LANG=C date -u1秒ごとに実行し、保存も行います。

$ sudo watch -d -n 1 './leapindicator.sh | tee -a LI.log'

■停止するときは、「Ctrl+C」です。

■ちなみにナノ秒は。。。
$ date '+%N' | awk '{print "0."$0}'
0.998211921