|
One of the common tasks while working with Netcool events is to enrich them by updating some of the event's properties with data retrieved from another system. We provide two sample enrichment implementations with the Netcool plugin for RapidOSS so that implementing enrichment is as easy as tweaking the sample scripts provided.
Lookup Data for EnrichmentIn our sample scenario, the data to be looked up for enrichment is stored in a MYSQL database.
Two Enrichment ScenariosThe difference between the two implementations is where the look up data is retrieved for each Netcool event processed:
"Lookup from Database" ScenarioHere are the steps for the first enrichment implementation:
EnrichmentProcessor ScriptThis script has 2 responsibilities:
enrichFromDb operation of EnrichmentProcessor script implements this functionality.
"Lookup from RapidOSS" Scenario
Here are the steps for the second enrichment implementation:
Database Connector ScriptThis script will periodically retrieve all rows of the DeviceSla table into RapidOSS my creating instances of DeviceSla model. It is possible to retrieve only the updated rows at each polling of the database, if the table supports identifying recent inserts or updates (via a timestamp field). In the sample scenario, table structure has no timestamp column and the data is small enough to make it feasible to retrieve all rows at every poll. The data can also reside somewhere other than a database. In this case another type of connector should be used. EnrichmentProcessor ScriptThis script has 2 responsibilities:
enrichFromRI operation of enrichment script implements this functionality. Installation of Enrichment Module
def prepareDBTables(){
def dsConn = DatabaseConnection.get(name:"mysql");
if(dsConn == null){
dsConn = DatabaseConnection.add(name:"mysql", driver:"com.mysql.jdbc.Driver",url:"jdbc:mysql://localhost/test", username:"root", userPassword:"root");
}
def dbDs = DatabaseDatasource.add(connection:dsConn,name:"DMNDB");
try{
dbDs.runUpdate("drop table deviceSla");
}
catch(e){}
dbDs.runUpdate("create table deviceSla (ID int(11) NOT NULL,NAME varchar(50) NOT NULL,SLALEVEL varchar(20), LOCATION varchar(50), STATUS varchar(10), CONTACT varchar(50), PRIMARY KEY (ID));");
dbDs.runUpdate("INSERT INTO deviceSla (id, name, slalevel, location, status, contact) VALUES(1,'router1', 'gold', 'paris', 'down', 'david')");
dbDs.runUpdate("INSERT INTO deviceSla (id, name, slalevel, location, status, contact) VALUES(2,'router2', 'gold', 'paris', 'down', 'david')");
dbDs.runUpdate("INSERT INTO deviceSla (id, name, slalevel, location, status, contact) VALUES(3,'switch1', 'gold', 'london', 'available', 'joe')");
dbDs.runUpdate("INSERT INTO deviceSla (id, name, slalevel, location, status, contact) VALUES(4,'switch2', 'silver', 'london', 'down', 'joe')");
dbDs.runUpdate("INSERT INTO deviceSla (id, name, slalevel, location, status, contact) VALUES(5,'host1', 'gold', 'dallas', 'down', 'jill')");
dbDs.runUpdate("INSERT INTO deviceSla (id, name, slalevel, location, status, contact) VALUES(6,'host2', 'silver', 'dallas', 'available', 'jill')");
}
|
Add Comment