Can nagios.cfg use system variables?
Posted: Tue Jan 22, 2019 5:06 pm
Hello,
I have a bit of an unusual question. So I am putting together some Nagios servers, and they are going to be using version control to sync up the configs across multiple boxes. I am putting configs that I want to run on specific Nagios servers in a directory called /etc/nagios/<hostname>, where the hostname is the value you get when you run hostname on the server. In Nagios.cfg, I have a cfgdir definition set up for each server, with a script that runs and comments out all of the cfgdir entries except the one with the local host's hostname. This works ok, but is a bit messy for the version control aspect. It would be ideal if I could do something like cfgdir=/etc/nagios/$(hostname)/, because then I'd be able to just have 1 nagios.cfg config file to rule them all, and they'd get their appropriate directory dynamically when nagios daemon starts. But I haven't been able to figure out how to get nagios.cfg to recognize any system variables that could give me that. Does anyone have any ideas on how I could do this?
I have a bit of an unusual question. So I am putting together some Nagios servers, and they are going to be using version control to sync up the configs across multiple boxes. I am putting configs that I want to run on specific Nagios servers in a directory called /etc/nagios/<hostname>, where the hostname is the value you get when you run hostname on the server. In Nagios.cfg, I have a cfgdir definition set up for each server, with a script that runs and comments out all of the cfgdir entries except the one with the local host's hostname. This works ok, but is a bit messy for the version control aspect. It would be ideal if I could do something like cfgdir=/etc/nagios/$(hostname)/, because then I'd be able to just have 1 nagios.cfg config file to rule them all, and they'd get their appropriate directory dynamically when nagios daemon starts. But I haven't been able to figure out how to get nagios.cfg to recognize any system variables that could give me that. Does anyone have any ideas on how I could do this?