Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.
15:39

Tcl INI-Parser with Macros

You probably know the common ini file format with [sections] and key=value pairs, e.g.

[foo]
key1=value1
key2=value2
 

But sometimes, the ini file describes very similar sections, such as:

[host foo.example.com]
listen=foo.example.com:80
allow=10.0.0.0/8

[host bar.example.com]
listen=bar.example.com:80
allow=10.0.0.0/8

; many more here...
 

In order to eliminate this redundancy, qmon's ini-file parser defines macros inspired by C++ style #defines:

#template HOST %FQDN%
[host %FQDN%]
listen=%FQDN%:80
allow=10.0.0.0/8
#end template

#use HOST foo.example.com
#use HOST bar.example.com
 

This kind of macro preprocessor is used in the qmon monitoring system to simplify the task of configuring the same check over and over again for each host to be monitored.

Don't be the product, buy the product!

Schweinderl