Skip to content

Commit

Permalink
Rename index_string to str_index_as_numeric (#15916)
Browse files Browse the repository at this point in the history
* rename index_string to index:str2num

* rename to str_index_as_numeric
  • Loading branch information
PipoCanaja committed Jun 13, 2024
1 parent 3ad5bbc commit d48fa27
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion LibreNMS/Device/YamlDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static function replaceValues($name, $index, $count, $def, $pre_cache)
'count' => $count,
// we compute a numOid compatible version of index
// string length followed by ASCII of each char.
'index_string' => implode('.', array_map(function ($index) {
'str_index_as_numeric' => implode('.', array_map(function ($index) {
return strlen($index) . '.' . implode('.', unpack('c*', $index));
}, explode('.', $index))),
];
Expand Down
3 changes: 2 additions & 1 deletion doc/Developing/os/Health-Information.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ are as follows:
automatically by discovery process. This parameter is still required to
submit a pull request. This is the numerical OID that contains
`value`. This should usually include `{{ $index }}`.
In case the index is a string, `{{ $index_string }}` can be used instead.
In case the index is a string, `{{ $str_index_as_numeric }}` can be used instead and will convert
the string to the equivalent OID representation.
- `divisor` (optional): This is the divisor to use against the returned `value`.
- `multiplier` (optional): This is the multiplier to use against the returned `value`.
- `low_limit` (optional): This is the critical low threshold that
Expand Down
48 changes: 24 additions & 24 deletions includes/definitions/discovery/ciena-rls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ modules:
data:
-
oid: rlsCircuitPackCurrTemprature
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.1.1.1.29.{{ $index_string }}'
index: 'rlsCircuitPackCurrTemprature.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.1.1.1.29.{{ $str_index_as_numeric }}'
index: 'rlsCircuitPackCurrTemprature.{{ $str_index_as_numeric }}'
descr: '{{ $rlsCircuitPackCtype }} Slot {{ $index }}'
state:
data:
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsAmpMode
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.3.{{ $index_string }}'
index: 'rlsInventoryAmpsAmpMode.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.3.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsAmpMode.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Mode'
state_name: rlsInventoryAmpsAmpMode
Expand All @@ -34,8 +34,8 @@ modules:
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsState
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.4.{{ $index_string }}'
index: 'rlsInventoryAmpsState.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.4.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsState.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier State'
state_name: rlsInventoryAmpsState
Expand All @@ -48,8 +48,8 @@ modules:
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsGainMode
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.5.{{ $index_string }}'
index: 'rlsInventoryAmpsGainMode.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.5.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsGainMode.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Gain Mode'
state_name: rlsInventoryAmpsGainMode
Expand All @@ -59,8 +59,8 @@ modules:
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsForcedShutdown
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.6.{{ $index_string }}'
index: 'rlsInventoryAmpsForcedShutdown.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.6.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsForcedShutdown.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Forced Shutdown State'
state_name: rlsInventoryAmpsForcedShutdown
Expand All @@ -72,51 +72,51 @@ modules:
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsInCurrPower
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.48.{{ $index_string }}'
index: 'rlsInventoryAmpsInCurrPower.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.48.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsInCurrPower.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Input - Current'
low_limit: rlsInventoryAmpsInputLosThreshold
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsInMinPower
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.49.{{ $index_string }}'
index: 'rlsInventoryAmpsInMinPower.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.49.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsInMinPower.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Input - Minimum'
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsInMaxPower
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.50.{{ $index_string }}'
index: 'rlsInventoryAmpsInMaxPower.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.50.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsInMaxPower.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Input - Maximum'
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsOutCurrPower
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.51.{{ $index_string }}'
index: 'rlsInventoryAmpsOutCurrPower.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.51.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsOutCurrPower.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Output - Current'
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsOutMinPower
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.52.{{ $index_string }}'
index: 'rlsInventoryAmpsOutMinPower.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.52.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsOutMinPower.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Output - Minimum'
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsOutMaxPower
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.53.{{ $index_string }}'
index: 'rlsInventoryAmpsOutMaxPower.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.53.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsOutMaxPower.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Output - Maximum'
-
oid: rlsInventoryAmpsTable
value: rlsInventoryAmpsOpticalReturnLoss
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.54.{{ $index_string }}'
index: 'rlsInventoryAmpsOpticalReturnLoss.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.1271.4.1.1.1.2.1.1.1.54.{{ $str_index_as_numeric }}'
index: 'rlsInventoryAmpsOpticalReturnLoss.{{ $str_index_as_numeric }}'
descr: 'Slot {{ $subindex0 }} {{ $subindex1 }}'
group: 'Amplifier Optical Return Loss'
low_warn_limit: rlsInventoryAmpsOrlThreshold
Expand Down
2 changes: 1 addition & 1 deletion includes/definitions/discovery/junos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ modules:
-
oid: jnxRpmResultsSummaryTable
value: jnxRpmResSumPercentLost
num_oid: '.1.3.6.1.4.1.2636.3.50.1.2.1.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.2636.3.50.1.2.1.{{ $str_index_as_numeric }}'
group: RPM Probes
descr: '{{ $index }} Probe Loss'
index: 'jnxRpmResSumPercentLost.{{ $index }}'
Expand Down
4 changes: 2 additions & 2 deletions includes/definitions/discovery/solidserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ modules:
-
oid: eipDnsStatTable
value: eipDnsStatValue
num_oid: '.1.3.6.1.4.1.2440.1.4.2.3.1.3.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.2440.1.4.2.3.1.3.{{ $str_index_as_numeric }}'
descr: '{{ $eipDnsStatName }}'
index: 'counter__{{ $index }}'
rrd_type: 'COUNTER'
Expand Down Expand Up @@ -73,7 +73,7 @@ modules:
-
oid: eipDhcpStatTable
value: eipDhcpStatValue
num_oid: '.1.3.6.1.4.1.2440.1.3.2.22.1.3.{{ $index_string }}'
num_oid: '.1.3.6.1.4.1.2440.1.3.2.22.1.3.{{ $str_index_as_numeric }}'
descr: '{{ $eipDhcpStatName }}'
rrd_type: 'COUNTER'
index: 'counter__{{ $index }}'
Expand Down
4 changes: 2 additions & 2 deletions misc/discovery_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
},
"num_oid": {
"type": "string",
"pattern": "^(\\.\\d+)+(\\.?\\{\\{ \\$index(.string)? \\}\\})?(\\.\\d+)*$"
"pattern": "^(\\.\\d+)+(\\.?\\{\\{ \\$(index|str_index_as_numeric) \\}\\})?(\\.\\d+)*$"
},
"descr": {
"type": "string"
Expand Down Expand Up @@ -415,7 +415,7 @@
},
"num_oid": {
"type": "string",
"pattern": "^(\\.\\d+)+(\\.?\\{\\{ \\$index(.string)? \\}\\})?(\\.\\d+)*$"
"pattern": "^(\\.\\d+)+(\\.?\\{\\{ \\$(index|str_index_as_numeric) \\}\\})?(\\.\\d+)*$"
},
"index": {
"type": ["integer", "string"]
Expand Down

0 comments on commit d48fa27

Please sign in to comment.