rsyslog
Mar 14, 2010 - 04:31 PM
Professional Services
Custom written rsyslog.conf? Maintenance Contract?

rsyslog professional services



Donate!
Satisfied with rsyslog?

Donate and help keep
the project alive!

Rainer's Blog

Login




 


 Log in Problems?
 New User? Sign Up!

Online
There are 32 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

RainerScript

RainerScript is a scripting language specifically designed and well-suited for processing network events and configuring event processors (with the most prominent sample being syslog). While RainerScript is theoritically usable with various softwares, it currently is being used, and developed for, rsyslog. Please note that RainerScript may not be abreviated as rscript, because that's somebody elses trademark.

RainerScript is currently under development. It has its first appearance in rsyslog 3.12.0, where it provides complex expression support. However, this is only a very partial implementatio of the scripting language. Due to technical restrictions, the final implementation will have a slightly different syntax. So while you are invited to use the full power of expresssions, you unfortunatley need to be prepared to change your configuration files at some later points. Maintaining backwards-compatibility at this point would cause us to make too much compromise. Defering the release until everything is perfect is also not a good option. So use your own judgement.

A formal definition of the language can be found in RainerScript ABNF. The rest of this document describes the language from the user's point of view. Please note that this doc is also currently under development and can (and will) probably improve as time progresses. If you have questions, use the rsyslog forum. Feedback is also always welcome.

Data Types

RainerScript is a typeless language. That doesn't imply you don't need to care about types. Of course, expressions like "A" + "B" will not return a valid result, as you can't really add two letters (to concatenate them, use the concatenation operator &).  However, all type conversions are automatically done by the script interpreter when there is need to do so.

Expressions

The language supports arbitrary complex expressions. All usual operators are supported. The precedence of operations is as follows (with operations being higher in the list being carried out before those lower in the list, e.g. multiplications are done before additions.
  • expressions in parenthesis
  • not, unary minus
  • *, /, % (modulus, as in C)
  • +, -, & (string concatenation)
  • ==, !=, <>, <, >, <=, >=, contains (strings!), startswith (strings!)
  • and
  • or
For example, "not a == b" probably returns not what you intended. The script processor will first evaluate "not a" and then compare the resulting boolean to the value of b. What you probably intended to do is "not (a == b)". And if you just want to test for inequality, we highly suggest to use "!=" or "<>". Both are exactly the same and are provided so that you can pick whichever you like best. So inquality of a and b should be tested as "a <> b". The "not" operator should be reserved to cases where it actually is needed to form a complex boolean expression. In those cases, parenthesis are highly recommended.

Functions

RainerScript supports a currently quite limited set of functions:

  • getenv(str) - like the OS call, returns the value of the environment variable, if it exists. Returns an empty string if it does not exist.
  • strlen(str) - returns the length of the provided string
  • tolower(str) - converts the provided string into lowercase

The following example can be used to build a dynamic filter based on some environment variable:

if $msg contains getenv('TRIGGERVAR') then /path/to/errfile

[rsyslog.conf overview] [manual index] [rsyslog site]

This documentation is part of the rsyslog project.
Copyright © 2008, 2009 by Rainer Gerhards and Adiscon. Released under the GNU GPL version 3 or higher.



Only logged in users are allowed to comment. register/log in
Back to the start page
 rsyslog Sponsors
 
Functionality looking for Sponsors
rsyslog sponsoring
Click here for more information


 Search
 
Google

 Last Forum Posts
 · Re: Kernel logging
Debian released a security fix yesterday. Kernel version is now 2 ...
· Newbie
Hi allhow i can know what type of message are used by a local fac ...
· Police: Baby Starved as Couple Nurtured ...
Hi kb.monitorware.com!A South Korean couple addicted to the Inter ...
· Ubuntu 9.10 + rsyslog + iptables
Hi,I'm trying to get rsyslog running on ubuntu 9.10 to output my ...
· Re: Kernel logging
I have the same issues with rsyslog and debian linux-image-2.6.26 ...
· Re: Errors during compilation with 5.4.0 ...
It turns out there was a problem with the configuration file I wa ...
· Re: Errors during compilation with 5.4.0 ...
I've tried building and installing on another system: 32-bit Cent ...
· Re: Errors during compilation with 5.4.0 ...
Burn,Did you get similar errors when you compiled? I'm wondering ...

:: Syndication: ::
Page created in 0.190325975418 seconds.