Add timing to monitor loop and pull out database/output logic.