NetIQ Operations Center - Tips for writing scripts

NetIQ Operations Center - Tips for writing scripts

I recently was helping a customer with their implementation of NetIQ Operations Center (NOC).   They were leveraging the feature to have custom properties on elements and were using a script to automatically generate a property based on the output of the script.  I have blogged about this feature before HERE, but the basics is, suppose you wanted a property on the element that was automatically updated when users looked at it, something like the total of children elements, or some other details.  The idea is, write a script, place it in the computed property settings and it does the work for you.

Anyways, the customer asked about converting data, such as a long integer to a date.  Other requests I've had have been around making the value a specific type.   For this blog, it is more about tips for scripting and not computed properties.

Typically you have an idea what the script will do such as access a database, open a file, get the current date/time, etc, etc, etc (most of which you do NOT want to do within a Custom Property).  Pretty much all of that stuff if "java" related and not NOC related.  What I mean by that is, in order to get the current date/time, you use java script and make a java call.   To test this, you have a few options such as creating a right-click operation, or most of the time, I use the noc\bin\fscript utility.   Start fscript and at the js> prompt, type in the following:


var currentDate = new java.util.Date()


The above line will create a variable called currentDate and it will set it to the current date/time.  Time out you say?  Where did that come from?   Java has the API documented and available on the web, just use THIS LINK to see them.   The top left shows the classes available (ie; java.util).  When you click one, it shows the methods you can call in the bottom left (ie: Date).

If you look further (ie: click on the java.util then click on Date), you will see the other methods (functions) on the right that you can call with the new date variable.  If you just type in currentDate at the js> prompt, it will show you a textual string.  Here are some examples of things you can try out.


currentDate.getTime()
currentDate.getHours()


While date is "Deprecated" (meaning it is still there, but it is marked as something that will be removed at some future java release), it is usually an easy one to demonstrate.  FYI, it has been deprecated for over over 5 years.  The recommendation if you are wondering is to use java.util.Calendar.

Anyways, you can use the fscript utility to do testing, even math

js> var x = (1*3)+27/2
js> x
16.5

I have used it to verify the steps to open files, send emails, etc.   The only thing really missing is access to real elements and alarms.   Typically that is not a problem, you can nail down those final details in a right-click operation or the debugger.

I have other blogs on scripting, the debugger, automations and other topics on the fscript utility.  Feel free to browse other blogs for more details.

Standard disclaimer:  Don't do this on a production system, be careful with what you do, a computer is silly, it will do exactly what you tell it to do, not what you meant to do.
Tags (2)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2015-05-22 18:27
Updated by:
 
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.