Extracting the folder name associated with a host

Hi all,

I’m looking for a reasonable way of getting the folder a given host is associated with. e.g. if [at least with version 2.0.0p15] if I go into setup → hosts, I have a list of folders, under each folder some number of hosts. what I really would like to get is some sort of Folder F has/contains/is associated with hosts h1, h2, h3, h4.

I’ve dug into the cmk --list-tags and cmk -D [host] and found nothing that seemed like it would get me what I want; I’ve also located the ./tmp/check_mk/wato/wato_host_folder_lookup.cache file, which seems to be binary and ‘strings’ doesn’t quite give me what I want, either.

I’ve got a set of hosts that live in a particular folder which experience infrequent provider changes - the ip gets moved around and checkmk doesn’t notice, ends up needing a dns cache update. is there a reasonable way that I can use cmk to for dns cache update on a subset of hosts? or is that an all or nothing type of thing?

hope this made some sense, thanks for any replies.

Hi,
you can clone your All hosts view and sort and group by Folder - complete path.

Karl

2 Likes

The hosts in wato folders are physical folders on the server as well /omd/sites/[sitename]/etc/check_mk/conf.d/wato/.
In LQL the column host_filename gives hostname with parent folder(s).

2 Likes

The DNS caching mechanism just works for all hosts if you use cmk --refresh-dns-cache. You can check some hosts to ignore the DNS cache in general and do a lookup on every call. This could pack a heavy load on the DNS server in larger environments so be patient with this option. The rule should name Hosts with dynamic DNS lookup during monitoring.

For an overview of hosts and their folders i would also prefer the live query way @Yggy mentioned. There should be an example in the forum around somewhere. We had this topic several times, i can remember.

the turning off dns caching for a subset of hosts would probably be the right solution but I’ll have to dig in more, I don’t see an option offhand for it.; I don’t much like getting rid of all the cache - that seems to cause transitional errors for connecting to the checkmk servers (at least I’m willing to chalk it up to that and call it good). the check_mk/conf.d/wato folder is good to know about too - not sure why I couldn’t find it in my searching with ls -R and find.

cool, thanks. I think this is about 90% of what I’m trying to get to. thanks.

1 Like

that sounds like an interesting option, but I was really trying to keep it more programatic/on the commandline and away from any sort of gui/http connection. but thanks.