On Thu, 27 Jun 2013, Orangepeel Beef wrote:

Can you do elsif or else if blocks in rainerscript?

currently using:
if re_match($fromhost,'^lb.*') then {
  *.* action(type="omprog" binary="/usr/local/sbin/sec_netscaler"
       template="RSYSLOG_TraditionalFileFormat")
}

if re_match($fromhost,'^(as|cs|r).*') then {
  *.* action(type="omprog" binary="/usr/local/sbin/sec_comware"
       template="RSYSLOG_TraditionalFileFormat")
}


but it would be nice if i could have something like..

if re_match($fromhost,'^lb.*') then {
  *.* action(type="omprog" binary="/usr/local/sbin/sec_netscaler"
       template="RSYSLOG_TraditionalFileFormat")
}

elsif re_match($fromhost,'^(as|cs|r).*') then {
  *.* action(type="omprog" binary="/usr/local/sbin/sec_comware"
       template="RSYSLOG_TraditionalFileFormat")
}

else {
  *.* action(type="omprob" binary="/usr/local/sbin/sec_misc"
        template="RSYSLOG_TraditionalFileFormat")
}

I just got it working, so i haven't wanted to break it again, so this may
actually already work, but i didn't see anything that mentioned it in the
documentation.

I haven't seen it in the documentation, but from a comment that Rainer made, I think it can be done as

if re_match($fromhost,'^lb.*') then {
  *.* action(type="omprog" binary="/usr/local/sbin/sec_netscaler"
       template="RSYSLOG_TraditionalFileFormat")
} else {
  if re_match($fromhost,'^(as|cs|r).*') then {
    *.* action(type="omprog" binary="/usr/local/sbin/sec_comware"
         template="RSYSLOG_TraditionalFileFormat")
  } else {
  *.* action(type="omprob" binary="/usr/local/sbin/sec_misc"
        template="RSYSLOG_TraditionalFileFormat")
  }
}

so, no direct elsif, but there is an else

David Lang
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to