Writing external output plugins
for RSysLog
IN 2 MINUTES
Rainer Gerhards
Write the plugin itself
• Choose any language you like
• Implement the pseudocode below
▫
▫
▫
▫

Messages arrive via stdin, one message per line
Read from stdin until EOF
Process each message read as you like
Terminate when EOF is reached

• That's it!
While not EOF(stdin) do {
    Read msg from stdin
    Process msg
}
Rainer Gerhards, http://blog.gerhards.net
Make RsysLog call plugin
• Regular filtering applies (as with any action)
• You can specify message format via a template
• Use omprog for the call

module(load=”omprog) # needed only once in config!
if $rawmsg contains “sometrigger” then
   action(type=”omprog”
          binary=”/path/to/your/plugin”)

Rainer Gerhards, http://blog.gerhards.net
Optional: debugging your plugin
• If something doesn't work, it's best to debug outside
of rsyslog
• Do this as you usually debug your programs in that
language
• For example, do
$ echo “testmessage” | /path/to/your/plugin

• Questions about the plugin interface or plugin
integration? Visit
http://kb.monitorware.com/external-plugins-f53.html
Rainer Gerhards, http://blog.gerhards.net
Want to know more details?
• There is an additional presentation available at
http://www.slideshare.net/rainergerhards1/external-plugins

• The complete interface specification can be found
right inside the source repository:
https://github.com/rsyslog/rsyslog/blob/master/plugins/external/INTERFACE.md

• Check out the copy-templates
▫ Available for an increasing number of languages
▫ More advanced interface handling
▫ Ready to be copied
▫ https://github.com/rsyslog/rsyslog/tree/master/plugins/external

Rainer Gerhards, http://blog.gerhards.net
Want to know more details?
• There is an additional presentation available at
http://www.slideshare.net/rainergerhards1/external-plugins

• The complete interface specification can be found
right inside the source repository:
https://github.com/rsyslog/rsyslog/blob/master/plugins/external/INTERFACE.md

• Check out the copy-templates
▫ Available for an increasing number of languages
▫ More advanced interface handling
▫ Ready to be copied
▫ https://github.com/rsyslog/rsyslog/tree/master/plugins/external

Rainer Gerhards, http://blog.gerhards.net

Writing rsyslog Plugins in 2 Minutes

  • 1.
    Writing external outputplugins for RSysLog IN 2 MINUTES Rainer Gerhards
  • 2.
    Write the pluginitself • Choose any language you like • Implement the pseudocode below ▫ ▫ ▫ ▫ Messages arrive via stdin, one message per line Read from stdin until EOF Process each message read as you like Terminate when EOF is reached • That's it! While not EOF(stdin) do {     Read msg from stdin     Process msg } Rainer Gerhards, http://blog.gerhards.net
  • 3.
    Make RsysLog callplugin • Regular filtering applies (as with any action) • You can specify message format via a template • Use omprog for the call module(load=”omprog) # needed only once in config! if $rawmsg contains “sometrigger” then    action(type=”omprog”           binary=”/path/to/your/plugin”) Rainer Gerhards, http://blog.gerhards.net
  • 4.
    Optional: debugging yourplugin • If something doesn't work, it's best to debug outside of rsyslog • Do this as you usually debug your programs in that language • For example, do $ echo “testmessage” | /path/to/your/plugin • Questions about the plugin interface or plugin integration? Visit http://kb.monitorware.com/external-plugins-f53.html Rainer Gerhards, http://blog.gerhards.net
  • 5.
    Want to knowmore details? • There is an additional presentation available at http://www.slideshare.net/rainergerhards1/external-plugins • The complete interface specification can be found right inside the source repository: https://github.com/rsyslog/rsyslog/blob/master/plugins/external/INTERFACE.md • Check out the copy-templates ▫ Available for an increasing number of languages ▫ More advanced interface handling ▫ Ready to be copied ▫ https://github.com/rsyslog/rsyslog/tree/master/plugins/external Rainer Gerhards, http://blog.gerhards.net
  • 6.
    Want to knowmore details? • There is an additional presentation available at http://www.slideshare.net/rainergerhards1/external-plugins • The complete interface specification can be found right inside the source repository: https://github.com/rsyslog/rsyslog/blob/master/plugins/external/INTERFACE.md • Check out the copy-templates ▫ Available for an increasing number of languages ▫ More advanced interface handling ▫ Ready to be copied ▫ https://github.com/rsyslog/rsyslog/tree/master/plugins/external Rainer Gerhards, http://blog.gerhards.net