Support and/or/negate filters

master
René Jochum 4 years ago
parent 7f29798b42
commit bdb73f7a66

4
debian/changelog vendored

@ -1,8 +1,8 @@
lql-api (0.0.12-alpha) UNRELEASED; urgency=medium
lql-api (0.0.12-beta) UNRELEASED; urgency=medium
* Add hosts_* filter, change service_* filter
-- René Jochum <rene@webmeisterei.com> Mon, 05 Oct 2020 02:22:54 +0200
-- René Jochum <rene@webmeisterei.com> Thu, 08 Oct 2020 02:34:22 +0200
lql-api (0.0.11-alpha) UNRELEASED; urgency=medium

@ -30,6 +30,7 @@ func init() {
"display_name",
"description",
"plugin_output",
"comments",
}
v1TableFilters = make(map[string][]string, 6)
@ -38,6 +39,7 @@ func init() {
"Filter: scheduled_downtime_depth = 0",
"Filter: host_scheduled_downtime_depth = 0",
"Filter: host_state = 0",
"And: 4",
}
v1TableFilters["services_unhandled"] = []string{
"Filter: state > 0",
@ -45,25 +47,30 @@ func init() {
"Filter: host_scheduled_downtime_depth = 0",
"Filter: acknowledged = 0",
"Filter: host_state = 0",
"And: 5",
}
v1TableFilters["services_stale"] = []string{
"Filter: service_staleness >= 1.5",
"Filter: host_scheduled_downtime_depth = 0",
"Filter: service_scheduled_downtime_depth = 0",
"And: 3",
}
v1TableFilters["hosts_problems"] = []string{
"Filter: state >= 0",
"Filter: state > 0",
"Filter: scheduled_downtime_depth = 0",
"And: 3",
}
v1TableFilters["hosts_unhandled"] = []string{
"Filter: state > 0",
"Filter: scheduled_downtime_depth = 0",
"Filter: acknowledged = 0",
"And: 3",
}
v1TableFilters["hosts_stale"] = []string{
"Filter: host_staleness >= 1.5",
"Filter: host_scheduled_downtime_depth = 0",
"And: 2",
}
}
@ -117,7 +124,11 @@ func v1TableGet(c *gin.Context, params *v1TableGetParams) ([]gin.H, error) {
filters = append(filters, addFilters...)
continue
}
if filter[0:7] != "Filter:" || filter[0:7] != "NEGATE:" || filter[0:3] != "OR:" || filter[0:4] != "AND:" {
if !strings.HasPrefix(filter, "Filter:") &&
!strings.HasPrefix(filter, "Negate:") &&
!strings.HasPrefix(filter, "Or:") &&
!strings.HasPrefix(filter, "And:") {
return nil, fmt.Errorf("Invalid Filter '%s' given", filter)
}

Loading…
Cancel
Save