Masato Taruishi
taru****@users*****
2004年 9月 17日 (金) 15:35:05 JST
=================================================================== RCS file: demo/haviewer/lib/haviewer/ultrapossum.rb,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- demo/haviewer/lib/haviewer/ultrapossum.rb 2004/09/16 06:04:43 1.9 +++ demo/haviewer/lib/haviewer/ultrapossum.rb 2004/09/17 06:35:05 1.10 @@ -4,15 +4,14 @@ class UltraPossumHost < Host - OID = "private.12345" # .2.101.1" - OID_STATUS = OID + ".1.1.0" - OID_PID = OID + ".1.2.0" - OID_SINCE = OID + ".1.3.0" - @@conf = ::UltraPossum::Config.new @@latest_entryCSN = "" @@monitored_entry = "cn=u0001,#{@@conf["SUFFIX"]}" + STATUS = ".1.1.0" + PID = ".1.2.0" + SINCE = ".1.3.0" + def UltraPossumHost.update_latest_entryCSN `ldapsearch -l 1 -x -h #{UltraPossumHost.conf["LDAPMASTER"]} -b #{@@monitored_entry} -s base -LLL +`.each_line do |line| case line @@ -78,20 +77,25 @@ end def snmp + status = @@conf["SNMP_MIB"] + STATUS statusbuf = nil + pid = @@conf["SNMP_MIB"] + PID pidbuf = nil + since = @@conf["SNMP_MIB"] + SINCE sincebuf = nil - puts "snmpget -v1 -t 3 -c ultrapossum #{@host} #{OID_STATUS} #{OID_PID} #{OID_SINCE}" if $DEBUG - buf = `snmpget -v1 -t 3 -c ultrapossum #{@host} #{OID_STATUS} #{OID_PID} #{OID_SINCE}` + + snmpget = "snmpget -On -v1 -t 3 -c ultrapossum #{@host} #{status} #{pid} #{since}" + puts snmpget if $DEBUG + buf = `#{snmpget}` buf.each_line do |line| case line - when /#{OID_STATUS}/ + when /#{status}/ statusbuf = line.gsub(/^[^"]+"(.*)"\n/, '\1') statusbuf = "-----" if statusbuf.size == 0 - when /#{OID_PID}/ + when /#{pid}/ pidbuf = line.gsub(/^[^"]+"(.*)"\n/, '\1') pidbuf = "-----" if pidbuf.size == 0 - when /#{OID_SINCE}/ + when /#{since}/ sincebuf = line.gsub(/^[^"]+"(.*)"\n/, '\1') sincebuf = "-----" if sincebuf.size == 0 end