Submit a ticketCall us

Webinar: Web Help Desk for HR, Facilities and Accounting Departments
This webinar will focus on use cases for HR, Facilities and Accounting.

Having a unified ticketing and asset management system for all the departments in your company can provide end-users with a seamless experience and make things easier for your IT team. Yet, with different business tasks and objectives, many departments don’t fully understand the capabilities of Web Help Desk and how the software can be customized for effective use in their departments.
Register Now.

Home > Success Center > Kiwi Syslog Server > Kiwi Syslog Server Administrator Guide > Add rules, filters, and actions > Add an action > Add an action to run a script

Add an action to run a script

You can add an action to run a script to filter or parse the current message.

You can use the Run script action to run a parsing script that breaks the syslog message down into various sub-fields. The values can then be assigned to custom fields and logged to a database. Because each device manufacturer creates syslog messages in a different format, it is not possible to create a generic parser that will break up the message text into separate fields. You must write a custom script to parse the message text and then place it in the custom database fields. Example parsing scripts can be found in the \Scripts subdirectory in the Kiwi Syslog Server installation directory.

  1. From the Kiwi Syslog Service Manager, choose File > Setup.
  2. Add or locate the rule that the action applies to.
  3. Right-click the Actions node below the rule, and choose Add Action.
  4. Replace the default name with a descriptive name. (The name does not have to be unique.)
  5. From the Action menu, select Run Script.

  6. Specify the following options.

    Script file name

    Enter the path and file name of an existing script file or of the file to be created.

    Script description Describe the purpose or function or the script.
    Script language

    Select the scripting language.

    Windows Script provides script engines for the following languages, which have similar feature sets.

    • VBScript: a variation of Visual Basic or VBA (Visual Basic for Applications) used in MS Word and Excel.

    • JScript: a variation of Java Script used in web pages.

      Consider JScript if you are familiar with Java Script. Also, JScript is usually faster than VBScript at performing string manipulations.

    To use one of the following languages, you must install the Active Scripting engine for that language:

    • PerlScript
    • Python
    • RubyScript
    Edit script

    Click this button to open the script in a text editor. If the specified file does not exist, it is created.

    Modify the script and save your changes.

    Script file rules

    The script must always contain a function called Main(). No parameters are passed to the function, but a return value of OK must be passed back to indicate that the script ran successfully. If any value other that OK is returned, Syslog will assume an error has occurred in the script and place an entry in the error log. The value returned from the script function will also be included in the error log for later diagnoses.

    Each of the available script variables can be accessed from the Fields object.

    Example (VBScript):

    Function Main()
    ' Your code goes here 
    ' Set the return value 
    Main = "OK" 
    End Function

    Additional information on scripting

    For examples, descriptions of variables and functions, dictionaries, and a tutorial, see Scripting resources. Sample scripts are located in the \Scripts subdirectory in the Kiwi Syslog Server installation directory.

    Field Read/Write permissions

    Select the groups of fields that Kiwi Syslog Server can access:

    • When you grant read access to a group of fields, their values are copied into the script variables and are readable from within the script.
    • When you grant write access to a group of fields, their values are copied from the script variables and replace the equivalent program fields.

    Each time a script runs, the available message fields are copied to the script variables and back again upon completion of the script. The copying takes time and uses CPU cycles. To improve script performance, SolarWinds recommends granting read and write access only to the variables used in the script.

    For more information about the fields in each group, see Script variables.

  7. (Optional) Test the action.

    Select if you want to see any changes that the script makes to the variables.

    Kiwi Syslog Server attempts to run the specified script.

    If an error occurs, a message displays the error description and the line number on which it occurred.

    If you select the Show test results option and the script runs successfully, a dialog shows the variable values before and after the script ran. Use this to see what variable values the script changed.

  8. Click Apply to save the action.

Script file caching

During normal operation, the script files are cached after they have been read from disk. This improves the program speed and prevents additional I/O. If you modify the script externally and save it back to disk, the changes do not take effect until the file is reloaded.

If you run Kiwi Syslog Server as an application, do either of the following to reload the file:

  • Flush the cache. Choose File > Debug options > Clear the script file cache, or press Ctrl+F8 from the Service Manager console.
  • Restart the application.

If you run Kiwi Syslog Server as a service, stop and restart the service to reload the file.

When you test a script from the Kiwi Syslog Server Setup window, the script is not cached. Each script is freshly loaded before it is run.

Triggering a script on a regular basis

To trigger a script on a regular basis, you can:

Last modified
11:46, 2 Mar 2017

Tags

Classifications

Public