The macro processor m4 is perhaps one of the most underappreciated programs in a typical UNIX environment. Sendmail may be the only reason it still exists – or would that distinction include GNU autotools?
Configuring Nagios can be dramatically simplified and made easier using m4 with Nagios templates. Even when using Nagios service and host templates, there is a lot of repetition in the typical services file – perhaps an extreme amount of duplicated entries.
Using m4 can reduce the amount of work that is required to enter items.
Here is an example:
DEFHPUX(`red',`10.1.1.1') DEFHPUX(`green',`10.1.1.2') DEFHPUX(`blue',`10.1.1.3') DEFHPUX(`white',`10.1.1.4') DEFHPUX(`black',`10.1.1.5') DEFHPUX(`orange',`10.1.1.6')
In my configuration, each line above expands into 64 lines (including three lines of header in the comments). So the result of those six lines is 384 lines of output.
Every DEFHPUX creates a host, complete with standard service checks such as PING, SSH, and TELNET. This is done all with just a few macro definitions at the beginning of the file.
Read about m4 and understand it, and your Nagios configurations will be much easier. You can use the program make to automate the creation of the actual config files and the check and reload necessary for Nagios to incorporate the changes.