diff --git a/doc/Developing/os/Health-Information.md b/doc/Developing/os/Health-Information.md index b009cde4f5..400eb706cf 100644 --- a/doc/Developing/os/Health-Information.md +++ b/doc/Developing/os/Health-Information.md @@ -145,6 +145,22 @@ $index="1.20", then $subindex0="1" and $subindex1="20". value: 4 ``` +> ``` op ``` can be any of the following operators : +> +> =, !=, ==, !==, <=, >=, <, >, +> starts, ends, contains, regex, in_array, not_starts, +> not_ends, not_contains, not_regex, not_in_array +> +> Example: + +```yaml + skip_values: + - + oid: sensorName + op: 'not_in_array' + value: ['sensor1', 'sensor2'] +``` + If you aren't able to use yaml to perform the sensor discovery, you will most likely need to use Advanced health discovery. diff --git a/includes/functions.php b/includes/functions.php index aae7fdd38f..99902dea9f 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -314,12 +314,24 @@ function compare_var($a, $b, $comparison = '=') return $a < $b; case "contains": return str_contains($a, $b); + case "not_contains": + return !str_contains($a, $b); case "starts": return starts_with($a, $b); + case "not_starts": + return !starts_with($a, $b); case "ends": return ends_with($a, $b); + case "not_ends": + return !ends_with($a, $b); case "regex": return (bool)preg_match($b, $a); + case "not regex": + return !((bool)preg_match($b, $a)); + case "in_array": + return in_array($a, $b); + case "not_in_array": + return !in_array($a, $b); default: return false; } diff --git a/misc/discovery_schema.json b/misc/discovery_schema.json index 2785a82aeb..75652d1fcb 100644 --- a/misc/discovery_schema.json +++ b/misc/discovery_schema.json @@ -444,7 +444,13 @@ "starts", "ends", "contains", - "regex" + "regex", + "not_starts", + "not_ends", + "not_contains", + "not_regex", + "in_array", + "not_in_array" ] } } diff --git a/misc/os_schema.json b/misc/os_schema.json index fbdc4e123a..899b386f81 100644 --- a/misc/os_schema.json +++ b/misc/os_schema.json @@ -502,7 +502,13 @@ "starts", "ends", "contains", - "regex" + "regex", + "not_starts", + "not_ends", + "not_contains", + "not_regex", + "in_array", + "not_in_array" ] } }