Feature: skip_value can check OID existance (#11822)

* exists for skip_values

* AR routers are using another logic for SFPs Power

* schemas

* tests
This commit is contained in:
PipoCanaja
2020-06-14 16:21:22 +02:00
committed by GitHub
parent 529f364ada
commit 15fe63d6b1
7 changed files with 4924 additions and 6 deletions

View File

@@ -161,7 +161,7 @@ $index="1.20", then $subindex0="1" and $subindex1="20".
> >
> =, !=, ==, !==, <=, >=, <, >, > =, !=, ==, !==, <=, >=, <, >,
> starts, ends, contains, regex, in_array, not_starts, > starts, ends, contains, regex, in_array, not_starts,
> not_ends, not_contains, not_regex, not_in_array > not_ends, not_contains, not_regex, not_in_array, exists
> >
> Example: > Example:
@@ -173,6 +173,14 @@ $index="1.20", then $subindex0="1" and $subindex1="20".
value: ['sensor1', 'sensor2'] value: ['sensor1', 'sensor2']
``` ```
```yaml
skip_values:
-
oid: sensorOptionalOID
op: 'exists'
value: false
```
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

@@ -218,6 +218,33 @@ modules:
oid: hwEntityAdminStatus oid: hwEntityAdminStatus
op: '=' op: '='
value: 12 value: 12
-
oid: hwOpticalModuleInfoTable
value: hwEntityOpticalRxPower
num_oid: '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.8.{{ $index }}'
descr: '{{ $entPhysicalName }} Rx'
entPhysicalIndex: '{{ $index }}'
entPhysicalIndex_measured: ports
index: 'rx-{{ $index }}'
divisor: 100
group: '{{ $entPhysicalName }}'
skip_values:
-
oid: hwEntityOpticalRxPower
op: '>'
value: 0
-
oid: hwEntityAdminStatus
op: '='
value: 12
-
oid: hwEntityOpticalLaneRxPower
op: 'exists'
value: true
-
oid: hwEntityOpticalBiasCurrent
op: '='
value: 0
- -
oid: hwOpticalModuleInfoTable oid: hwOpticalModuleInfoTable
value: hwEntityOpticalTxPower value: hwEntityOpticalTxPower
@@ -237,6 +264,33 @@ modules:
oid: hwEntityAdminStatus oid: hwEntityAdminStatus
op: '=' op: '='
value: 12 value: 12
-
oid: hwOpticalModuleInfoTable
value: hwEntityOpticalTxPower
num_oid: '.1.3.6.1.4.1.2011.5.25.31.1.1.3.1.9.{{ $index }}'
descr: '{{ $entPhysicalName }} Tx'
entPhysicalIndex: '{{ $index }}'
entPhysicalIndex_measured: ports
index: 'tx-{{ $index }}'
divisor: 100
group: '{{ $entPhysicalName }}'
skip_values:
-
oid: hwEntityOpticalTxPower
op: '>'
value: 0
-
oid: hwEntityAdminStatus
op: '='
value: 12
-
oid: hwEntityOpticalLaneTxPower
op: 'exists'
value: true
-
oid: hwEntityOpticalBiasCurrent
op: '='
value: 0
- -
oid: hwOpticalModuleInfoTable oid: hwOpticalModuleInfoTable
value: hwEntityOpticalLaneRxPower value: hwEntityOpticalLaneRxPower

View File

@@ -337,6 +337,8 @@ function compare_var($a, $b, $comparison = '=')
return in_array($a, $b); return in_array($a, $b);
case "not_in_array": case "not_in_array":
return !in_array($a, $b); return !in_array($a, $b);
case "exists":
return isset($a) == $b;
default: default:
return false; return false;
} }

View File

@@ -62,7 +62,7 @@
"$ref": "#/definitions/comparison" "$ref": "#/definitions/comparison"
}, },
"value": { "value": {
"type": ["integer", "string", "array"], "type": ["boolean", "integer", "string", "array"],
"items": { "items": {
"type": ["integer", "string"] "type": ["integer", "string"]
} }
@@ -204,7 +204,7 @@
"$ref": "#/definitions/comparison" "$ref": "#/definitions/comparison"
}, },
"value": { "value": {
"type": ["integer", "string", "array"], "type": ["boolean", "integer", "string", "array"],
"items": { "items": {
"type": ["integer", "string"] "type": ["integer", "string"]
} }
@@ -385,7 +385,7 @@
"$ref": "#/definitions/comparison" "$ref": "#/definitions/comparison"
}, },
"value": { "value": {
"type": ["integer", "string", "array"], "type": ["boolean", "integer", "string", "array"],
"items": { "items": {
"type": ["integer", "string"] "type": ["integer", "string"]
} }
@@ -468,7 +468,8 @@
"not_contains", "not_contains",
"not_regex", "not_regex",
"in_array", "in_array",
"not_in_array" "not_in_array",
"exists"
] ]
} }
} }

View File

@@ -533,7 +533,8 @@
"not_contains", "not_contains",
"not_regex", "not_regex",
"in_array", "in_array",
"not_in_array" "not_in_array",
"exists"
] ]
} }
} }

3732
tests/data/vrp_ar169sfp.json Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff