From: Expert Alart Date: 2013-07-26T19:01:41+09:00 Subject: Re: how to create structure like bellow I think i know why .... let me try to explain when i am doing snmp on 2 pdues.. ( directly command line not from ruby ) actuall value i get is : 3.60 4.60 So it will be : 8.20 group_by_row[get_row] += row_per_power_amp.to_i : its getting value : 7 and my way its getting : 8 so both way its not right ..... and we have 82 pdues so we losing amps on report ... bellow is the code : pdus.each do |pdu_name| puts pdu_name[:name] get_row= pdu_name[:name].match(/.*(\w\d\d\w).*$/).captures[0] puts "
" #total_power=0 power= `/usr/bin/snmpwalk -v 2c -OQ -c xxxx #{pdu_name[:name]} xxxxxxxx | awk '{print $3}'` row_per_power_amp=(power.to_i/10) # This is for "group_by_row" total_power=total_power.to_i + power.to_i # This is for manual output group_by_row[get_row] += row_per_power_amp.to_i end total_power_amp=(total_power.to_i/10) total_power_amp_dc=total_power_amp_dc.to_i + total_power_amp.to_i puts "
" puts "Total Power Uses Per racks (amps): #{total_power_amp} amps" end total_power_amp_per_dc=(total_power_amp_dc.to_i/10) Total Power for DC: #{total_power_amp_per_dc} i think they way i am storing values from snmp is not right .. ( floating point entry ) am i right ??? -- Posted via http://www.ruby-forum.com/.