Added skip_values operator and documentation (#10419)

* more operators

* os_schema

* discovery_schema

* doc

* doc
This commit is contained in:
PipoCanaja 2019-07-09 16:47:02 +02:00 committed by Neil Lathwood
parent 164f3a096a
commit 71da38cdf5
4 changed files with 42 additions and 2 deletions

View File

@ -145,6 +145,22 @@ $index="1.20", then $subindex0="1" and $subindex1="20".
value: 4 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 If you aren't able to use yaml to perform the sensor discovery, you
will most likely need to use Advanced health discovery. will most likely need to use Advanced health discovery.

View File

@ -314,12 +314,24 @@ function compare_var($a, $b, $comparison = '=')
return $a < $b; return $a < $b;
case "contains": case "contains":
return str_contains($a, $b); return str_contains($a, $b);
case "not_contains":
return !str_contains($a, $b);
case "starts": case "starts":
return starts_with($a, $b); return starts_with($a, $b);
case "not_starts":
return !starts_with($a, $b);
case "ends": case "ends":
return ends_with($a, $b); return ends_with($a, $b);
case "not_ends":
return !ends_with($a, $b);
case "regex": case "regex":
return (bool)preg_match($b, $a); 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: default:
return false; return false;
} }

View File

@ -444,7 +444,13 @@
"starts", "starts",
"ends", "ends",
"contains", "contains",
"regex" "regex",
"not_starts",
"not_ends",
"not_contains",
"not_regex",
"in_array",
"not_in_array"
] ]
} }
} }

View File

@ -502,7 +502,13 @@
"starts", "starts",
"ends", "ends",
"contains", "contains",
"regex" "regex",
"not_starts",
"not_ends",
"not_contains",
"not_regex",
"in_array",
"not_in_array"
] ]
} }
} }