Assign Templates to Values?

Hi,
i have host names like countrycity-street.
I splitted this via mapping (i didn’t get regex to work) which was a real pain, but now it works.
Now i have to add values to each host depending on the street.

Hostname (for example): germanynuernberg-15deutschherrnstrasse are splitted to:
host.vars.country=germany
host.vars.city=nuernberg
host.vars.street=deutschherrnstrasse

Now i want to add Coordinates for NagVis which i wanted to do with a template:
LONG: 1234
LAT: 5678

What i’m looking for is a assignement like this:
assign if host.vars.street = deutschherrnstrasse

I didn’t found any other way that put this values in templates and adding this thempates with a filter for each street. My sync-properties are 2 sites long.
I’m sure there is a better way to do this, but i didn’t finde one.

Could you help?

Thank you,
Uwe

Hi,

can you share such an example sync rule you’re using, and also the mapping you’re talking about?

Host objects do not share an assign where logic to my knowledge, and as such there’s only the template way of things.

Do you know the coordinates up front for these hosts? The best way I could imagine would be an additional field in your import source already, maybe manipulated with a script in between.

Cheers,
Michael

Hello Michael,

thank you for your time.

Sync-Rule:
2019-02-25%2009_40_27-Icinga%20Web

Mapping:


The streetMap maps 15deutschherrnstrasse to deutschherrnstarasse.
The countryMap maps germanynuernberg to germany
and so on.

Do you know the coordinates up front for these hosts? The best way I could imagine would be an additional field in your import source already, maybe manipulated with a script in between.

Interesting Idea. Yes, i know the coordinates up front. But i would prefer the Template-way.

Thank you!

Uwe