thank you :) this worked like a charm. edit /etc/icinga/icinga.cfg and set : use_regexp_matching=1
then service can be set up exactly how I wanted: define service{ use generic-service-nobody hostgroups tomcats host_name !internal* service_description app: tomcat check_command check_nrpe!check_tomcat } On Mon, Feb 6, 2017 at 8:33 AM, Assaf Flatto <ici...@flatto.net> wrote: > On 06/02/17 10:22, Jan Matis wrote: > > :) I'll try once again: > > What I'm trying to achieve is service that is assigned to hostgroup with > exception based on first part of hostname (because second part changes in > time ) > > so : > > define service{ > use generic-service-nobody > hostgroups tomcats > host_name !internal* > service_description app: tomcat > check_command check_nrpe!check_tomcat > } > > Error: Could not find any host matching 'internal*' (config file > '/etc/icinga/services/linux-tomcats.cfg', starting on line 82) > > -I understand why this doesn't work (it's because there is no "internal*" > hostname defined, there are few internal_i-330e24ab, internal_i-26351330, > and these second parts of hostname can and will change in time, so I can > not rely on full hostname in services ) > > So what I'm trying to figure out: is there any wildcard possibility for > host_name > in a service definition ? > > thanks > > 1 ) There is a way to enable regex in the icinga.cfg , > https://docs.icinga.com/latest/en/sample-icinga.html > > 2) if the hosts are in the hostgroup , why are you trying to exclude them ? > > 3) if they need Tomcat monitoring but differ from "prod" tomcat > monitoring, wouldn't it be simpler to assign them to another group all > together? > > > > > Jan > > On Mon, Feb 6, 2017 at 8:08 AM, Assaf Flatto <ici...@flatto.net> wrote: > >> On 06/02/17 09:58, Jan Matis wrote: >> >> Thank you. >> >are you using an automated method to register the hosts >> yes >> >> > you can just add the host (via templates) to the host group and that >> way any service check assigned to the group will be applied to the host in >> that group. >> That is exactly what I'm doing. The problem is I have an exception of >> this rule and I wanted to avoid hard coding those exceptions into my >> "autoregister" script and just set them in services. >> >> Jan >> >> >> >> Can you share the error you are getting ? it would be helpful to help >> understand the issue. >> >> >> >> On Sun, Feb 5, 2017 at 1:35 PM, Assaf Flatto <ici...@flatto.net> wrote: >> >>> On 02/02/17 18:32, Jan Matis wrote: >>> >>> Hi all, >>> >>> this is to my understanding quite easily achievable in icinga2 : (not >>> tested, but this is where i'd start ) >>> >>> apply Service "app: tomcat" { >>> import "generic-service" >>> check_command = "nrpe" >>> vars.nrpe_command = "check_tomcat" >>> assign where "tomcats" in host.groups >>> ignore where match("internal*", host.name) >>> } >>> >>> >>> Unfortunately, I have icinga1 on the server, where I need to implement >>> this >>> (and no power over changing to icinga2), so I have started with >>> define service{ >>> use generic-service-nobody >>> hostgroups tomcats >>> host_name !internal* >>> service_description app: tomcat >>> check_command check_nrpe!check_tomcat >>> } >>> >>> the usage of * failed during service icinga checkconfig >>> and after going through icinga1 documentation I'm starting to think this >>> it not possible in icinga1. >>> >>> The reason why I'm trying to do this, is that we have host definitions >>> that include aws instanceid in the host name and those instance ids are >>> changing in time. so I also can not write whole host name (as >>> internal_i-234sdq234) because upon next icinga restart that host definition >>> might not exist anymore and there could be another >>> (internal-i_123asdf324tre ) >>> >>> Is there any way to use regular expression in service definitions in >>> icinga1 ? Or any other way of achieving this in icinga1 ? >>> >>> many thanks in advance >>> Jan >>> >>> >>> >>> >>> Yes it possible, are you using an automated method to register the hosts >>> ? >>> you can just add the host (via templates) to the host group and that way >>> any service check assigned to the group will be applied to the host in that >>> group. >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> icinga-users mailing >>> listicinga-users@lists.icinga.orghttps://lists.icinga.org/mailman/listinfo/icinga-users >>> >>> _______________________________________________ icinga-users mailing >>> list icinga-users@lists.icinga.org https://lists.icinga.org/mailm >>> an/listinfo/icinga-users >> >>
_______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users