[Ultrapossum-cvs 377] demo/haviewer 1.11, 1.12, haviewer.glade 1.23, 1.24, haviewer.rb

Back to archive index

Masato Taruishi taru****@users*****
2004年 9月 10日 (金) 18:22:22 JST


===================================================================
RCS file: demo/haviewer/haviewer.glade,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- demo/haviewer/haviewer.glade	2004/09/09 15:45:13	1.11
+++ demo/haviewer/haviewer.glade	2004/09/10 09:22:21	1.12
@@ -359,7 +359,6 @@
 		<widget class="GtkVBox" id="vbox4">
 		  <property name="border_width">4</property>
 		  <property name="visible">True</property>
-		  <property name="sensitive">False</property>
 		  <property name="homogeneous">False</property>
 		  <property name="spacing">0</property>
 
@@ -367,6 +366,7 @@
 		    <widget class="GtkHBox" id="hbox6">
 		      <property name="border_width">4</property>
 		      <property name="visible">True</property>
+		      <property name="sensitive">False</property>
 		      <property name="homogeneous">False</property>
 		      <property name="spacing">8</property>
 
@@ -480,24 +480,178 @@
 		  </child>
 
 		  <child>
-		    <widget class="GtkScrolledWindow" id="scrolledwindow2">
-		      <property name="border_width">4</property>
+		    <widget class="GtkVBox" id="vbox5">
 		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
-		      <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
-		      <property name="shadow_type">GTK_SHADOW_NONE</property>
-		      <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+		      <property name="homogeneous">False</property>
+		      <property name="spacing">0</property>
+
+		      <child>
+			<widget class="GtkHBox" id="hbox8">
+			  <property name="visible">True</property>
+			  <property name="homogeneous">False</property>
+			  <property name="spacing">0</property>
+
+			  <child>
+			    <widget class="GtkFrame" id="frame2">
+			      <property name="visible">True</property>
+			      <property name="label_xalign">0</property>
+			      <property name="label_yalign">0.5</property>
+			      <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+
+			      <child>
+				<widget class="GtkAlignment" id="alignment1">
+				  <property name="border_width">2</property>
+				  <property name="visible">True</property>
+				  <property name="xalign">0.5</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xscale">1</property>
+				  <property name="yscale">1</property>
+				  <property name="top_padding">0</property>
+				  <property name="bottom_padding">0</property>
+				  <property name="left_padding">12</property>
+				  <property name="right_padding">4</property>
+
+				  <child>
+				    <widget class="GtkLabel" id="monitored_entry">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">XXXXXXXX</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				    </widget>
+				  </child>
+				</widget>
+			      </child>
+
+			      <child>
+				<widget class="GtkLabel" id="label14">
+				  <property name="visible">True</property>
+				  <property name="label" translatable="yes">Entry</property>
+				  <property name="use_underline">False</property>
+				  <property name="use_markup">True</property>
+				  <property name="justify">GTK_JUSTIFY_LEFT</property>
+				  <property name="wrap">False</property>
+				  <property name="selectable">False</property>
+				  <property name="xalign">0.5</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				</widget>
+				<packing>
+				  <property name="type">label_item</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">True</property>
+			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+
+			  <child>
+			    <widget class="GtkFrame" id="frame3">
+			      <property name="visible">True</property>
+			      <property name="label_xalign">0</property>
+			      <property name="label_yalign">0.5</property>
+			      <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+
+			      <child>
+				<widget class="GtkAlignment" id="alignment2">
+				  <property name="border_width">2</property>
+				  <property name="visible">True</property>
+				  <property name="xalign">0.5</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xscale">1</property>
+				  <property name="yscale">1</property>
+				  <property name="top_padding">0</property>
+				  <property name="bottom_padding">0</property>
+				  <property name="left_padding">12</property>
+				  <property name="right_padding">4</property>
+
+				  <child>
+				    <widget class="GtkLabel" id="latest_entrycsn">
+				      <property name="visible">True</property>
+				      <property name="label" translatable="yes">XXXXXXXX</property>
+				      <property name="use_underline">False</property>
+				      <property name="use_markup">False</property>
+				      <property name="justify">GTK_JUSTIFY_LEFT</property>
+				      <property name="wrap">False</property>
+				      <property name="selectable">False</property>
+				      <property name="xalign">0.5</property>
+				      <property name="yalign">0.5</property>
+				      <property name="xpad">0</property>
+				      <property name="ypad">0</property>
+				    </widget>
+				  </child>
+				</widget>
+			      </child>
+
+			      <child>
+				<widget class="GtkLabel" id="label16">
+				  <property name="visible">True</property>
+				  <property name="label" translatable="yes">Latest entryCSN</property>
+				  <property name="use_underline">False</property>
+				  <property name="use_markup">True</property>
+				  <property name="justify">GTK_JUSTIFY_LEFT</property>
+				  <property name="wrap">False</property>
+				  <property name="selectable">False</property>
+				  <property name="xalign">0.5</property>
+				  <property name="yalign">0.5</property>
+				  <property name="xpad">0</property>
+				  <property name="ypad">0</property>
+				</widget>
+				<packing>
+				  <property name="type">label_item</property>
+				</packing>
+			      </child>
+			    </widget>
+			    <packing>
+			      <property name="padding">0</property>
+			      <property name="expand">True</property>
+			      <property name="fill">True</property>
+			    </packing>
+			  </child>
+			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">False</property>
+			  <property name="fill">False</property>
+			</packing>
+		      </child>
 
 		      <child>
-			<widget class="GtkTreeView" id="treeview2">
+			<widget class="GtkScrolledWindow" id="scrolledwindow2">
+			  <property name="border_width">4</property>
 			  <property name="visible">True</property>
 			  <property name="can_focus">True</property>
-			  <property name="headers_visible">True</property>
-			  <property name="rules_hint">False</property>
-			  <property name="reorderable">False</property>
-			  <property name="enable_search">True</property>
+			  <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+			  <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+			  <property name="shadow_type">GTK_SHADOW_NONE</property>
+			  <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+			  <child>
+			    <widget class="GtkTreeView" id="treeview2">
+			      <property name="visible">True</property>
+			      <property name="can_focus">True</property>
+			      <property name="headers_visible">True</property>
+			      <property name="rules_hint">False</property>
+			      <property name="reorderable">False</property>
+			      <property name="enable_search">True</property>
+			    </widget>
+			  </child>
 			</widget>
+			<packing>
+			  <property name="padding">0</property>
+			  <property name="expand">True</property>
+			  <property name="fill">True</property>
+			</packing>
 		      </child>
 		    </widget>
 		    <packing>
===================================================================
RCS file: demo/haviewer/haviewer.rb,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- demo/haviewer/haviewer.rb	2004/09/09 15:45:13	1.23
+++ demo/haviewer/haviewer.rb	2004/09/10 09:22:21	1.24
@@ -2,6 +2,7 @@
 
 require 'uconv'
 require 'libglade2'
+require 'ultrapossum'
 
 def on_close_clicked
   Gtk.main_quit
@@ -32,7 +33,6 @@
      end
    end
 
-
     DarkGreen = "#005500"
     DarkYellow = "#555500"
     DarkRed = "#550000"
@@ -100,13 +100,14 @@
       @host = host;
       @status = ""
       @sign = Signal::SignalFactory.create
+      @repl_sign = Signal::SignalFactory.create
       @type = type
     end
 
     def update
     end
 
-    attr_reader :row, :host, :sign
+    attr_reader :row, :host, :sign, :repl_sign
     attr_accessor :type
     
   end
@@ -130,6 +131,36 @@
         OID_PID = OID + ".1.2.0"
         OID_SINCE = OID + ".1.3.0"
 
+        @@latest_entryCSN = ""
+	@@monitored_entry = "cn=u0001,o=ultrapossum"
+
+        def UltraPossumHost.update_latest_entryCSN
+	  `ldapsearch -l 1 -x -h #{Conf["LDAPMASTER"]} -b #{@@monitored_entry} -s base -LLL +`.each_line do |line|
+            case line
+	    when /entryCSN: (.+)/
+              @@latest_entryCSN = $1
+	    end
+	  end
+	  UltraPossumHosts.each do |host|
+	    case host.entryCSN
+	    when @@latest_entryCSN
+	      host.repl_sign.on(Green)
+	    when ""
+              host.repl_sign.off
+	    else
+	      host.repl_sign.on(Yellow)
+	    end
+	  end
+        end
+
+	def UltraPossumHost.monitored_entry
+	  @@monitored_entry
+	end
+	
+	def UltraPossumHost.latest_entryCSN
+	  @@latest_entryCSN
+	end
+
         def update
 	  snmp
 	  monitor_entry
@@ -137,12 +168,22 @@
 
         def monitor_entry
 	  @entryCSN = ""
-	  `ldapsearch -x -h #{@host} -b  cn=u0001,o=ultrapossum -s base -LLL +`.each_line do |line|
+	  return if ! avail?
+	  `ldapsearch -l 1 -x -h #{@host} -b #{@@monitored_entry} -s base -LLL +`.each_line do |line|
             case line
 	    when /entryCSN: (.+)/
               @entryCSN = $1
 	    end
 	  end
+	  UltraPossumHost.update_latest_entryCSN
+          case @entryCSN
+	  when @@latest_entryCSN
+            @repl_sign.on(Green)
+	  when ""
+	    @repl_sign.off
+	  else
+	    @repl_sign.on(Red)
+	  end
 	end
 
         def snmp
@@ -186,39 +227,40 @@
           @sign.on(c)
         end
 
+        def avail?
+          return true if @status == "STANDBY" || @status == "ACTIVE" || @status == "RUN"
+	  return false
+	end
+
         attr_accessor :status, :pid, :since, :entryCSN
 
       end
 
+      Conf = ::UltraPossum::Config.new
       UltraPossumHosts = []
       begin
         hash = {}
-        `ultrapossum-config get MASTER BACKUP SYNCBACKUPS`.each_line do |line|
-        host = nil
-        case line
-          when /(MASTER|BACKUP|SYNCBACKUPS)="(.+)"\n/
-            $2.split(' ').each do |s|
-              host = UltraPossumHost.new(s,"master")
-              if hash[s].nil?
-	        UltraPossumHosts << host
-		Hosts << host
-	        hash[s] = host
-              end
-	    end
-          end
+	ary =  [ Conf["MASTER"], Conf["BACKUP"], Conf["SYNCBACKUPS"] ]
+	ary.each do |val|
+	  next if val.nil?
+          host = nil
+          val.split(' ').each do |s|
+            host = UltraPossumHost.new(s,"master")
+            if hash[s].nil?
+	      UltraPossumHosts << host
+              Hosts << host
+	      hash[s] = host
+            end
+	  end
         end
-	`ultrapossum-config get SLAVES`.each_line do |line|
-	  host = nil
-	  case line
-	  when /SLAVES="(.+)"\n/
-	    $1.split(' ').each do |s|
-	      host = UltraPossumHost.new(s,"slave")
-              if hash[s].nil?
-	        @row[host] =****@list*****
-	        UltraPossumHosts << host
-		Hosts << host
-	        hash[s] = host
-              end
+	if ! Conf["SLAVES"].nil?
+	  Conf["SLAVES"].split(' ').each do |s|
+	    host = UltraPossumHost.new(s,"slave")
+            if hash[s].nil?
+	      @row[host] =****@list*****
+	      UltraPossumHosts << host
+	      Hosts << host
+	      hash[s] = host
 	    end
 	  end
 	end
@@ -315,9 +357,14 @@
         end
 
         def update(host)
-          @list.set_value(@row[host], 1, host.host)
-          @list.set_value(@row[host], 2, host.type)
-          @list.set_value(@row[host], 4, host.entryCSN)
+	  UltraPossumHosts.each do |host|
+            @list.set_value(@row[host], 0, host.repl_sign.to_s )
+            @list.set_value(@row[host], 1, host.host)
+            @list.set_value(@row[host], 2, host.type)
+            @list.set_value(@row[host], 4, host.entryCSN)
+	  end
+          @glade["monitored_entry"].set_text(UltraPossumHost::monitored_entry)
+          @glade["latest_entrycsn"].set_text(UltraPossumHost::latest_entryCSN)
 	end
 
       end



Ultrapossum-cvs メーリングリストの案内
Back to archive index