Hi,
in the HW/SW Inventory system we have to deal with two tasks:
- Adding (unsorted) data, ie.
Attributes
or TableRow
, via inventory plug-ins
- Specify order and representation of this data via so called
display hints
Unfortunatelly we don’t have docs about the second part but I try to explain it with an example:
We add data in our inventory plug-in:
def inventory(...):
yield Attributes(
path=["path", "to", "node1"],
inventory_attributes={
"key_1": "value 1",
"key_2": "value 2",
...
},
)
for entry in a_list:
yield TableRow(
path=["path", "to", "node2"],
# key columns are used to identify a row
key_columns={
"key_col_1": "value 1",
"key_col_2": "value 2",
...
},
inventory_columns={
"key_3": "value 3",
"key_4": "value 4",
...
},
)
Then we can specify the representation of this data:
# OMD[<SITE>]:~/local/share/check_mk/web/plugins/views$ ll my_display_hints.py
from cmk.gui.views.inventory.registry import inventory_displayhints
inventory_displayhints.update({
# For attributes
".path.to.node1.": {
"title": "Node 1",
"keyorder": ["key_2", "key_1"],
},
".path.to.node1.key_1": {
"title": "Key 1",
},
".path.to.node1.key_2": {
"title": "Key 2",
},
...
# For table rows
".path.to.node2:": {
"title": "Node 2",
"keyorder": ["key_col_2", "key_col_1", "key_4", "key_3"],
},
".path.to.node2:*.key_col_1": {
"title": "Key column 1",
},
".path.to.node2:*.key_col_2": {
"title": "Key column 2",
},
".path.to.node2:*.key_3": {
"title": "Key 3",
},
".path.to.node2:*.key_4": {
"title": "Key 4",
},
})
- If a path ends with a
.
(dot) then it’s a node
- If a related path ends with a name and then it’s an attribute
- If a path ends with a
:
(colon) then it’s a table
- If a related path ends with
*.
+ a name and then it’s a column
- The
keyorder
specifies the order of the columns
The path specs are not very readable or obvious ![:frowning: :frowning:](https://forum.checkmk.com/images/emoji/twitter/frowning.png?v=12)
There are also other fields which can be specified, see
OMD[<SITE>]:~/lib/check_mk/gui/views/inventory$ ll builtin_display_hints.py
We may add an API for the second part in the future which will be documentated as we do with other APIs like the agent-based
or graphing
.
I hope this helps you.
Feel free to ask further questions.
BG
Simon