Hi Thomas, thanks a lot. Problem solved.
scenario 2: (service by hostname) ================================= Just ensure the existance of the corresponding host-definitions (casesensitiv) inside the database of director. Otherwise you get SQL-errors on the _second_ run. Import Source: -------------- key Column; object_name (service) ; import (name of service template); host (hostname) 1; d1; d1_template; hostA 2; d1; d1_template; hostB Preconditions ------------- make sure that hostA and hostB exists inside director! check it: select * from icinga_host where object_name like "host%"\G; id: 16 object_name: hostA .. id: 3 object_name: hostB .. Sync ---- Now the sync is working check it: select * from icinga_service where object_name="d1"\G; object_name: d1 object_type: object host_id: 16 .. object_name: d1 object_type: object host_id: 3 ... Generated config ---------------- object Service "d1" { host_name = "hostA" import "d1_template" } object Service "d1" { host_name = "hostB" import "d1_template" } scenario 1: (service by assign_filter) ====================================== Not supported, but works with the master-branch-code from today Importsource: -------------- id; object_name (service); import (service_template); assign_filter (assign-where-clause); object_type 1; d3; d3_template; host.vars.service_enabled.d3; apply 2; d4; d4_template; host.vars.service_enabled.d4; apply Sync ---- check it: select * from icinga_service where assign_filter like "%service_enabled%"\G; object_name: d3 object_type: apply assign_filter: host.vars.service_enabled.d3 .. object_name: d4 object_type: apply assign_filter: host.vars.service_enabled.d4 ... Generated config ---------------- apply Service "d3 { import "d3_template" assign where hosts.vars.service_enabled.d3 == 1 import DirectorOverrideTemplate } apply Service "d4 { import "d4_template" assign where hosts.vars.service_enabled.d4 == 1 import DirectorOverrideTemplate } Cheers, Tilo Am 13.12.2016 um 14:26 schrieb Thomas Gelf: > Hi Tilo, > > quite some questions at once :D > > * scenario 2: the description field for the key column name says "This > must be a column containing unique values like hostnames. Unless > otherwise specified this will then be used as the object_name for the > synchronized Icinga object. Especially when getting started with > director please make sure to strictly follow this rule. Duplicate values > for this column on different rows will trigger a failure, your import > run will not succeed" > > So, importing hosts should run fine, just make sure that you choose the > field that will become your identifier (object_name) as a key column. > > * hasServiceSet -> this was a bug, I pushed a fix - please try again > > * sync for single services on specific hosts works fine, everything else > used to be not supported - and still is. However, as some people > insisted doing so (and managed it to do so), we removed parts of the > code that blocked you when trying. > > * when synchronizing templates the object_name should be your key > > * synchronizing apply rules is VERY tricky, us you cannot work with a > unique name - Icinga allows for many rules with the very same name > unless they do not collide once realized. > > I guess even apply rules COULD work with some hack based on custom vars, > but unless you have an immediate need for doing so I'd strongly advise > against even trying. > > Best practice is to define apply rules in the Director, sync hosts with > custom properties useful for your apply (or "apply for") rules and > additionally also sync some single services in case your data source > provides such detailed information. > > As soon as your sync has a host and an object_name property for your > services it would internally switch to using those as a combined key and > succeed. The setup I'm currently working with does so with next to > 10,000 single services (plus more than 60,000 generated as apply rules), > so I guess it should work ;-) > > Cheers, > Thomas > > Am 13.12.2016 um 13:46 schrieb tilo....@googlemail.com: >> Hello, >> >> i want to sync services via Director. >> >> 1. scenario: assign-filter >> The importsource delivers the "import template name" and the >> "assign-filter" >> >> 2. scenario: hostname >> The importsource delivers the "import template name" and the "hostname" >> >> Neither 1 nor 2 i'm able to create >> >> >> 1. scenario >> =========== >> Importsource >> ------------- >> a file (fileshipper) or databasetable (mysql) with: >> >> id; service_template; assign_where >> 1; check_1_template; host.vars.os==Windows >> >> Key column name: id >> >> sync rule >> --------- >> properties Source field -> Destination: >> ${service_template} -> import >> ${assign_where} -> assign_filter >> apply -> object_type >> >> On sync I get: >> Undefined variable: hasServiceSet >> >> Even if i introduce an "object_name" i got this error. >> >> >> 2. scenario >> =========== >> Importsource >> ------------ >> a file (fileshipper) or databasetable (mysql) with: >> id; service; service_template; host_name >> 1; d1; check_2_template; hostA >> 2; d1; check_2_template; hostB >> >> Key column name: id >> >> sync rule >> ---------- >> ${service} ->object_name >> {service_template} -> import >> {host_name} -> host >> >> on first sync i got as expected: >> >> object Service "d1" { >> host_name = "hostA" >> import "check_2_template" >> } >> object Service "d1" { >> host_name = "hostB" >> import "check_2_template" >> } >> >> on second sync i got >> >> "Exception while syncing Icinga\Module\Director\IcingaService d1: >> Storing icinga_service[] failed: SQLSTATE[23000]: Integrity constraints >> violadtion: 1062 Duplicate entry 'd1-1' for key 'object_key'..." >> >> But the database icinga_servcei is showing no "d1-1": >> select id,object_name, oibject_type from icinga_service; >> 11 d1 object >> 12 d1 object >> >> >> How do I import services via Director? >> >> Regards >> Tilo Mey >> _______________________________________________ >> icinga-users mailing list >> icinga-users@lists.icinga.org >> https://lists.icinga.org/mailman/listinfo/icinga-users > > -- > Thomas Gelf > Principal Consultant > > NETWAYS GmbH | Deutschherrnstr. 15-19 | D-90429 Nuernberg > Tel: +49 911 92885-0 | Fax: +49 911 92885-77 > CEO: Julian Hein, Bernd Erk | AG Nuernberg HRB18461 > http://www.netways.de | thomas.g...@netways.de > > ** OSDC 2017 - Mai – osdc.de ** > _______________________________________________ > icinga-users mailing list > icinga-users@lists.icinga.org > https://lists.icinga.org/mailman/listinfo/icinga-users > _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users