#if, #ifdef Nesting
You can nest #ifdef's within #if's, and vice-versa, throughout the config files.
For example, you might do this in your alerts.cfg:
Debug #ifndef holiday # if piktmaster timing 55 * * * * 5 # else timing 55 */6 * * * 5 # endif #elsedef timing =piktnever #endifdefWhen nesting in this way, per-machine #if directives take precedence over logical #ifdef directives. So, for example,
#if linux [ aaa ... ] #ifdef paranoid [ bbb ... ] #endifdef [ ccc ... ] #endifwould have the aaa, bbb & ccc content appear only on linux machines, and the bbb content only if paranoid is set (defined). On the other hand, with
#ifdef paranoid [ aaa ... ] #if linux [ bbb ... ] #endif [ ccc ... ] #endifdefthe aaa and ccc content would appear on all machines, if paranoid is set, while the bbb content would appear only on linux machines with paranoid defined.
This, however, would lead to error on non-linux systems:
#ifdef paranoid [ aaa ... ] #if linux [ bbb ... ] #endifdef [ ccc ... ] #endifbecause there would be no concluding #endifdef on those machines. In other words, be careful about intertwining #if-#endif's with #ifdef-#endifdef's.
Observe that you can set/unset defines on a per-machine basis in the defines.cfg file, for example
#if dbserver paranoid TRUE #else paranoid FALSE #endifOr, alternatively and equivalently,
paranoid #if dbserver TRUE #else FALSE #endifRefer to the Samples section for more examples.
prev page | 1st page | next page |