Ad Widget

Collapse

Use value mappings in LLD macro or item protoype

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fwilke
    Junior Member
    • Mar 2024
    • 5

    #1

    Use value mappings in LLD macro or item protoype

    Hello,

    I followed this forum for a while and find many helpful answers.

    Now I have a specific problem. In order to create items through LLD I extract a JSON like this:

    Code:
    [
        {
            "ChannelsInstalled": "48",
            "@CID": "sw/6/0/1",
            "ChannelsInUse": "1",
            "ResourceType": "1"
        },
        {
            "ChannelsInstalled": "32",
            "@CID": "sw/6/0/2",
            "ChannelsInUse": "0",
            "ResourceType": "2"
        },
        {
            "ChannelsInstalled": "6",
            "@CID": "sw/6/0/3",
            "ChannelsInUse": "0",
            "ResourceType": "3"
        },
        {
            "ChannelsInstalled": "0",
            "@CID": "sw/6/0/4",
            "ChannelsInUse": "0",
            "ResourceType": "4"
        },
        {
            "ChannelsInstalled": "128",
            "@CID": "sw/6/0/5",
            "ChannelsInUse": "0",
            "EmbeddedResource": {
                "@CID": "sw/6/0/5/5",
                "ChannelsInUse": "0",
                "ResourceType": "7"
            },
            "FirstBankSize": "64",
            "ResourceType": "5"
        }
    ]
    I woul like to create an item prototype to have 5 items in this case, each identified by "ResourceType" (EmbeddedResource will be ignored).

    So far not a problem. But each ResourceType (Number) has an equivalent name:

    DataChannel=1,
    VCMChannel=2,
    VMChannel=3,
    ModemChannel=4,
    ConferenceChannel=5,
    EmbeddedChannel=6,
    HighQualityConferenceChannel=7,
    OutdialerVMChannel=8,
    RTPMediaChannel=9,​

    I would like to have those names to be part of the item's name. Therefore I would like to have i.e. a LLD Macros like {#RESNAME} -> .$.ResourceType.[mappedvalue(RasourceType)].

    I hope you get what I mean. If "ResourceType" equals 1, the macro {#RESNAME} should be "DataChannel"

    Is this possible? Or is there another idea, how I can get the resource name into the item name?

    Thanks in advance, Florian
  • fwilke
    Junior Member
    • Mar 2024
    • 5

    #2
    My workaround is to add the following to Preprocessing:

    Click image for larger version

Name:	image.png
Views:	280
Size:	43.4 KB
ID:	480233
    The part of the JSON with the ResourceType and it's number is Replaces by itself and the ResourceName.

    But this doesn't scale if there are i.e. 100 types for other values.

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4806

      #3
      There is no valuemap option to be applied to LLD macros. You can use JS preprocessing and do replacements (or adding additional value to json) there based on your values. After that you can use that LLD macro as you need.

      Comment

      • fwilke
        Junior Member
        • Mar 2024
        • 5

        #4
        Puuh... I will check what I can do.

        Comment

        Working...