def _status_query(query, hostname, enumerate=None, service=None):
    '''
    Send query along to Nagios.
    '''
    config = _config()

    data = None
    params = {
        'hostname': hostname,
        'query': query,
    }

    ret = {
        'result': False
    }

    if enumerate:
        params['formatoptions'] = 'enumerate'
    if service:
        params['servicedescription'] = service

    if config['username'] and config['password'] is not None:
        auth = (config['username'], config['password'],)
    else:
        auth = None

    try:
        result = salt.utils.http.query(
            config['url'],
            method='GET',
            params=params,
            decode=True,
            data=data,
            text=True,
            status=True,
            header_dict={},
            auth=auth,
            backend='requests',
            opts=__opts__,
        )
    except ValueError:
        ret['error'] = 'Please ensure Nagios is running.'
        ret['result'] = False
        return ret

    if result.get('status', None) == salt.ext.six.moves.http_client.OK:
        try:
            ret['json_data'] = result['dict']
            ret['result'] = True
        except __HOLE__:
            ret['error'] = 'Please ensure Nagios is running.'
    elif result.get('status', None) == salt.ext.six.moves.http_client.UNAUTHORIZED:
        ret['error'] = 'Authentication failed. Please check the configuration.'
    elif result.get('status', None) == salt.ext.six.moves.http_client.NOT_FOUND:
        ret['error'] = 'URL {0} was not found.'.format(config['url'])
    else:
        ret['error'] = 'Results: {0}'.format(result.text)

    return ret
dataset/ETHPy150Open saltstack/salt/salt/modules/nagios_rpc.py/_status_query