Documentation forKiwi Syslog Server

Create and execute scripts in KSS NG

The current version of Kiwi Syslog Server NG (KSS NG) only supports PowerShell scripts.

Learn how to create and executive scripts in KSS NG using the following script example. The script below searches and replaces text in a syslog message, replacing the word "cat" with "dog". Each of the tasks outlined below must be completed in sequential order to successfully create and execute the sample script.

Create the script

  1. Open a text editor and paste the following script.

    # Replace cat with dog within the message text field
    # Case insensitive replace 
    $Common.VarCleanMessageText = $Common.VarCleanMessageText -replace "cat", "dog"
    
    # OR
    # Case sensitive replace 
    $Common.VarCleanMessageText = $Common.VarCleanMessageText.Replace('Message','LOG(replaced)')
    
    
    # Return OK to indicate that the script ran correctly.
    $Main = "OK"
  2. Save the script file with a .ps1 extension. Choose a descriptive name for your script. The script in this example is my_script.ps1.

  3. Run the script locally to test the script. Open PowerShell, navigate to your script's directory, and use the following command. Use the name of the script file you just created.

    .\my_script.ps1
  4. Log in to KSS NG and navigate to Setup > Scripts.

  5. Click Add Script to upload the script to KSS NG.

Create the Run script action

  1. From the Kiwi Syslog Server NG navigation bar, choose Setup > Rules.

  2. Locate an existing rule. If the rule does not exist, add a rule and start the New Rule wizard.
  3. If you are adding an action to an existing rule, select the rule and click Edit. If you are creating a new rule, navigate to the Actions step of the New Rule wizard.
  4. Click Add Action. Define the action name in the provided field.
  5. In the Action drop down, select Run script.

  6. Select the script you previously uploaded and review the read and write permissions. Click Add.

  7. On the next page, click Apply to save all changes.

Check the script workflow

KSS NG executes actions within rules concurrently. Configure the order of execution by rearranging the rules.

Modify the message before display by reviewing the rule order.

Rules:

Rule 1: Replace Text

Filters: No filters

Actions: Run script

Rule 2: Display\log message

Filters: no filters

Actions: Log to file, Display