隠れた便利ツールを活用する

以下のテキストは、執筆時当時の情報を元に書いたものであり、 現在の情勢にそぐわないことを含む場合があるので注意されたい。 また、テキストは最終提出原稿で校正を経る前のものなので、実際にUNIXUSER 本誌に記載されたものとは異なる。誤字脱字等そのままである。

致命的な誤り以外は加筆修正等は行なわないので情報の鮮度に気をつけつつ 利用して欲しい。

目次


Part 5 ()

Part5



clockspeed








NTPntpd(Network Time Protocol Daemon)
NTPGPS Stratum 1 
 Stratum 2, 3, ... 
NTP


clockspeedCPU
()
 ntpd()NTP
clockspeedUnix
clockspeed
NTP


--[ ]-------------------------------------------------------------


)
----------------------------------------------------------------------

clockspeed

ntpdclockspeed

clockspeed

	* 

	  DJBqmail1998
	  (0.62)

	* 

	  
	  
	  NTP
	  

	* 

	  clockspeed 
	  3
	  
	   

--[ ]-------------------------------------------------------------
PCntpd
clockspeed

----------------------------------------------------------------------

clockspeed

clockspeed



clockspeed Pentium CPURDTSC(Read Time Stamp Counter)
Solarisgethrtime() 
--[ ]-------------------------------------------------------------
 Pentium Solaris 

----------------------------------------------------------------------

Pentium
64 rdtsc 
CPU100MHz over 
1 10^-8 
clocksppedNTP
NTP
rdtsc





clockspeed


UTCTAI

1

2486400


1 
19671
9192631770
Temps Atomique International () 
TAI1

1(;
UT1)0.91
TAI
 UTC(Coordinated Universal Time)NTP
UTC 2002UTCTAI32


UnixUnixUnix(1970110
GMT) Unix time 
1009810800(JST)200211000
Unix time 
localtime()Unixlocaltime() POSIX

xntpd 

--[ ]-------------------------------------------------------------
http://cr.yp.to/proto/utctai.html 
----------------------------------------------------------------------

	1997-06-30 23:59:59.7 UTC -> 867715199.7 xntpd
	1997-06-30 23:59:59.8 UTC -> 867715199.8 xntpd
	1997-06-30 23:59:59.9 UTC -> 867715199.9 xntpd
	1997-06-30 23:59:60.0 UTC -> 867715200.0 xntpd
	1997-06-30 23:59:60.1 UTC -> 867715200.1 xntpd
	1997-06-30 23:59:60.2 UTC -> 867715200.2 xntpd
	1997-06-30 23:59:60.3 UTC -> 867715200.3 xntpd
	1997-06-30 23:59:60.4 UTC -> 867715200.4 xntpd
	1997-06-30 23:59:60.5 UTC -> 867715200.5 xntpd
	1997-06-30 23:59:60.6 UTC -> 867715200.6 xntpd
	1997-06-30 23:59:60.7 UTC -> 867715200.7 xntpd
	1997-06-30 23:59:60.8 UTC -> 867715200.8 xntpd
	1997-06-30 23:59:60.9 UTC -> 867715200.9 xntpd
	1997-07-01 00:00:00.0 UTC -> 867715200.0 xntpd
	1997-07-01 00:00:00.1 UTC -> 867715200.1 xntpd
	1997-07-01 00:00:00.2 UTC -> 867715200.2 xntpd

 23:59:60.9 UTC  00:00:00.0 UTC Unix time 
1

TAI+
PC-UnixPOSIX



clockspeedTAI
OS
()


clockspeed

clockspeed clockspeed-0.62 
http://cr.yp.to/clockspeed.html CD-ROM
clockspeed

	1. clockspeed
	2. (11)
	3. 
	4. taiclockd (LAN)


1. clockspeed

    clockspeed-0.62.tar.gz 
   

	# tar vxpf clockspeed-0.62.tar.gz
	# cd clockspeed-0.62
	# less INSTALL

   qmail conf-*
   

	% head conf-*
	==> conf-cc <==
	gcc -O2
	
	This will be used to compile .c files.
	
	==> conf-home <==
	/usr/local/clockspeed
	
	This is the clockspeed home directory. Programs will be installed in
	.../bin.
	
	==> conf-ld <==
	gcc -s
	
	This will be used to link .o files into an executable.

    conf-home 
   /usr/local/clockspeed (
   /usr/local/clockspeed/bin )

    

	% make

   root

	% su
	# make setup check

    /usr/local/clockspeed 
    /etc/leapsecs.dat TAI
   

    clockspeed 
   ($PATH) /usr/local/clockspeed/bin 

---[ ]------------------------------------------------------------
 Linux  clockview.c 

http://www.geocrawler.com/archives/3/509/2001/3/0/5427615/

----------------------------------------------------------------------

2. (111)

   NTP
   NTP http://www.kt.rim.or.jp/~ksakai/ntp.html 
   ISP
   NTP
   
   
   

    ntp.koeki-u.ac.jp(211.120.119.69; Stratum 2) NTP
   211.120.119.69 
   NTPIP
   

   NTP

	% sntpclock 211.120.119.69 | clockview
	  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	before: 2002-05-09 17:01:03.362059000000000000
	after:  2002-05-09 17:01:04.421865999951221048

   NTP
   NTP

    root NTP
   

	# sntpclock 211.120.119.69 | clockadd

   clockview

	% sntpclock 211.120.119.69 | clockview
	  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	  before: 2002-05-09 17:18:18.855419000000000000
	  after:  2002-05-09 17:18:18.853083999849356710

   clockspeed

	# clockspeed &
	# sntpclock 211.120.119.69 > /usr/local/clockspeed/adjust &

   ()
   

	# sntpclock 211.120.119.69 > /usr/local/clockspeed/adjust &

   
   
   
   

	# sntpclock 211.120.119.69 > /usr/local/clockspeed/adjust &

   
   
	% sntpclock 211.120.119.69 | clockview

   
   NTP1NTP
   

3.  

--[ ]-------------------------------------------------------------
Pentium OS
PC-UnixFreeBSD, NetBSD, RedHat
LinuxDebian/GNU Linux 
----------------------------------------------------------------------

   clockspeed
   

   clockspeedUnix/etc/localtime 
   
    /usr/share/zoneinfo 
   /usr/share/zoneinfo 
   Unix time 
   

	1. /usr/share/zoneinfo 
	2.  /etc/localtime 

   OS
   JSTJST
    /usr/share/zoneinfo 
   

   * FreeBSD

     (1)FreeBSD
      /usr/share (src/sshare.*) 
     
     /usr/src/share/zoneinfo/Makefile make
     LEAPSECONDS
     root

	# cd /usr/src/share/zoneinfo
	# make LEAPSECONDS=yes install

     (2) /usr/share/zoneinfo/Asia/Tokyo 
     /etc/localtime 

	# rm -f /etc/localtime
	# cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime

   * NetBSD

     (1)FreeBSD /usr/share 
     /usr/src/share/zoneinfo/Makefile 
     

	# cd /usr/src/share/zoneinfo
	#  make REDO=right_posix install

     (2)/etc/localtime 

	# rm -f /etc/localtime
	# cp /usr/share/zoneinfo/Japan /etc/localtime

   * Linux

      (1) /usr/share/zoneinfo POSIX
      
      /usr/share/zoneinfo/posix, /usr/share/zoneinfo/right 
       /usr/share/zoneinfo 
       right 
      

	# cd /usr/share/zoneinfo/right
	# cp -r * ..

     (2)/etc/localtime 

	# rm -f /etc/localtime
	# cp /usr/share/zoneinfo/Japan /etc/localtime

   OS
   OS
   CD-ROMNetBSD/i386 1.5ZC
   (
   )

   
4. taiclockd (LAN)

   clocksppedLAN taiclockd 
   clockspeed
    taiclockd 

	% taiclockd &

   

   3 sntpclock 
   taiclock 13
   
   (taiclockdLAN10.0.0.110)

	
	% taiclock 10.0.0.110 > adjustment
	% clockview < adjustment

	roottaiclockd
	# clockadd < adjustment

	clockspeed
	# clockspeed &
	# taiclock 10.0.0.110 > /usr/local/clockspeed/adjust &

	11....
	

    3, 4 root
    /usr/local/clockspeed/adjust (
   )

clockspeed

clockspeed
daemontools
svscanclockspeed
/usr/local/clockspeed/clockspeed 


	# mkdir /usr/local/clockspeed/clockspeed
	# cd /usr/local/clockspeed/clockspeed
	# touch run
	# chmod +x run
	# vi run
	()
---[ /usr/local/clockspeed/clockspeed/run ]---------------------------
#!/bin/sh
exec 2>&1
echo 'Starting clockspeed...'
exec env - PATH="$PATH" \
/usr/local/clockspeed/bin/clockspeed
----------------------------------------------------------------------

runclockspeed
(2)

	/usr/local/clockspeed/bin/sntpclock 211.120.119.69 \
		| /usr/local/clockspeed/bin/clockadd



run/service 
 clockspeed clockspeed
kill

	# kill clockspeedPID
	# ln -s /usr/local/clockspeed/clockspeed /service
	(5)
	# svstat /service/clockspeed




()clockspeed


clockspeedNTP 
NTP
UTC
t1UTC
(t2)UTC
t1

	t2 - t1


NTP()

---[  clockcheck.sh]------------------------------------------
#!/bin/sh
#NTP
SNTPSV=211.120.119.69
PATH=/usr/local/clockspeed/bin:$PATH

check () {
  echo -n "`date` "
  echo `sntpclock $SNTPSV | clockview \
	| awk -F: '{print $NF}' | tr '\012' '-' \
	| sed 's/-$//'` | bc -l
}

while true; do
  check
  sleep 10
done
----------------------------------------------------------------------



	CPU:	Athlon XP 2000+
	OS:	NetBSD 1.5ZC

clockspeed
 Stratum 2 NTP1
clockcheck.sh
GPS Stratum 1 NTP 
5


	 t1
	Thu May  9 22:32:01 JST 2002 -.021324499860517680
	Thu May  9 22:32:11 JST 2002 -.021237499778561293
	Thu May  9 22:32:21 JST 2002 -.021186499866738915
	Thu May  9 22:32:31 JST 2002 -.021297999775581061
	Thu May  9 22:32:41 JST 2002 -.021248499933503567
	(5 = -0.021258999842980505)

	t11
	Thu May  9 23:32:01 JST 2002 -.021898999815851449
	Thu May  9 23:32:11 JST 2002 -.021811499922394752
	Thu May  9 23:32:21 JST 2002 -.021762499892465770
	Thu May  9 23:32:31 JST 2002 -.021873499859705567
	Thu May  9 23:32:41 JST 2002 -.021823999831154942
	(5 = -0.021834099864314498)

	  -0.0213 - (-0.0218) = 0.0005

1 0.0005 1 0.0005*24*30=0.36
11
0.41
1



clockspeed




clockspeed



 publicfile


ADSL






 publicfile 

publicfile


http://cr.yp.to/publicfile.html publicfile


	* 
          chroot()root
	* 
          publicfile
	* user, group, other 
          
	* HTTP, FTP
          
	* HTTP CGI( )FTP
          SITE EXEC
	* stdio

---[ ]-----------------------------------------------------------
shttpd(http://www.superscript.com/shttpd/intro.html) 

---------------------------------------------------------------------

publicfile

 publicfile  publicfile-0.52.tar.gz  
http://cr.yp.to/publicfile.html  "How to install publicfile" 
CD-ROM
DJB

	# gzip -dc publicfile-0.52.tar.gz
	# cd publicfile-0.52
	# make
	# make setup check

/usr/local/publicfile/bin publicfile

conf-home make
 /usr/local/publicfile/bin 

publicfile

publicfileftpWeb
djbdnstinydns-confpubilcfile

configureftpdhttpddaemontools 
1
configure 

/usr/local/publicfile/bin/configure      ...



			(
			UID/GID )
		(
			multilogUID/GID)
			ftpd, httpd 
			(configuremkdir
			)
			
			IP
	...		



			public
			publiclog
		/archive/public
			ftp.uu.ymzk.org
				www.uu.ymzk.org
	IP		10.0.0.21

 anonymous ftp Web
publicfile4

	1. 
	2. 
	3. configure
	4. 




1. 

    public 
    public 

	(Solaris2, Linux, NetBSD, OpenBSD)
	# groupadd public
	# useradd -s /bin/noshell -d /opt/public/ftpd -g public public
	(FreeBSD)
	# pw groupadd public
	# pw useradd public -g public -s /noshell -d /opt/public/ftpd

    publiclog 

	(Solaris2, Linux, NetBSD, OpenBSD)
	# useradd -s /bin/noshell -d /opt/public/ftpd/log -g public publiclog
	(FreeBSD)
	# pw useradd publiclog -g public -s /noshell -d /opt/public/ftpd/log

2. 

    /archive/public 
    publicfile configure
    /archive/public 
   configure
   mkdir

3. configure

   

	# /usr/local/publicfile/bin/configure \
	    public publiclog /archive/public ftp.uu.ymzk.org 10.0.0.21 \
	    www.uu.ymzk.org

   /archive/public  
   
 ------------------------------------------------------------
# ls -lF /archive/public
total 3
drwxr-sr-x  3 root  wheel  512 May 11 00:53 file/
drwx--S--T  3 root  wheel  512 May 11 00:53 ftpd/
drwx--S--T  3 root  wheel  512 May 11 00:53 httpd/

# ls -lF /archive/public/*
/archive/public/file:
total 1
drwxr-sr-x  2 root  wheel  512 May 11 00:53 0/
lrwxr-xr-x  1 root  wheel    1 May 11 00:53 10.0.0.21@ -> 0
lrwxr-xr-x  1 root  wheel    1 May 11 00:53 ftp.uu.ymzk.org@ -> 0
lrwxr-xr-x  1 root  wheel    1 May 11 00:53 www.uu.ymzk.org@ -> 0

/archive/public/ftpd:
total 2
drwxr-sr-x  3 root  wheel  512 May 11 00:53 log/
-rwxr-xr-x  1 root  wheel  176 May 11 00:53 run*

/archive/public/httpd:
total 2
drwxr-sr-x  3 root  wheel  512 May 11 00:53 log/
-rwxr-xr-x  1 root  wheel  152 May 11 00:53 run*
----------------------------------------------------------------------

4. 

   /archive/public/ftpd, /archive/public/httpd 
   daemontools run 
    run 

# head */run
==> ftpd/run <==
#!/bin/sh
exec 2>&1
exec envuidgid public softlimit -o20 -d50000 tcpserver -vUDRHl0 -b20 -c40 -B'220 Features: a p .
' 0 21 /usr/local/publicfile/bin/ftpd /archive/public/file

==> httpd/run <==
#!/bin/sh
exec 2>&1
exec envuidgid public softlimit -o20 -d50000 tcpserver -vUDRHl0 -b50 -c100 0 80 /usr/local/publicfile/bin/httpd /archive/public/file

   

	A softlimit 
          
	B (PATH)

   A run 
   (NetBSD 1.5ZC)softlimit
   

	# /archive/public/httpd/run
	  ~~~~~~~~~~~~~~~~~~~~~~~~~
	mmap of bss failed: Cannot allocate memory

    softlimit  -d ()

	# vi /archive/public/httpd/run
	(softlimit)

	exec envuidgid public softlimit -o20 -d50000  ()
					       ~~~~~
	
	exec envuidgid public softlimit -o20 -d100000  ()
					       ~~~~~~
    run httpd
   

	# /archive/public/httpd/run
	  ~~~~~~~~~~~~~~~~~~~~~~~~~
	tcpserver: status: 0/100

   Bucspi-tcp  /usr/local/bin 
   runPATH
   

   
   /service 
   httpd

	# ln -s /archive/public/httpd /service

   ftpd

	# ln -s /archive/public/ftpd /service

   svstat

	# svstat /service/httpd
	  ~~~~~~~~~~~~~~~~~~~~~
	/service/httpd: up (pid 15240) 5 seconds

	# svstat /service/ftpd
	  ~~~~~~~~~~~~~~~~~~~~
	/service/ftp: up (pid 15255) 4 seconds

   up01svstat pid 
   run
   

	(httpd)
	# cd /service/httpd
	# rm /service/httpd
	# svc -dx . log

publicfile 

publicfile configure 
file/ 
 0/ publicfile
ftpd  anonymous ftp login 


chroot

httpdHTTP 
 Virtual Host public httpd 
/archive/public/file IP 
HTTP


	http://virtual.uu.ymzk.org/

 Virtual Host 

	/archive/public/file/virtual.uu.ymzk.org/





	
	# cd /archive/public/file
	# ln -s 0 virtual.uu.ymzk.org

Web


	
	(root)
	# cd /archive/public/file/www.uu.ymzk.org
	# mkdir -p users/taro
	# chown taro users/taro
	(taro)
	% ln -s /archive/public/file/www.uu.ymzk.org/users/taro ~/webpage





publicfile 



yuuji@gentei.org
Fingerprint16 = FF F9 FF CC E0 FE 5C F7 19 97 28 24 EC 5D 39 BA
HIROSE Yuuji - ASTROLOGY / BIKE / EPO / GUEST BOOK / YaTeX [Tweet]