Highlighted
Absent Member.
Absent Member.
422 views

implement custom.js in Generic Event Collector


Sentinel Log Manager 1.2
Collector: Generic Event Collector

Hello,

sorry for this low end question, but I'm going crazy. I try to
implement a custom.js to get some data into CustomerVar fields.

My problem, if I start with simple code and implement the file like
described here http://tinyurl.com/cgvtaab. If I checked my Sentinel Log
Manager no additional data was writen to the event record. I stripped my
code to a realy simple example, to exclude errors here:

Collector.prototype.customInit = function() {
this.protoEvt.CustomerVar21 = "test log";
return true;
}

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

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

The collector runs in "custom" execution mode.

Thanks for help
Michael


--
michaelkuerschner
------------------------------------------------------------------------
michaelkuerschner's Profile: https://forums.netiq.com/member.php?userid=6939
View this thread: https://forums.netiq.com/showthread.php?t=50155

0 Likes
7 Replies
Highlighted
Absent Member.
Absent Member.

Using customInit is, I believe, the wrong place for this type of code.
Try customParse which runs after the parse method. customInit is made
more for things that only happen when the collector starts (meaning not
with every event that comes in). Maybe you intended that, but the better
way to test customization (in my opinion) is to test with customParse
since then you can watch happenings with every event within the debugger.

Typing about the debugger, have you tried using that already? When in
custom mode the debugger (if not the CM log file) does a decent job of
showing the events before/after any custom code which can be really nice
for troubleshooting; you cannot (or could not last time I checked) step
through the custom code itself within the debugger, but there's an
enhancement/bug in for that.

--
Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below...
0 Likes
Highlighted
Absent Member.
Absent Member.


Hi ab,

ab;241503 Wrote:
> Using customInit is, I believe, the wrong place for this type of code.
> Try customParse which runs after the parse method. customInit is made
> more for things that only happen when the collector starts (meaning not
> with every event that comes in). Maybe you intended that, but the
> better
> way to test customization (in my opinion) is to test with customParse
> since then you can watch happenings with every event within the
> debugger.
>


Ok I will try this.

ab;241503 Wrote:
>
> Typing about the debugger, have you tried using that already? When in
> custom mode the debugger (if not the CM log file) does a decent job of
> showing the events before/after any custom code which can be really
> nice
> for troubleshooting; you cannot (or could not last time I checked) step
> through the custom code itself within the debugger, but there's an
> enhancement/bug in for that.
>


The debugger option are not available in the ESM menu for the collector.
The menu entry is deactivated.

Regards,
Michael


--
michaelkuerschner
------------------------------------------------------------------------
michaelkuerschner's Profile: https://forums.netiq.com/member.php?userid=6939
View this thread: https://forums.netiq.com/showthread.php?t=50155

0 Likes
Highlighted
Absent Member.
Absent Member.


Hi Michael,

The debugger is only grayed out when your collector is started. If you
stop the collector you can start it again in debug mode. Make sure you
start your event source as well to receive data.
You can step through the custom code, so you can see what happens
exactly.

Another thing to keep an eye on is what variable you use.
I never used the this.protoEvt.. before so it might work.
I know for sure that e.CustomVar21 = '..' should work.
You can also use, for instance, this.cv21 and make a custom_Rec2Evt.map
which contains: CustomerVar21,cv21
You have to put your code in customParse, customInit is only run by the
start of the collector and is normally used to initialize variables or
maps.

Hope this helps,
Anco


--
jcvader1
------------------------------------------------------------------------
jcvader1's Profile: https://forums.netiq.com/member.php?userid=502
View this thread: https://forums.netiq.com/showthread.php?t=50155

0 Likes
Highlighted
Absent Member.
Absent Member.


Hi Anco,

thanks for your support. Yes your explanations helps a lot. I can run
the debugger now.

Regards,
Michael


--
michaelkuerschner
------------------------------------------------------------------------
michaelkuerschner's Profile: https://forums.netiq.com/member.php?userid=6939
View this thread: https://forums.netiq.com/showthread.php?t=50155

0 Likes
Highlighted
Absent Member.
Absent Member.


michaelkuerschner;241495 Wrote:
> Sentinel Log Manager 1.2
> Collector: Generic Event Collector
>
> Hello,
>
> sorry for this low end question, but I'm going crazy. I try to
> implement a custom.js to get some data into CustomerVar fields.
>
> My problem, if I start with simple code and implement the file like
> described here http://tinyurl.com/cgvtaab. If I checked my Sentinel Log
> Manager no additional data was writen to the event record. I stripped my
> code to a realy simple example, to exclude errors here:
>
> Collector.prototype.customInit = function() {
> this.protoEvt.CustomerVar21 = "test log";
> return true;
> }
>
> Record.prototype.customPreparse = function(e) {
> return true;
> }
>
> Record.prototype.customParse = function(e) {
> return true;
> }
>
> The collector runs in "custom" execution mode.
>
> Thanks for help
> Michael


Dumb question but since you didn't call it out - did you change the
collector's run mode to 'Custom' from 'Release'?


--
brandon.langley
------------------------------------------------------------------------
brandon.langley's Profile: https://forums.netiq.com/member.php?userid=350
View this thread: https://forums.netiq.com/showthread.php?t=50155

0 Likes
Highlighted
Absent Member.
Absent Member.


brandon.langley;241533 Wrote:
> Dumb question but since you didn't call it out - did you change the
> collector's run mode to 'Custom' from 'Release'?


Hi brandon.langley,

yes I changed te collectors mode to custom. The collector restarts
after this step.

Regards,
Michael


--
michaelkuerschner
------------------------------------------------------------------------
michaelkuerschner's Profile: https://forums.netiq.com/member.php?userid=6939
View this thread: https://forums.netiq.com/showthread.php?t=50155

0 Likes
Highlighted
Absent Member.
Absent Member.


Hi folks,

Couple quick things:

1) You were absolutely correct to put your code in customInit() as you
originally did - commenters are correct that the init code is only run
on startup, but in this case what you're doing is modifying the static
global protoEvt, which is the template on which all subsequent Events
are based. If you do run through this in the debugger, then what you
should see is that immediately after the 'curEvt = new
Event(instance.protoEvt)' line in main.js (which should be at the bottom
of your assembled Collector), your 'curEvt' global variable should have
that CustomerVar21 set in it. Further, when you get to the Event.send()
bit, the Event you are constructing should have that pre-set. You can of
course look at the protoEvt object in the debugger as well to make sure
that it actually was modified by your customInit().

2) I saw that you actually did call out that you set Custom execution
mode, but you did not mention AFAIK that you did the 'Add Auxiliary
File' step to upload your edited custom.js into the Collector. Can we
assume you did that?

BTW, just a tip on the debugger: read through:
http://www.novell.com/developer/plugin-sdk/collector_debug.html
Note the bit about scrolling to the bottom of your file to find the main
loop - this is where all the action happens, so put your breakpoints
there (typically).


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

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.