DX Unified Infrastructure Management

  • 1.  LUA Script Query

    Posted Sep 16, 2015 08:32 AM

    Hi,

     

    I am trying to write a simple lua script for CPU utilization alert. When the message string matches CPU this script should run. I need some help around passing the value of the server in question to the script. How to achieve this. For instance, server 'abc' has triggered a cpu alert, how to pass the name of the server to the script so that I can generate a new alert with the utilization details. Will the below line work when the string matches?

     

    controller = nimbus.request("controller","get_info")

     

    Let me know if this will work as I am trying to learn lua and this will really help me a lot.

     

    -kag



  • 2.  Re: LUA Script Query

    Posted Sep 16, 2015 09:56 AM

    Hello!

     

    If you run you script from profiles (not event pre-processing rules) you can use:

    --start script

    a = alarm.get ()

    --you code

    myvar1 = a.hostname

    myvar2 = a.source

    myvar3 = a.message

    ................

    message = "my message "..myvar3

    hostname = "my_new_hostname"

    source = "my_new_source"

    supp_key = "my_new_suppkey"

    --and more

    --------------

    nimbus.alarm (a.level, message, supp_key,"", source)          --It will create a new! alarm.

    --end of script

     

    If you run you script from event pre-processing rules you can use:

    --start script

    --you code

    myvar1 = event.hostname

    myvar2 = event.source

    myvar3 = event.supp_key

    --and more

    return event                      --it will paste modified event.

    --end script


    See also: http://docs.nimsoft.com/prodhelp/en_US/Probes/Catalog/nas/4.2/index.htm

    >>The NAS Extentions to LuaLanguage Extension



    As returned from alarm.list(), alarm.get():

     

    .nimid- unique Nimsoft Id
    .nimts- timestamp when the alarm was created (at source)
    .source- source of the alarm (typically ip-address)
    .hostname- resolved name (robotname or ip-address to name resolution)
    .level- severity level (0-5)
    .severity- textual representation of the severity level.
    .supptime- timestamp of last suppression.
    .sid- subsystem identification.
    .subsys- subsystem string resolved from sid.
    .message- alarm message text.
    .suppcount- number of times event has been suppressed.
    .supp_key- suppression identification key.
    .origin- origin of the alarm (stamped by nearest hub, or in some cases the robot.)
    .domain- name of originating Domain.
    .robot- name of the sending robot.
    .hub- name of the nearest hub to the sending robot.
    .nas- name of originating alarm server.
    .prid- name of probe issuing the alarm.
    .user_tag1- user tag 1 (as set by robot).
    .user_tag2- user tag 2 (as set by robot).
    .visible- flag for visibility (1 = visible)
    .aots- AO timestamp
    .arrival- timestamp when alarm arrived at NAS.
    .time_arrival- datetime of arrival.
    .time_supp- datetime of supptime.
    .time_origin- datetime of nimts.
    .assigned_at- datetime at assignment.
    .assigned_to- user alarm is assigned to.
    .assigned_by- the user who assigned the alarm.
    .tz_offset- timezone offset (seconds from GMT)
    .supp_id- checksum of suppression information.
    .change_id- checksum of message,severity and subsystem.

     

     

    Custom Pre-Processing

    The event table is placed into the LUA context prior to executing the "custom" pre-processing rule. You may alter (launder) the event by setting these fields: message, level, sid, source, hostname, user_tag1, user_tag2, visible, custom_1 through _5, supp_key, and origin. The following fields are present for the script to use:

     

    .source - source of the alarm (typically ip-address)

    .hostname - resolved name (robotname or ip-address to name resolution)

    .level - severity level (0-5)

    .sid - subsystem identification.

    .message - alarm message text.

    .origin - origin of the alarm (stamped by nearest hub, or in some cases the robot.)

    .domain - name of originating Nimsoft domain.

    .robot - name of the sending robot.

    .hub - name of the nearest hub to the sending robot.

    .prid - name of probe issuing the alarm.

    .user_tag1 - user tag 1 (as set by robot).

    .user_tag2 - user tag 2 (as set by robot).

    .supp_key - suppression identification key.

    .visible - flag for visibility (true = visible)