Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename index_string to index:str2num #15916

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion LibreNMS/Device/YamlDiscovery.php
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) {
'index:str2num' => 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
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, `{{ $index:str2num }}` 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
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.{{ $index:str2num }}'
index: 'rlsCircuitPackCurrTemprature.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsAmpMode.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsState.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsGainMode.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsForcedShutdown.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsInCurrPower.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsInMinPower.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsInMaxPower.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsOutCurrPower.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsOutMinPower.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsOutMaxPower.{{ $index:str2num }}'
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.{{ $index:str2num }}'
index: 'rlsInventoryAmpsOpticalReturnLoss.{{ $index:str2num }}'
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
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.{{ $index:str2num }}'
group: RPM Probes
descr: '{{ $index }} Probe Loss'
index: 'jnxRpmResSumPercentLost.{{ $index }}'
Expand Down
4 changes: 2 additions & 2 deletions includes/definitions/discovery/solidserver.yaml
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.{{ $index:str2num }}'
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.{{ $index:str2num }}'
descr: '{{ $eipDhcpStatName }}'
rrd_type: 'COUNTER'
index: 'counter__{{ $index }}'
Expand Down
4 changes: 2 additions & 2 deletions misc/discovery_schema.json
Expand Up @@ -229,7 +229,7 @@
},
"num_oid": {
"type": "string",
"pattern": "^(\\.\\d+)+(\\.?\\{\\{ \\$index(.string)? \\}\\})?(\\.\\d+)*$"
"pattern": "^(\\.\\d+)+(\\.?\\{\\{ \\$index(:str2num)? \\}\\})?(\\.\\d+)*$"
},
"descr": {
"type": "string"
Expand Down Expand Up @@ -414,7 +414,7 @@
},
"num_oid": {
"type": "string",
"pattern": "^(\\.\\d+)+(\\.?\\{\\{ \\$index(.string)? \\}\\})?(\\.\\d+)*$"
"pattern": "^(\\.\\d+)+(\\.?\\{\\{ \\$index(:str2num)? \\}\\})?(\\.\\d+)*$"
},
"index": {
"type": ["integer", "string"]
Expand Down