open(url, :http_basic_authentication=>[user, pwd]) do |f|
f.each do |line|
if three_liners>0
three_liners=three_liners+1
if three_liners==2
print "Memoryusagepercentage.value "
end
if three_liners==3
print "Memoryusage.value "
end
if three_liners==4
print "Memorymax.value "
end
print line.gsub!(/[^0-9.]/s,"")
print "\n"
end
if one_liners>0
one_liners=one_liners+1
print "#{key}.value "
print line.gsub!(/[^0-9.]/s,"")
print "\n"
end
if one_liners>1
line=""
one_liners=0
end
if three_liners>3
line=""
three_liners=0
end
if line =~ /Memory usage/
key=line.gsub!(/(<[^>]*>)|\n|\t| /s,"")
three_liners=three_liners+1
end
if line =~ /<td class="e">Free memory/ || line =~ /<td class="e">Cached scripts/ || line =~ /<td class="e">Removed scripts/ || line =~ /<td class="e">Cached keys/