Submit a ticketCall us

Get a crash course on Network Monitoring delivered right to your inbox
This free 7-day email course provides a primer to the philosophy, theory, and fundamental concepts involved in IT monitoring. Lessons will explain not only how to perform various monitoring tasks, but why and when you should use them. Sign up now.

Home > Success Center > Kiwi Syslog Server > Kiwi Syslog Server Administrator Guide > Scripting resources > Scripting tutorial

Scripting tutorial

This tutorial will show you how to create your own script and use it to search and replace text within a syslog message.

The scripting action is available only in the registered version.

Task 1: Create the script action

  1. Create a new rule called "Replace text" .
  2. Add a new Run Script action.
  3. Set the script file name to: ReplaceText.txt.
  4. Set the script description to: Replaces occurrences of "cat" with "dog". Set the script language to VBScript.
  5. Set the field read/write permissions to:
    • Common fields: Read=Yes, Write=Yes
    • Other fields: Read=No, Write=No
    • Custom fields: Read=No, Write=No
  6. Press the Edit Script button to open the file in Notepad. Since the file doesn't exist, you will be prompted to create a new file.
  7. Copy and paste the following script file into Notepad and then choose File > 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 actions

  1. Add a new Log to file action.
  2. Set the file name to "MyCustomLog.txt" in the folder of your choice.
  3. Leave the file format as default.
  4. Click the action and then press F4 to auto name the action "Log to file".
  5. Add a new Display action.
  6. Leave the display number as default.
  7. Click the action and then press F4 to auto name the action "Display".

The Run script action should be above the display and log to file actions. If not, you can move it up the list by selecting the action and using the ^ toolbar button.

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.

Once the script runs, the results are opened in Notepad. There you will be able to see all 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. Apply the new rule changes by clicking OK on the Kiwi Syslog Server Setup window. You will then have just the main syslog window showing.
  2. Download SyslogGen from http://www.kiwisyslog.com/downloads.aspx 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 be: This is a test. The cat sat on the mat. Press the Send button

You should now see this message appear on the display "This is a test. The dog sat on the mat."

Last modified
12:40, 2 Mar 2017

Tags

Classifications

Public