Ad Widget

Collapse

Discover VMware VMs -> Host prototypes -> add Group based on {#HV.ID} with .regsub

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cowa
    Junior Member
    • Jan 2023
    • 4

    #1

    Discover VMware VMs -> Host prototypes -> add Group based on {#HV.ID} with .regsub

    Hello,

    I would like to add a group to the "Discover VMware VMs".
    {#HV.ID} should use as a base, because I am not allowed to use regular user macros in LLD.

    For example, my {#HV.ID}:
    Code:
    esxi07.lan.company.org
    esxi06.lan.company.org
    esxi2.lan.company.local
    I now want to cut everything up to the first point.

    Wished result:
    Code:
    lan.company.org
    lan.company.org
    lan.company.local
    Unfortunately, all my attempts to do this with {{#HV.ID}.regsub(...)} failed.
    Is there someone who can create my regular expression for the REGSUB for me?​

    This was one of my many attempts:
    Code:
    {{#HV.ID}.regsub([a-zA-Z]+,(\.[a-zA-Z]+)+)}
    Alternatively, I would prefer if I could give the groups of the hypervisor (parent) to Discovery VM (child). But I still have no idea how best to do this.

    Thanks for your help,
    Best Regards,
    Cornelius​
  • Answer selected by cowa at 01-02-2023, 10:59.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    {{#HV.ID}.regsub("(.*?)\.(.*)",\2)}
    Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.

    Comment


    • cowa
      cowa commented
      Editing a comment
      regex is working! Thanks!
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    {{#HV.ID}.regsub("(.*?)\.(.*)",\2)}
    Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.

    Comment


    • cowa
      cowa commented
      Editing a comment
      regex is working! Thanks!
  • cowa
    Junior Member
    • Jan 2023
    • 4

    #3
    Hello Cyber,
    thanks so much!
    I've been trying for more than 6 hours with no success.

    Now it works on ONE ESXi Hypervisor

    Click image for larger version

Name:	image.png
Views:	738
Size:	40.0 KB
ID:	458656

    ​If I now execute this on an ESXI hypervisor, it works.
    When I execute it on a second ESXI hypervisor, I get the error message that the group already exists.​

    Click image for larger version

Name:	image.png
Views:	670
Size:	28.2 KB
ID:	458657


    I think the Problem is, i added more esxi with the ending lan.company.org lile esx1.lan.company.org and esxi3.lan.company.org ...
    On each ESXi I added the templates "VMware" and "Template Virt VMware Hypervisor".

    Click image for larger version

Name:	image.png
Views:	640
Size:	18.6 KB
ID:	458658

    Maybe my approach is wrong here?


    ​I guess I have to create a dummy host for all ESXi in a group.
    In this dummy host I link the template "VMware" as well as all ESXi as interface SNMP.​

    Since we have installations without vcenter(vcsa), I have to use the {VMware} variable for every ESXi Hypervisor separately ...
    In the variable {VMware}: "https://{HOST.IP}/sdk" I am not allowed to use {HOST.IP}, because this is a user macro.
    Only LLD macros are allowed there...

    Can you help me?
    I may have gotten a bit off track.​

    Best Regards,
    Cornelius

    Comment

    • cowa
      Junior Member
      • Jan 2023
      • 4

      #4
      Now i add the dummy host and i think it is working, when i change the {vmware} Variable for every ESXi, but I am afraid that the "Discovery VMware VM" will then no longer be updated for the VM guests, since the LLD Discovery is in the dummy host.

      Click image for larger version

Name:	image.png
Views:	626
Size:	46.7 KB
ID:	458661​​
      Attached Files

      Comment

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

        #5
        Just like hostnames, group names have to be unique, so if you have discovered those already from one, then it gives you error in another.

        Comment

        • cowa
          Junior Member
          • Jan 2023
          • 4

          #6
          It is a confirmed critical bug.



          Anywhere have any experience how long it might take for the Zabbix team to fix critical bugs?

          Click image for larger version

Name:	image.png
Views:	618
Size:	17.8 KB
ID:	461902

          Comment

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

            #7
            as you saw.. that bugreport was created in 2014... has been around since versions 2.2...:P Zabbix has long lost the touch with their older bugs...

            Comment

            Working...