> -----Original Message-----
> From: [email protected] [mailto:rsyslog-
> [email protected]] On Behalf Of Rainer Gerhards
> Sent: Friday, June 25, 2010 8:25 AM
> >From what I know so far, YAML actually seems to be the best fit (but I
> have
> yet to see a rsyslog config with it). I *think* we could use the if-
> then-else
> constructs in a Python way inside YAML, something like
> 
> if expr then
>    Action 1:
>      Param1: value1
>      ...
>    Action 2:
>      ...
>    ...
> else
>    Action n+1:
>    ....
> end if

As this becomes interesting, I have now tried to do a rsyslog.conf in YAML as
well. Not sure if it is the best way to do it, but at least it validates with
yaml's reference parser [http://yaml.org/ypaste/]:

global:
  emitstartupmessages: off

modules:
  - imtcp:
    binary: "imtcp"
    maxlisten: 512
  - imudp
  - ommail

input:
  type: "imtcp"
  listen: 10515
  ruleset: "remote10515"

input:
  type: "imudp"
  listen: 10515
  ruleset: "remote10515"

ruleset:
  name: "remote10514"
  processing:
    if: expr
      then:
        - action:
          type: "omfile"
          file: "/var/log/catchall"
        - action:
          use: "dynfile"
    endif:

ruleset:
  name: "testFromEmail"
  processing:
    if: expr
      - action:
        type: "omfile"
        file: "/var/log/file1"
      - action:
        type: "omfile"
        file: "/var/log/file2"
    else:
      if: expr
        - action:
          type: "omfile"
          file: "/var/log/file3"
      else:
        - action:
          type: "omfile"
          file: "/var/log/file4"
      endif:
    endif:

I have to admit that it doesn't look too bad, but it also does not look as
appealing as I had hoped for... One inherant problem is the potentially large
number of parameters that an action needs. In this sample, I have specified
only very few, but with async processing, actions and the like they will
become many.

Maybe it would be a good idea to force the user to predefine actions before
they are used... but that is not intuitive :(

Back to the sample: I notice that YAML was not meant to express control-flow
like things and I really see how we are abusing it...

Rainer
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com

Reply via email to