update gateway script to support m monitoring