Documentation forKiwi Syslog Server NG

Scripting tutorial

This documentation is for legacy Kiwi Syslog Server versions 9.8.2 and older.

This tutorial demonstrates how to create a script and use it to search and replace text within a syslog message.

The scripting action is available only in the registered version of Kiwi Syslog Server Service Manager.

Each of the four tasks outlined below must be completed in sequential order to successfully create and execute the tutorial script.

Task 1: Create the script action in Setup

  1. Open Setup window from the File menu.
  2. Create a rule called Replace text.
  3. Add a Run Script action.
  4. Set the script file name to: ReplaceText.txt.
  5. Set the Script Description field to Replaces occurrences of "cat" with "dog".
  6. Set the Script Language to VBScript.
  7. Set the Field Read/Write permissions to:
    • Common fields: Read = Checked, Write = Checked
    • Other fields: Read = Unchecked, Write = Unchecked
    • Custom fields: Read = Unchecked, Write = Unchecked
  8. Click the Edit Script button to open the file in Notepad. Because the file does not exist, you will be prompted to create a file.
  9. Copy and paste the following script file into Notepad and Save.

    Function Main()
    ' Replace cat with dog within the message text field Fields.VarCleanMessageText = Replace(Fields.VarCleanMessageText, "cat", "dog")
    ' Return OK to tell syslog that the script ran correctly.
    Main = "OK"
    End Function

Task 2: Create the log to file actions

  1. Return to Replace Text rule created in Task 1.
  2. Add a Log to file action.
  3. Enter the Path and file name of log file as: MyCustomLog.txt in a folder.
  4. Leave the log file format as the default: Kiwi format ISO yyyy-mm-dd (Tabdelimited).
  5. Click the action and then press F4 to auto name the action Log to file.
  6. Add a Display action.
  7. Leave the display number as the default: Display 00 (Default).
  8. Click the action and then press F4 to auto name the action Display.

The Run script action should be listed above the Display and Log to file actions. If not, you can select the action and use the ^ toolbar button to move it up the list.

Your rule should look like this:

Rules

Rule: Replace Text

Filters

Actions

Run Script

Display

Log to file

Task 3: Test the script

  1. Select the Run Script action.
  2. Click the Test Setup button.
  3. Change the message text to read: The cat sat on the mat.
  4. Click the Show action button.
  5. Check the Show test results check box.
  6. Press the Test button.

After the script runs, the results open in Notepad. There you see the script variables. Check the VarCleanMessageText field and you should see the word "cat" has been changed to "dog."

Task 4: Test the script with SyslogGen

  1. To apply the rule changes, click OK on the Kiwi Syslog Server Setup window.
  2. Download SyslogGen from http://www.kiwisyslog.com/downloads.aspx and install it on the same machine as the Syslog Server.
  3. Set the send options to send message once. Set the destination to localhost (127.0.0.1).
  4. Set the message text to "This is a test. The cat sat on the mat."
  5. Press the Send button.

The message: "This is a test. The dog sat on the mat." is displayed.