[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Debian JP master SVN www commits (rev.260)



=======================================================
Repository: /org/svn.debian.or.jp/repos
  Revision: 260
  Commiter: yasu
      Date: 2007-04-14 21:10:33 +0900 (土, 14  4月 2007)
=======================================================
Log:

add syslog

=======================================================
Changed:

A   cdn/ChangeLog
A   cdn/README
U   cdn/check-surrogates.rb
A   cdn/config-server-lists.rb

Added: cdn/ChangeLog
===================================================================
--- cdn/ChangeLog	                        (rev 0)
+++ cdn/ChangeLog	2007-04-14 12:10:33 UTC (rev 260)
@@ -0,0 +1,9 @@
+2007-04-14  ARAKI Yasuhiro  <yasu@debian.or.jp>
+
+	* README: add new file.
+
+	* check-surrogates.rb: main program.
+
+	* config-server-lists.rb: add new file for cdn.debian.or.jp.
+	
+

Added: cdn/README
===================================================================
--- cdn/README	                        (rev 0)
+++ cdn/README	2007-04-14 12:10:33 UTC (rev 260)
@@ -0,0 +1,17 @@
+使いかた
+
+https://osdn.debian.or.jp/repos/cdn からダウンロードする。
+
+check-surrogates.rb をcronでまわすようにする。
+
+ */2 * * * * cd /home/yasu2/Debian-JP/DNS-Balance-2.0 && ruby check-surrogates.rb
+
+これが動くと addr というファイルが作られる。
+
+DNS-Balance/addr -> addr のリンクをつくる。
+
+DNS-Balanceを動作させる。(これはrootで動いている必要がある)
+ # ruby dns_balance.rb -i 210.157.158.38
+
+/var/log/syslog/daemon.log などを確認する。
+

Modified: cdn/check-surrogates.rb
===================================================================
--- cdn/check-surrogates.rb	2007-04-10 06:14:47 UTC (rev 259)
+++ cdn/check-surrogates.rb	2007-04-14 12:10:33 UTC (rev 260)
@@ -7,26 +7,29 @@
 require 'uri'
 require 'resolv'
 
-surrogates = {
-  '203.178.137.175' => '1',
-#  '133.41.81.212' => '9900', # hiroshima-u
-  '219.103.212.212' => '1000', # hanzubon
-  '210.157.158.38' => '9900', # plat
-  '210.157.158.59' => '9900' ## fail
-}
+sslog = Syslog.open(__FILE__,   
+                  Syslog::Constants::LOG_PID |
+                  Syslog::Constants::LOG_CONS,
+                  Syslog::Constants::LOG_DAEMON)
 
-def checkhttp(host, codename='sid', port=80, tl=5)
+require File.dirname(__FILE__) + '/config-server-lists'
+surrogates = $surrogates
+
+def checkhttp(host, slog, codename='sid', port=80, tl=5)
   begin 
-    timeout(tl) do 
-      h = Net::HTTP.new(host, port)
-      case response = h.get("/debian/dists/#{codename}/Release", nil)
-      when Net::HTTPSuccess
-        return true
-      else
-        return nil
-      end
+    h = Net::HTTP.new(host, port)
+    h.open_timeout = 10
+    h.read_timeout = 20
+    case response = h.head("/debian/dists/#{codename}/Release", nil)
+    when Net::HTTPSuccess
+      slog.info("#{host} return #{response.code}")
+      return true
+    else
+      slog.info("#{host} return #{response.code}")
+      return nil
     end
-  rescue
+  rescue Timeout::Error
+    slog.info("#{host} timeout (#{$!})")
     return nil
   end
 end
@@ -34,7 +37,7 @@
 s_active = Hash.new
 
 surrogates.each do |t_ip, t_value|
-  if checkhttp(t_ip)
+  if checkhttp(t_ip, sslog)
     s_active[t_ip.gsub('.',',')] = t_value
   else
   end
@@ -63,3 +66,5 @@
 }'
 
 foo.close
+sslog.close
+

Added: cdn/config-server-lists.rb
===================================================================
--- cdn/config-server-lists.rb	                        (rev 0)
+++ cdn/config-server-lists.rb	2007-04-14 12:10:33 UTC (rev 260)
@@ -0,0 +1,7 @@
+$surrogates = {
+  '203.178.137.175' => '0', # naist
+  '61.115.118.67' => '9000', # hanzubon 2007apr5
+  '210.157.158.38' => '9900', # plat
+#  '15.12.218.222' => '9900', # fail data for test
+#  '210.157.158.59' => '9900' ## fail data for test
+}