Welcome to LQ!!
What have you tried? Once we know where you are, it's easier to give the right kind of advice.
SED will do this, and I'm pretty sure AWK will also.
With SED, the basic drill is this:
when you see "device hostname", send the line to the hold register(h), get the next line, and
append to the hold register (H)
Then, get (g) the contents of hold, strip out the "\n" (newline), and print
The final command would key off of "OK" and simply remove the line.
Really good SED tutorial here:
http://www.grymoire.com/Unix/Sed.html