DX Unified Infrastructure Management

 View Only
  • 1.  LUA script for pre-processing rules (database.open)

    Posted Apr 20, 2016 04:33 PM



    I am running this script in pre-processing to change the field (source) of the alarm (net_connect) with existing IPs in the table (CM_COMPUTER_SYSTEM).


    However, it presents this error:

    Apr 20 17: 26: 11: 496 [6904] in: PREPROCESSOR ERROR: scripts / company \ db: 5: attempt to index global 'database' (a nil value)



    hostname = event.hostname

    database.open ("provider = nis, driver = none; database = none")

    rs = database.query ("SELECT [name], [ip] FROM [CA_UIM]. [dbo]. [CM_COMPUTER_SYSTEM] WHERE [name] = '" ..hostname .. "'")

    for i = 1, # rs

         ip = (rs [i] .IP)

         event.source = ip

         return event


    database.Close ()


    If I run the script it makes the query perfectly. But when used in pre-processing does not work.


    NOTE: Using profile AO, I can only add IP in custom's field. The hostname field or source, can not be changed.


    What am I doing wrong?


    Thank you.

  • 2.  Re: LUA script for pre-processing rules (database.open)

    Posted Apr 20, 2016 07:47 PM

    And now what do I do?


    Note that only a subset of the lua methods are available to the pre-processing script. The following classes and methods are not available: exit, sleep, nimbus, pds, trigger, action, database, alarm and note. The trigger.state method through the state method is however available.

  • 3.  Re: LUA script for pre-processing rules (database.open)
    Best Answer

    Broadcom Employee
    Posted Jun 02, 2016 11:15 AM



    You will want to use alarm_enrichment for this process as this allows you to connect to  a database and then change the information you need.


    hope this helps.