<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def monitor(name):
    '''
    Get the summary from module monit and try to see if service is
    being monitored. If not then monitor the service.
    '''
    ret = {'result': None,
           'name': name,
           'comment': '',
           'changes': {}
           }
    result = __salt__['monit.summary'](name)

    try:
        for key, value in result.items():
            if 'Running' in value[name]:
                ret['comment'] = ('{0} is being being monitored.').format(name)
                ret['result'] = True
            else:
                if __opts__['test']:
                    ret['comment'] = 'Service {0} is set to be monitored.'.format(name)
                    ret['result'] = None
                    return ret
                __salt__['monit.monitor'](name)
                ret['comment'] = ('{0} started to be monitored.').format(name)
                ret['changes'][name] = 'Running'
                ret['result'] = True
                break
    except KeyError:
        ret['comment'] = ('{0} not found in configuration.').format(name)
        ret['result'] = False

    return ret