PDA

View Full Version : Is there a way to do a mass "link to template" ?


Maximum
09-07-2007, 19:41
Hi,

I just started from scratch after an export (zabbix 1.4.2).
After I imported everything in my new database I have 200 hosts in 3 host groups and none are linked to a template.

I want all host in host group number 1 to use template1, all hosts in host group number 2 to use template2 and all hosts in host group 3 to use template3.

I did this the hard way last friday and realized that I had to do 5 mouse clicks per host = a total of 1000 mouse clicks.. that was a nightmare and my right hand took some serious damage :(

Now I wonder if there is another way to do it ? (a mass update feature under "Configuration/Hosts" would be awesome).

Could this be done with a crazy sql script or maybe some home brewed php tweak ?
Have anyone done this before ?

Im lousy at sql and have never coded php so if anyone have some code that could do this, please help me !


Best Regards /Maximum

Alexei
11-07-2007, 15:43
Apologies for the serious damage of your right hand :) Seriously, I believe that editing of the XML file would be much more productive and, depending on a text editor, is a good exercise for both hands!

hegermi
11-07-2007, 21:01
If the groups are defined then there must be a simple way to apply a set of items on a group of hosts.

Why do you advise him to create an xml file?

Cheers,

Michel

Maximum
11-07-2007, 21:47
Hi,

If I have understand this correctly, I can't get hosts linked to a template with an XML-import.

In my setup I only change items/triggers on templates and when I do that all the hosts associated with the template gets updated.

If I use the XML-import way, then I have to change the XML file and update each hosts items/triggers every time I want to make an adjustment.


After a lot of coffee I found a way to solve my problem anyway:
1. I imported the XML-file with all the hosts
2. I created 3 text files with only the IPs of my routers (one for each hostgroup that I wanted to link to its template)
3. I created an auto discovery rule and copied the host list from my first text file into it, in my case I used port 23 (telnet) for discovery because all my routers listens to that port.
4. I created an auto discovery action that would not check for anything, just link the found host to my first template.
5. When all my routers in my auto discovery rule had been found and linked, I changed the IPs of the rule to use those in my second textfile, changed the action to link to the second template.. and so on..

Pretty slow, but much faster than my manual nightmare and alot of less clicks... just some grep/awk-ing from my original XML-file to get all the IPs out in 3 plain text files.


If anyone find a better way to do this I would love to hear about it !



I would like to thank the developers for this great product that keeps on getting better and better each day and I would especially like to thank all you guys in the forum for the fast support ! You guys rock !

Best Regards !
/Maximum