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

def monitored(name, device_class=None, collector='localhost', prod_state=None):
    '''
    Ensure a device is monitored. The 'name' given will be used for Zenoss device name and should be resolvable.

    .. code-block:: yaml

        enable_monitoring:
          zenoss.monitored:
            - name: web01.example.com
            - device_class: /Servers/Linux
            - collector: localhost
            - prod_state: 1000
    '''

    ret = {}
    ret['name'] = name

    # If device is already monitored, return early
    device = __salt__['zenoss.find_device'](name)
    if device:
        ret['result'] = True
        ret['changes'] = None
        ret['comment'] = '{0} is already monitored'.format(name)

        # if prod_state is set, ensure it matches with the current state
        if prod_state is not None and device['productionState'] != prod_state:
            if __opts__['test']:
                ret['comment'] = '{0} is already monitored but prodState will be updated'.format(name)
                ret['result'] = None
            else:
                __salt__['zenoss.set_prod_state'](prod_state, name)
                ret['comment'] = '{0} is already monitored but prodState was updated'.format(name)

            ret['changes'] = {
                'old': 'prodState == {0}'.format(device['productionState']),
                'new': 'prodState == {0}'.format(prod_state)
                }
        return ret

    # Device not yet in Zenoss
    if __opts__['test']:
        ret['comment'] = 'The state of "{0}" will be changed.'.format(name)
        ret['changes'] = {'old': 'monitored == False', 'new': 'monitored == True'}
        ret['result'] = None
        return ret

    # Add and check result
    if __salt__['zenoss.add_device'](name, device_class, collector, prod_state):
        ret['result'] = True
        ret['changes'] = {'old': 'monitored == False', 'new': 'monitored == True'}
        ret['comment'] = '{0} has been added to Zenoss'.format(name)
    else:
        ret['result'] = False
        ret['changes'] = None
        ret['comment'] = 'Unable to add {0} to Zenoss'.format(name)
    return ret