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  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
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?
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.
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.