On 3/6/2018 2:53 AM, Rainer Gerhards wrote:
2018-03-06 9:04 GMT+01:00 deoren
<rsyslog-users-lists.adiscon....@whyaskwhy.org>:
On 3/6/2018 1:43 AM, Rainer Gerhards wrote:

2018-03-05 19:17 GMT+01:00 deoren
<rsyslog-users-lists.adiscon....@whyaskwhy.org>:

Hi,

When refactoring an older configuration I figured I would give global
variables a try.

I'm attempting to create a generic email notification ruleset that can be
called after setting values in a subtree of the $.email-notification
local
variable.

Example (email templates and associated ruleset not included here):

set $/default-email-notification!sender = 'rsyslog-ale...@example.com';
set $/default-email-notification!recipient = 'rsyslog-ad...@example.com';
set $/default-email-notification!subject-template =
'email-notification-standard-subject';
set $/default-email-notification!body-template =
'email-notification-standard-body';
set $/default-email-notification!server-ip = '127.0.0.1';
set $/default-email-notification!server-port = '25';

action(
      name="email-alert-action"
      type="ommail"
      server="$.email-notification!server-ip"
      port="$.email-notification!server-port"
      mailfrom="$.email-notification!sender"
      mailto="$.email-notification!recipient"
      subject.template="$.email-notification!subject-template"
      template="$.email-notification!body-template"
      body.enable="on"

      # The parameter is included for every client request, so if we do
      # not apply some sort of rate limiting we will be flooded in a
      # very short amount of time.
      # Note: The interval is configured in number of seconds.
      action.execonlyonceeveryinterval=$.email-notification!interval
)


But I think the above will not work, as the parameters must be constant
strings.

Rainer


I ended up learning that the hard way. It's too bad really, as that felt
like a really good place to have support for variables.

For ommail, I would in theory not be such a big problem to support
these things, but in general this would be immensely
performance-hungry. In the concrete case, however, there is no
plumbing at all in the module interface/rsyslog core for this, so it
would probably require weeks of refactoring to make it happen. And for
almost all other cases you really don't want to have that capability,
as it slows down things very, very considerably.

Rainer

Thanks for explaining. As you've noted, the time investment sounds like it would be better spent elsewhere.
_______________________________________________
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