Ad Widget

Collapse

Derive multiple tags from purposedly constructed hostnames for any type of HW hosts

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • molnarm
    Junior Member
    • Apr 2024
    • 4

    #1

    Derive multiple tags from purposedly constructed hostnames for any type of HW hosts

    Ok, what would be the best practice to add multiple user defined tags to a host, substracted from a host name? This should be universally applicable to diferent HW host types, where data collection is achieved by different methods (SNMP agent to various LAN/SAN switches, HTTPS API thrown at servers and different types of storage devices, etc.). Can this be somehow universally automated via discovery and/or other functions within 7.0 LTS? The point is - the hostname of any HW device/host is always constrained by a specific nomenclature, i.e. same lenght, same defining substrings within the name, etc. Anyone has any good example for such purpose?
  • Answer selected by molnarm at 18-02-2025, 09:01.
    vsergione
    Junior Member
    • Oct 2023
    • 28

    Originally posted by vsergione
    If the hosts are added via discovery, the yes. You can use scripts or regexp to achieve this. When creating a discovery rule, in the preprocessing steps, one can add a custom script or a custom regexp expression to parse the hostname and extract the meaningful sub-strings from it and assign them to macros which later on can be used as tags in the host prototype.

    Otherwise, if hosts are added manually, you could create a script which scans the Zabbix periodically and updates the hosts which do not have the tags yet configured.
    the output of the preprocessing step should be a JSON. For example:
    Click image for larger version

Name:	image.png
Views:	88
Size:	17.4 KB
ID:	499115
    Click image for larger version

Name:	image.png
Views:	83
Size:	28.7 KB
ID:	499116
    Attached Files
    Last edited by vsergione; 14-02-2025, 13:50.

    Comment

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

      #2
      <tag> -> value something like {{HOST.NAME}.regsub("<your regex>",\1 \2..\n)}

      Comment

      • vsergione
        Junior Member
        • Oct 2023
        • 28

        #3
        If the hosts are added via discovery, the yes. You can use scripts or regexp to achieve this. When creating a discovery rule, in the preprocessing steps, one can add a custom script or a custom regexp expression to parse the hostname and extract the meaningful sub-strings from it and assign them to macros which later on can be used as tags in the host prototype.

        Otherwise, if hosts are added manually, you could create a script which scans the Zabbix periodically and updates the hosts which do not have the tags yet configured.
        Last edited by vsergione; 14-02-2025, 13:40.

        Comment

        • vsergione
          Junior Member
          • Oct 2023
          • 28

          #4
          Originally posted by vsergione
          If the hosts are added via discovery, the yes. You can use scripts or regexp to achieve this. When creating a discovery rule, in the preprocessing steps, one can add a custom script or a custom regexp expression to parse the hostname and extract the meaningful sub-strings from it and assign them to macros which later on can be used as tags in the host prototype.

          Otherwise, if hosts are added manually, you could create a script which scans the Zabbix periodically and updates the hosts which do not have the tags yet configured.
          the output of the preprocessing step should be a JSON. For example:
          Click image for larger version

Name:	image.png
Views:	88
Size:	17.4 KB
ID:	499115
          Click image for larger version

Name:	image.png
Views:	83
Size:	28.7 KB
ID:	499116
          Attached Files
          Last edited by vsergione; 14-02-2025, 13:50.

          Comment

          Working...