[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] help with nrpe.cfg lens


I'm trying to build a lens to handle nrpe's config file. Apart from
some easy "key=value" options, this file can have N "command" options,
which typically look like:

command[check_load]=/usr/lib/nagios/plugins/check_load -w $ARG1$ -c $ARG2$
command[check_disk]=/usr/lib/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_procs]=/usr/lib/nagios/plugins/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$

I was thinking of creating this lens in a way which would allow to
access these "command" options by doing:
set /files/etc/nrpe.cfg/command/check_load "..."

I'm having some trouble understanding the way subtrees should be
declared in a lens, and I found no other lens doing exactly what
I'm trying to do.

My (stripped-down) code is currently unable to match more than
one sub-item:

test_test.aug:5.7-.31:exception: Get did not match entire input
    Lens: ./test.aug:8.16-.95:
    Error encountered at 2:0 (17 characters into string)

    Tree generated so far:
/command/foo = "bar"

Where the test looks like:

module Test_test =

  let command = "command[foo]=bar\ncommand[bar]=baz\n"

  test Test.command get command =
    { "command"
      { "foo" = "bar" }
      { "bar" = "baz" }

And the lens itself:

module Test =

  let nl = del /\n/ "\n"
  let eq = del /=/ "="
  let obrkt = del /\[/ "["
  let cbrkt = del /\]/ "]"

  let command = [ key "command" .
    [ obrkt . key /[a-z]+/ . cbrkt . eq . store /[^=]+/ . nl ]*

  let lns = ( command ) *

First, do you think it makes sense to access the "command"
options this way ?

Then, if anyone has a clue what's wrong with my current lens...

Many thanks !

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]