Build precise queries to find exactly what you need
Press ESC to close
Nagios World Conference 2026: Sept. 14-17 in St. Paul, MN | Learn More
I really like the regex of it all. Searches most things. But I have found that when the host alias is missing it does not work properly.
Also the search does a grep -A INT so if the configuration is less default and places the grep’ed variable outside of the lookahead it will fail also. example: grep -EA2 “define[ ]+host[ ]+” /path/to/objects.cache | grep -Eo “(host_name|alias).+” if alias is on position 3+ it will miss it.
Perhaps first grep all the required parameters and then split the ones you want. Something like below. example: grep “(host_name|alias|define[ ]+host[ ]+).+” |grep -EA2 “define[ ]+host[ ]+” /path/to/objects.cache | grep -Eo “(host_name|alias).+”