Anonymous_User Absent Member.
Absent Member.
285 views

From Steve Zeng: collector/jdbc connector won't start


Hi,

when i develop a database collector to collect bussiness database
logs about oracle for our customer , i use JDBC to connect to remote
oracle database, after i add database collector / jdbc connector /
database event source in SCC, i found i can not startup any of these
plugins, why? can database collector debug? the following codes is my
collector codes, additions, can anyone provide me a detail step by step
guide for database collector?


sqlquery.base
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT TOP %d * FROM ts_querybillsigned_log WHERE REQUEST_TM > %s

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

release.js
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Collector.prototype.initialize = function() {
this.PARSER.getOffsetData = function(input) {
if (typeof input.RXMap != "undefined") {
return input.RXMap.REQUEST_TM;
}
};
conn.addParser(this.PARSER.getOffsetData);
return true;
};

Collector.prototype.cleanup = function() {
return true;
};


Connector.prototype.sendQuery = function() {
return true;
};


Record.prototype.preParse = function(e) {
if (this.CONNECTION_ERROR != null || typeof this.RXMap == "undefined")
{ return false; }

if (this.CONNECTION_METHOD == "DATABASE") {

for (var field in this.RXMap) {
this[field] = this.RXMap[field];
}

return true;
};

Record.prototype.parse = function(e) {

this.iuid = this.LOG_ID;
this.cv30 = this.METHODNAME;
this.cv31 = this.CLIENTNAME;
this.cv32 = this.CLIENTMAC;
this.cv33 = this.CLIENTIP;
this.cv34 = this.QUERYTYPE;
this.cv35 = this.SIGNEDTYPE;
var detstring =
this.RXMap.REQUEST_TM.replace(/(\d+)\/(\d+)\/(\d{4})\s(\S+)/, "$1/$2/$3
$4 GMT");
var dt = new Date(detstring);
e.setDeviceEventTime(dt);
return true;
};


Record.prototype.normalize = function(e) {
instance.SEND_EVENT =true;
return true;
};

Record.prototype.postParse = function(e) {
return true;
};


Record.prototype.reply = function(e) {
return true;
};


--
DCorlette
------------------------------------------------------------------------
DCorlette's Profile: https://forums.netiq.com/member.php?userid=323
View this thread: https://forums.netiq.com/showthread.php?t=50302

0 Likes
1 Reply
Anonymous_User Absent Member.
Absent Member.

Re: From Steve Zeng: collector/jdbc connector won't start


Hi Steve,

I believe you've gotten closer to tracking down your issue, but there
are a couple style issues here I thought I'd comment on for general
consumption.

1) Your Collector will issue a query against the database, then it will
return a Record object. Each column in the database is mapped to the
RXMap object within that Record, in the form 'rec.RXMap.METHODNAME',
'rec.RXMap.CLIENTIP', etc. Since 'parse()' is a member function of
Record, 'rec' in this case is simply 'this'.

2) You then proceed to copy all of those fields from
this.RXMap.something to this.something, and then you proceed to copy
several fields from this.something to
this.somethingelsethatlookslikeasentinelfield. All of this is completely
unnecessary.

3) As long as you don't have to do any further processing on the values
in the source data (as with REQUEST_TM), you can skip everything in
preParse() and all of the this.* = this.* stuff in parse(), and simply
put entries like this in Rec2Evt.map:

iuid,RXMap.LOG_ID
cv30,RXMap.METHODNAME
cv31,RXMAP.CLIENTNAME
.....

The Collector will automatically copy the information from the fields on
the RHS of Rec2Evt.map into the Sentinel Event fields on the LHS of
Rec2Evt.map.

Thus your entire Collector can be boiled down to this:

Collector.prototype.initialize = function() {
this.PARSER.getOffsetData = function(input) {
if (typeof input.RXMap != "undefined") {
return input.RXMap.REQUEST_TM;
}
conn.addParser(this.PARSER.getOffsetData);
return true;
};

Record.prototype.parse = function(e) {
var dt = new Date(this.RXMap.REQUEST_TM.substr(0,
this.RXMap.REQUEST_TM.length-2));
e.setDeviceEventTime(dt);
return true;
};


--
DCorlette
------------------------------------------------------------------------
DCorlette's Profile: https://forums.netiq.com/member.php?userid=323
View this thread: https://forums.netiq.com/showthread.php?t=50302

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.