Ad Widget

Collapse

How to make a duplicate template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brambo
    Senior Member
    • Jul 2023
    • 245

    #1

    How to make a duplicate template

    I know how to import / export an template.
    However when I export, change the time in the field of template name and import again the existing template is 'updated'
    Next I tried changing the UUIDs with other hex characters and keep the same length >> error about not valid UUIDv4.
    Well I can understand why it tries to update the existing template however my own custom template are designed toward our own products and R&D sometimes decides to change things and that is why I have to make template with works until version x.y for example.

    Copy items from a template to a new one works fine and is doable, however you can't do that with discovery rules and that is why I wonder am I missing something or is there a route to take to make a duplicate?
  • Markku
    Senior Member
    Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
    • Sep 2018
    • 1781

    #2
    I have a workflow where I occasionally need to duplicate a discovery rule in a template. When copying an existing discovery rule (with all the prototypes), I first copy the exported lines to a text file and then I'm using a self-made Python script to replace the existing UUIDs with new ones (as well as replacing the other necessary texts for the new rules to work). Then I add the lines in the original template export file, and import back in. This results in the new discovery rule added to the template, not overwriting anything.

    The same could also be made fully automated with API calls and some scripting of course.

    Simple command to generate a new UUID4 value for manual operations:

    python3 -c "import uuid; print(uuid.uuid4())"

    Markku
    Last edited by Markku; 30-06-2024, 12:20.

    Comment

    • Markku
      Senior Member
      Zabbix Certified SpecialistZabbix Certified ProfessionalZabbix Certified Expert
      • Sep 2018
      • 1781

      #3
      Just adding that I'm still using Zabbix 6.0, but I think duplicating a discovery rule (with prototypes) is still impossible in Zabbix 7.0 UI as well.

      Markku

      Comment

      • Brambo
        Senior Member
        • Jul 2023
        • 245

        #4
        Originally posted by Markku
        I have a workflow where I occasionally need to duplicate a discovery rule in a template. When copying an existing discovery rule (with all the prototypes), I first copy the exported lines to a text file and then I'm using a self-made Python script to replace the existing UUIDs with new ones (as well as replacing the other necessary texts for the new rules to work). Then I add the lines in the original template export file, and import back in. This results in the new discovery rule added to the template, not overwriting anything.

        The same could also be made fully automated with API calls and some scripting of course.

        Simple command to generate a new UUID4 value for manual operations:

        python3 -c "import uuid; print(uuid.uuid4())"

        Markku
        Ok if that is the route to take im gonna build a script for that as well. But for me that will be powershell
        Code:
        function newguid {
        [string]$temp = [guid]::Newguid()
        $temp = $temp.replace('-','')
        return $temp
        }
        will be the function I will use to generate new guid ID's without a - separator.
        And as zabbix supports multiple file output types I create a full script to process all types

        Comment

        • burns
          Junior Member
          • Apr 2024
          • 1

          #5
          python3 -c "import uuid; print(str(uuid.uuid4()).replace('-',''))"

          python3 -c "import uuid; [print(str(uuid.uuid4()).replace('-','')) for _ in range(5)]"

          Comment

          Working...