juju: moved collector code to collector.go.

related to #553 and #537.