import tempfile


def get_config(nagios_conf, events=False, service_perf=False, host_perf=False, tags=None):
    """
    Helper to generate a valid Nagios configuration
    """
    tags = [] if tags is None else tags

    NAGIOS_CFG = tempfile.NamedTemporaryFile(mode="a+b")
    NAGIOS_CFG.write(nagios_conf)
    NAGIOS_CFG.flush()

    CONFIG = {
        'instances': [
            {
                'nagios_conf': NAGIOS_CFG.name,
                'collect_events': events,
                'collect_service_performance_data': service_perf,
                'collect_host_performance_data': host_perf,
                'tags': list(tags),
            }
        ]
    }

    return CONFIG, NAGIOS_CFG