def process_local_monitors():
    """Get all the monitor dicts and write out and local checks."""
    monitor_dicts = nrpe_helpers.MonitorsRelation().get_monitor_dicts()
    for monitor_src in monitor_dicts.keys():
        monitor_dict = monitor_dicts[monitor_src]
        if not (monitor_dict and "local" in monitor_dict["monitors"]):
            continue
        monitors = monitor_dict["monitors"]["local"]
        for checktype in monitors:
            for check in monitors[checktype]:
                render_nrpe_check_config(
                    nrpe_helpers.NRPECheckCtxt(
                        checktype,
                        monitors[checktype][check],
                        monitor_src,
                    ))
def process_user_monitors():
    """Collect the user defined local monitors from config."""
    if hookenv.config("monitors"):
        monitors = yaml.safe_load(hookenv.config("monitors"))
    else:
        return
    try:
        local_user_checks = monitors["monitors"]["local"].keys()
    except KeyError as e:
        hookenv.log("no local monitors found in monitors config: {}".format(e))
        return
    for checktype in local_user_checks:
        for check in monitors["monitors"]["local"][checktype].keys():
            check_def = nrpe_helpers.NRPECheckCtxt(
                checktype, monitors["monitors"]["local"][checktype][check],
                "user")
            render_nrpe_check_config(check_def)