Ad Widget

Collapse

api hostgroup.massupdate : how to retreive hg's templates first to link them after ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gerard-wl
    Junior Member
    • Sep 2015
    • 24

    #1

    api hostgroup.massupdate : how to retreive hg's templates first to link them after ?

    Hello

    I need to do a massupdate to update the hostid list for a hosgroup
    But doing so, linked templated to this hostgroup are unklink from it https://www.zabbix.com/documentation...oup/massupdate
    Confirmed by personnal test
    So how can I :

    1/ get the template ids liked to the hostgroup : which api ?
    2/ do my massupdate
    3/ re-link these template ids to my hotgroup

    Thank you !
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Templates are linked to hosts, not hostgroups...

    Comment

    • gerard-wl
      Junior Member
      • Sep 2015
      • 24

      #3
      Hello cyber, I've done a more complete test, and you are right, I was confused by the "template" column displayed at hostgroup level in the gui.
      And using hostgroup.massupdate seems to keep the templates linked to hosts, removed or added to hg.
      The documentation is confusing too : "This method allows to replace hosts and templates with the specified ones in multiple host groups."
      My mystake : ) Thank you for your remark cyber.

      Comment

      • gerard-wl
        Junior Member
        • Sep 2015
        • 24

        #4
        Hello cyber I'm using zabbix 6.0
        The api were different from 6.4

        The parameter "templates" is required : "data":"Invalid parameter "/": the parameter "templates" is missing."}
        How can I interpret this parameter ? Which templateid's do I have to give ?

        Comment

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

          #5
          I don't now the answer... All that API side and any codewriting related to it is kind of alien to me..

          Comment

          • gerard-wl
            Junior Member
            • Sep 2015
            • 24

            #6
            Thank you for your answer cyber ,you make me laugh ^^
            Shouldn't a specialist be interested?
            Whatever, I've found the answer the answer, it may interest other people maybe
            When you want to modify the host list of a hosgroup, without touching the templates contained, you must :
            1/ make a hostgroup.get with the "selectTemplates" parameter
            2/ make the hostgroup.massupdate with the new list of hosts + this list of templates
            Yes a template is only linked to a host, but you can add a template in a hostgroup, this does not affect the hosts contained at all, it's just a trick to give modification rights on this template​

            Comment

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

              #7
              Glad I can make you laugh... /s.
              Hope you do not make it a habit to laugh over everyone, who cannot answer your questions right away...

              Comment

              • gerard-wl
                Junior Member
                • Sep 2015
                • 24

                #8
                Above all cyber don't see any harm in it, it's very nice to have answered me, I really liked the alien

                Comment

                Working...