def alerts_edit(alert_id): hosts = Host.query.all() host_groups = HostGroup.query.all() services = Service.query.all() checks = Check.query.all() plugins = Plugin.query.all() alert = Alert.query.get(alert_id) module_options_list = AlertModuleOption.query.filter( AlertModuleOption.alert_id==alert_id) alert_modules = get_alert_modules() module_options = {} for option in module_options_list: module_options[option.key] = option.value if not alert: abort(404) # Generate a list of tuples of state and it's human readable name ordered # by priority, highest first hp = Host.health_priorities states = [] for state, priority in reversed( sorted(hp.items(), key=operator.itemgetter(1))): states.append((state, state.replace("_", " ").title())) return render_template("alert-form.html", nav_section="alerts", section="Alerts", title="Edit Alert", method="edit", hosts=hosts, host_groups=host_groups, services=services, checks=checks, states=states, plugins=plugins, alert=alert, module_options=module_options, alert_modules=alert_modules)
def alerts_edit(alert_id): hosts = Host.query.all() host_groups = HostGroup.query.all() services = Service.query.all() checks = Check.query.all() plugins = Plugin.query.all() alert = Alert.query.get(alert_id) module_options_list = AlertModuleOption.query.filter( AlertModuleOption.alert_id==alert_id) alert_modules = get_alert_modules() module_options = {} for option in module_options_list: module_options[option.key] = option.value if not alert: abort(404) # Generate a list of tuples of state and it's human readable name ordered # by priority, highest first hp = Host.health_priorities states = [] for state, priority in reversed( sorted(hp.items(), key=operator.itemgetter(1))): states.append((state, state.replace("_", " ").title())) return render_template("alert-form.html", nav_section="alerts", section="Alerts", title="Add Alert", method="edit", hosts=hosts, host_groups=host_groups, services=services, checks=checks, states=states, plugins=plugins, alert=alert, module_options=module_options, alert_modules=alert_modules)
def alerts_add(): hosts = Host.query.all() host_groups = HostGroup.query.all() services = Service.query.all() checks = Check.query.all() plugins = Plugin.query.all() alert_modules = get_alert_modules() # Generate a list of tuples of state and it's human readable name ordered # by priority, highest first hp = Host.health_priorities states = [] for state, priority in reversed( sorted(hp.items(), key=operator.itemgetter(1))): states.append((state, state.replace("_", " ").title())) return render_template("alert-form.html", nav_section="alerts", section="Alerts", title="Add Alert", method="add", hosts=hosts, host_groups=host_groups, services=services, checks=checks, states=states, plugins=plugins, alert_modules=alert_modules)