Variable expansion in control file

Issue #52 on hold
Sergey Maslyakov created an issue

It would be great if the syntax of a control file would allow for variable expansion. This could make configuration less error prone and more elegant. For example:

check process slowLogger-1 with pidfile /monit/demo/monit/var/slowLogger-1.pid
  start program = "/monit/demo/svcs/slowLogger.sh start /monit/demo/monit/var/slowLogger-1.pid 1"
  stop program = "/monit/demo/svcs/slowLogger.sh stop /monit/demo/monit/var/slowLogger-1.pid"

This could be rewritten like this:

check process slowLogger-1 with pidfile $SL1_PID
  start program = "$SL_CTL start $SL1_PID 1"
  stop program = "$SL_CTL stop $SL1_PID"

Assuming that SL1_PID and SL_CTL are defined either in the control file or picked up from the environment as a fallback.

This would eliminate duplication and allow for more elegant syntax.

Do you see an issue or a risk associated with it?

Comments (4)

  1. Tildeslash repo owner

    This might be added in a later version. Or more likely, something like blocks or lists, as in

    check hosts my_hosts with address [192.168.1.0 - 192.168.1.255] 
          <do check on all hosts in list>
    

    and ditto for for instance files

    check files my_files with path /some/directory/*.log
          <do check on all matching files>
    

    etc.

    Variable definition might be useful, but it is unclear as tests tend to be specific and not much re-use is possible. Anyway, cleaning up, expanding and simplifying the config language is on our list.

  2. Log in to comment