NetIQ Operations Center – Creating alarms programmatically

Tobin Isenberg

By: Tobin Isenberg

January 7, 2014 4:47 pm

Reads: 288

Comments:0

Rating:0

From time to time there is a need to create a custom alarm inside of Operations Center either due to some specific process you are trying to set up or due to NOC not having an adapter to a third party product.   I assume that you have read THIS BLOG on the different integration options and still need other options.   While there are still even more options, let’s assume you want to use a Universal Script Adapter and integrate with the third party product via java script.  Again, there are several options, this is just one of them.

When I have done this in the past, I usually create a bit more of an extravagant script that runs within the scope of the Script Adapter.   There is a property on the adapter called script.onStarted, meaning, when you start the adapter, it blindly will start up a java script.  For example, if you put this in the property field, it will start the script (if it exists).

load( ‘myScript.fs’ );

When this script starts, it is run in context to the NOC server and there are some predefined variables such as a variable to work directly with the adapter.   Depending on what you want to do in the script, you may just run through a bunch of lines in the script (rarely) and end it, or you are going to set up a while loop to process a bunch of things, go to sleep, wake up and process more.  If you do the “while” option, you need to make sure you check the adapter.status from time to time and allow your script to end if the adapter is stopped.   The adapter assumes you are doing all the work, it just starts the script and forgets about it.  If you would like some tips on this, please leave a comment below or send me an email.  For this blog, I’m just going to go straight into how to creating the alarm via java script.

The method we are going to use is adapter.createAlarm(), it requires a few variables.  An example of what it would look like in your code would be:

adapter.createAlarm(“Sync”, Flds, Vals, null );

The first parm “Sync”, is the class of the alarm you are sending.   While you can put anything in there, in most cases you have this hardcoded.  If you look at the adapter settings, this is an actual setting for the class.   Most of the time you are sending in a new alarm or an update to an alarm.   If you will only ever send new alarms (or your script is more sophisticated), you can make this anything such as router, disk, etc.   I typically do “Sync” and have a field within the alarm that contains this class.  Again, by doing the pre-set, it will search for the alarm based on the ID to update it, if it does not exists, it will create a new one.

The Fld parm is an array.  This array holds the list of all the columns/fields in the alarm.  For instance, hostname, NIC, severity, Description.  This is the textual name of the individual alarm column name.  There are only a few reserved fields such as ID, element, lastUpdated and a couple others.

The Val parm is an array also.  This contains the values for each of the “Fld”.  You must take care in the ordering of items in the array, the matching up between Fld and Val by postion in the array.  For example, whatever is in array position of Val[4], it will get related to Fld[4].

The last parm is always null.  I used to know what this was for specifically, but all I can remember is that it is something internally on the adapter that does not apply to this specific use case, so…. leave it null.

Here is a simple example of a script on started for a Universal Adapter.

var Fld = new Array();  /* array to hold all alarm fields */
var Val = new Array(); /* array to hold all values of fields */

/* assigning values to the arrays, remember array positions need to line up between Fld and Val arrays */

Fld[0] = new java.lang.String( “originating_event_id” );
Fld[1] = new java.lang.String( “DB_name” );
Fld[2] = new java.lang.String( “severity”);

Val[0] = new java.lang.String( “123″ );
Val[1] = new java.lang.String( “ora.netiq.com” );
Val[2] = new java.lang.String( “OK” );

/* Log statement to see that it is running */

formula.log.info( “Creating alarm…” );

adapter.createAlarm( “Sync”, Fld, Val, null );

This is probably the most simplistic example.   There are other things to do such as mining the third party product, while loops, data checking, logic to determine severity, etc, etc, etc.  The purpose of this blog is to get you started.  For more specific implementation and/or best practices, I advise you to work with the Consulting group.

 

- Tobin

 

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Tags: , , , ,
Categories: Operations Center, Technical Solutions

Disclaimer: As with everything else at NetIQ Cool Solutions, this content is definitely not supported by NetIQ, so Customer Support will not be able to help you if it has any adverse effect on your environment.  It just worked for at least one person, and perhaps it will be useful for you too.  Be sure to test in a non-production environment.

Comment