I need a help to compact my bellow code or make it write a smart way as
i follow this style , for 100 record i will have to do this 100 times!!
Basically, i am executing a sql command its giving me data like bellow.
now i need to present that in our monitoring system in a table and need
to set threshold for each variables
the monitoring system will generate the html from “msg”
Now the way i am doing, if i have 100 Records i will go MAD!! ,
so i need some advise how to make it more smart and compact.
by using some smart LOOP HASH…
Can any one please give me guide …
bellow is my code :-
output=come command
its output like bellow :-
Field1 56 80 100
Field2 44 33 44
Field3 55 55 66
Field4 3 50 200
Currently i am doing this way
field1=Hash.new
field2=Hash.new
…
…
output.each_line do |line|
if line =~ /Field1/
cn = line.split(' ')
field1["Total"]=cn[1]
if field1["Total"] > 50
field1["Total_status"]="Red"
else
field1["Total_status"]="Green"
end
field1["Fail"]=cn[2]
if field2["Fail"] > 50
field1["Fail_status"]="Red"
else
field1["Fail_status"]="Green"
end
field1["Success"]=cn[3]
if field1["Success"] > 50
field1["Success_status"]="Red"
else
field1["Success_status"]="Green"
end
end
if line =~ /Field2/
...............
end
end
MSG="
| field1[“Total”] field1[“Total_status”] <t/d> |
field1[“Fail”] field1[“Fail_status”] |
field1[“Success”] | field2[“Success”] |