I would like to have nights a daily service discovery to add new discovered services and removing vanished services, without adding a new check to the hosts, which what the Periodic service discovery over WATO does.
So basically I just want to write a script to do cmk -vII for all hosts except for some critical hosts, that should remain untouched if a service vanished or a new one is discovered.
How can I exclude a group of hosts from being inventoried?
I did read the help for this, but this doesn’t solve my problem, when I do cmk -vII this will delete all existing checks, which I don’t want for specific hosts. so basically I am good with this for the majority of my hosts, but I don’t want to delete a vanished service like a network interface check if it is defective and the new inventory cannot find it any more.
I was actually looking for a regex how to exclude a group of hosts when performing cmk -vII and for these hosts just perform cmk -vI.
you can do this with the undocumented WebAPI call “bulk_discovery_start”. You can use the parametres from “discover_service” and send a hostlist as payload. This will handle as backround job. You can check it with "bulk_discovery_status’.
This is really a simple solution with Linux tools. Didn’t think about it at all, I thought cmk command supports some kind of regex, but this is just great.
Yep, @Dirk’s suggestion is simple and handy but limits the possible filter. It’s just usable if you like to filter the hostname. Via livestatus you have plenty of possibilities to filter your hosts and also make it transparent at the web interface with tags. I would recommend to create a tag for your hosts you like to discover and use the livestatus to get out this hosts.
@tosch but you can also list the hosts by tag on the command line:
cmk --list-tag mytag
will list all hosts the the tag mytag. You can combine this with grep and xargs.
Still, I see your point. Your suggestion offers far more possibilities but the list/grep solution doesn’t need any further tools or knowledge.