[Ultrapossum-cvs 219] demo/haviewer 1.11,1.12,haviewer.rb

アーカイブの一覧に戻る

Masato Taruishi taru****@sourc*****
2004年 6月 23日 (水) 19:01:18 JST


===================================================================
RCS file: demo/haviewer/haviewer.rb,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- demo/haviewer/haviewer.rb	2004/06/23 09:19:17	1.11
+++ demo/haviewer/haviewer.rb	2004/06/23 10:01:18	1.12
@@ -80,6 +80,7 @@
       statusbuf = "-----"
       pidbuf = "-----"
       sincebuf = "-----"
+      puts "snmpget -v1 -c ultrapossum #{@host} #{OID_STATUS} #{OID_PID} #{OID_SINCE}" if $DEBUG
       buf = `snmpget -v1 -c ultrapossum #{@host} #{OID_STATUS} #{OID_PID} #{OID_SINCE}`
       buf.each_line do |line|
         case line
@@ -123,19 +124,13 @@
     
       Column = ["S", "Host", "Type", "Status", "Pid", "Since" ]
 
-      def initialize
+      def initialize(haview)
         @list = Gtk::ListStore.new( String, String, String, String, String, String)
         @columns = []
         Column.size.times do |i|
           @columns << Gtk::TreeViewColumn.new(Column[i], Gtk::CellRendererText.new, { :markup => i })
         end
         h = Host.new(`ultrapossum-config get MASTER`.gsub!(/MASTER="(.+)"\n/, '\1'), "master" )
-        Thread.new {
-          while(1) do
-            h.snmp
-	    sleep 10
-          end
-        }
 	@row = {} 
 	@row[h] =****@list*****
         Hosts << h
@@ -144,24 +139,18 @@
           h = Host.new(s.chomp, (backup==s)?"master":"slave" )
 	  @row[h] =****@list*****
           Hosts << h
-          Thread.new {
-            while(1) do
-              h.snmp
-	      sleep 10
-            end
-          }
         end
+	@haview = haview
       end
 
-      def update
-        @row.each do |host,row|
-          @list.set_value(row, 0, host.sign.to_s)
-          @list.set_value(row, 1, host.host)
-          @list.set_value(row, 2, host.type)
-          @list.set_value(row, 3, host.status)
-          @list.set_value(row, 4, host.pid)
-          @list.set_value(row, 5, host.since)
-	end
+      def update(host)
+        @list.set_value(@row[host], 0, host.sign.to_s)
+        @list.set_value(@row[host], 1, host.host)
+        @list.set_value(@row[host], 2, host.type)
+        @list.set_value(@row[host], 3, host.status)
+        @list.set_value(@row[host], 4, host.pid)
+        @list.set_value(@row[host], 5, host.since)
+	@haview.update
       end
 
       def summary
@@ -224,7 +213,7 @@
   def update
     @glade["time"].set_text(`date | iconv --to UTF-8`.chomp!)
     @glade["uptime"].set_text(`uptime`.chomp!)
-    @view.update if @view
+#    @view.update if @view
     summary
   end
 
@@ -243,12 +232,18 @@
 
 Gtk.init
 
-h = HAViewer.new('haviewer.glade')
-h.set_view( HAViewer::View::UltraPossum.new )
-h.update
-Gtk.timeout_add(5000) {
-  h.update
-  true
-}
+haview = HAViewer.new('haviewer.glade')
+haview.set_view( HAViewer::View::UltraPossum.new(haview) )
+haview.update
+HAViewer::Hosts.each do |host|
+  haview.view.update(host)
+  Thread.new {
+    while(1) do
+      host.snmp
+      haview.view.update(host)
+      sleep 10
+    end
+  }
+end
 Gtk.main
 



Ultrapossum-cvs メーリングリストの案内
アーカイブの一覧に戻る