I missed one obvious answer because I so prefer to have everything defined
in the XML tags
XML can be a mix of tags and text, use the tagsto define the things that
XML is good for and the text for the logic flow that it doesn't do
<ruleset id='default'>
<rule>
if <test filter='$source = "host1"'>
then
<action1/>
<action2/>
if <test filter='$msg contains "error"'>
then
<action3/>
<action4>
else
<action5/>
</rule>
</ruleset>
the logic partsw of this could not be validated by external tools, but the
XML pieces could be and I think that is where you get the most value (as
it's where there is more likely going to be mistakes)
David Lang
On Thu, 24 Jun 2010, [email protected] wrote:
> On Thu, 24 Jun 2010, Rainer Gerhards wrote:
>
>> if $source = 'host1' then
>> do action 1
>> do action 2
>> if $msg contains 'error then
>> do action 3
>> end if
>> do action 4
>> else
>> do action 5
>> end if
>
> true, XML doesn't have three part tags so it can't do if-the-else but
> there are a few ways to deal with this
>
> <ruleset id='default'>
> <rule filter='$source = "host1"'>
> <action1/>
> <action2/>
> <action3 filter='$msg contains "error"'/>
> <action4>
> <discard>
> </rule>
> <rule>
> <action5/>
> </rule>
> </ruleset>
>
> <ruleset id='default'>
> <rule filter='$source = "host1"'>
> <action1/>
> <action2/>
> <action3 filter='$msg contains "error"'/>
> <action4>
> </rule>
> <rule filter='$source != "host1"'>
> <action5/>
> </rule>
> </ruleset>
>
I misse
> <ruleset id='default'>
> <rule>
> <test filter='$source = "host1"'>
> <match>
> <action1/>
> <action2/>
> <test filter='$msg contains "error"'>
> <match>
> <action3/>
> </match>
> </test>
> <action4>
> </match>
> <nomatch>
> <action5/>
> </nomatch>
> </rule>
> </ruleset>
>
> any of these look sane?
>
> unfortunantly I don't know any way of expressing what you are wanting to
> do directly in any config language. you would have to go to an interpreter
> to express things directly because it is directly code logic you are
> expressing. I think that any config language is going to have problems
> with if-then-else
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com