MetricsHub
MetricsHub Community Connectors 1.0.22
-
Home
- Connector Developer Guide Computes 24
convert (Compute)
When To Use
Use convert for one of two fixed conversions on a column:
hex2Decturns a hexadecimal string into its decimal value. The engine strips a0xprefix, colons, and whitespace before parsing, so0x1F,1f, and1A:2B:3Call convert. Use it before arithmetic computes (multiply,divide…) orperBitTranslation[1], which require decimal input.array2SimpleStatuscollapses a pipe-separated array of statuses (ok,degraded,failed, case-insensitive) into the single worst status. It is the standard follow-up toarrayTranslate[2] when a device reports several status codes for one component.
Syntax
sources:
enclosureStatus:
# Enclosure;Vendor;Model;SerialNumber;Status;StatusInformation;PowerConsumption
type: ipmi
computes:
- type: keepOnlyMatchingLines
column: 1
valueList: enclosure
- type: convert
column: 5
conversion: array2SimpleStatus
Properties
| Property | Required | Default | Description |
|---|---|---|---|
type |
Yes | None | convert. |
column |
Yes | None | 1-based index of the column to convert in place. |
conversion |
Yes | None | hex2Dec or array2SimpleStatus. |
Table Transformation Example
With conversion: array2SimpleStatus on column 2 (simplified table):
Input
| DeviceID | StatusArray |
|---|---|
| encl-0 | ok|degraded|ok |
| encl-1 | ok|failed |
| encl-2 | ok |
Result
| DeviceID | Status |
|---|---|
| encl-0 | degraded |
| encl-1 | failed |
| encl-2 | ok |
Severity order is failed > degraded > ok; values that are none of the three are ignored, and a cell containing no recognized status becomes UNKNOWN.
With conversion: hex2Dec, a cell containing 0x1F becomes 31, and 1A:2B becomes 6699.
Recommended Pattern
- Chain
arrayTranslate(codes took/degraded/failed) thenconvertwitharray2SimpleStatusto derive one monitorable state from a status array, as WinStorageSpaces does. - Apply
hex2Decimmediately after acquisition so every downstream compute and the mapping deal with plain decimal numbers. - Keep a
duplicateColumncopy of the raw array if you also want the detail as informational text.
Common Mistakes
- Feeding
array2SimpleStatusuntranslated numeric codes: onlyok,degraded, andfailedtokens are recognized, so raw codes yieldUNKNOWN. Translate first. - Applying
hex2Decto a value that is not valid hexadecimal: the row is left unchanged and a warning is logged, which can go unnoticed. - Confusing
conversionvalues: they are camelCase (hex2Dec,array2SimpleStatus), nothex2dec. - Counting columns from 0:
columnis 1-based, like everywhere else in connectors.
Community Examples
- IpmiTool[3]
- LinuxIpmiTool[4]
- WinStorageSpaces[5]
From WinStorageSpaces, included directly from the connector source:
# Convert the array of status to a simple status (keep the worse one)
- type: convert
column: 3
conversion: array2SimpleStatus
convert
compute
hex2Dec
array2SimpleStatus
worst status
metricshub
community
connector
hardware
system
Links:
- [1] translate-per-bit.html
- [2] array-translate.html
- [3] https://github.com/metricshub/community-connectors/blob/main/src/main/connector/hardware/IpmiTool/IpmiTool.yaml
- [4] https://github.com/metricshub/community-connectors/blob/main/src/main/connector/hardware/LinuxIpmiTool/LinuxIpmiTool.yaml
- [5] https://github.com/metricshub/community-connectors/blob/main/src/main/connector/hardware/WinStorageSpaces/WinStorageSpaces.yaml
Search Results for {{siteSearch | truncate:'50'}}
{{resultArray.length}}
Searching...
No results.
