Masato Taruishi
taru****@sourc*****
2004年 6月 23日 (水) 00:46:30 JST
=================================================================== RCS file: demo/haviewer/haviewer.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- demo/haviewer/haviewer.rb 2004/06/22 15:21:26 1.4 +++ demo/haviewer/haviewer.rb 2004/06/22 15:46:30 1.5 @@ -12,6 +12,9 @@ Column = ["S", "Host", "Type", "Status", "Pid", "Since", "I" ] Hosts = [] OID = "private.12345" # .2.101.1" + OID_STATUS = OID + ".2.101.1" + OID_PID = OID + ".3.101.1" + OID_SINCE = OID + ".4.101.1" Green = "#00FF00" DarkGreen = "#005500" @@ -74,13 +77,22 @@ end def snmp - @list.set_value(@row, 6, "\\") - buf = `snmpget -v1 -c ultrapossum #{@host} #{OID}.2.101.1` - @status = buf.gsub(/^[^"]+"(.+)"\n/, '\1') - @status = "-----" if****@statu***** == 0 - - @color = Yellow + buf = `snmpget -v1 -c ultrapossum #{@host} #{OID_STATUS} #{OID_PID} #{OID_SINCE}` + buf.each_line do |line| + case line + when /#{OID_STATUS}/ + @status = line.gsub(/^[^"]+"(.+)"\n/, '\1') + @status = "-----" if****@statu***** == 0 + when /#{OID_PID}/ + @pid = line.gsub(/^[^"]+"(.+)"\n/, '\1') + @pid = "-----" if****@pid***** == 0 + when /#{OID_SINCE}/ + @since = line.gsub(/^[^"]+"(.+)"\n/, '\1') + @since = "-----" if****@since***** == 0 + end + end + @color = "" case @status when "DEAD" @color = Red @@ -93,20 +105,6 @@ when "RUN" @color = Green end - - @list.set_value(@row, 0, HAViewer._icon(@color)) if****@statu***** - - @list.set_value(@row, 6, "|") - buf = `snmpget -v1 -c ultrapossum #{@host} #{OID}.3.101.1` - @pid = buf.gsub(/^[^"]+"(.+)"\n/, '\1') - @pid = "-----" if****@pid***** == 0 - - @list.set_value(@row, 6, "/") - buf = `snmpget -v1 -c ultrapossum #{@host} #{OID}.4.101.1` - @since = buf.gsub(/^[^"]+"(.+)"\n/, '\1') - @since = "-----" if****@since***** == 0 - - @list.set_value(@row, 6, "-") end