Extending SiteScope’s monitoring capabilities with SiteScope 11.20

Hello from HP Discover, HP’s user conference which is taking place as we speak in Las Vegas! We are very excited to announce the release of SiteScope 11.20. This release has a lot of great new features, new monitoring content and tons of enhancements. You can take a look at the release notes for more details.

 

This post, compliments of Erez Holzman, SiteScope R&D Manager, focuses on custom monitors - one of the new exciting features in this release which allows our customers and partners to easily extend the monitoring capabilities of SiteScope based on their specific needs.

 

To start creating a new custom monitor you will need to select one of the following Custom Monitors types:

 

  1. Custom Monitor – retrieve data from any available source using custom Java Code

  2. Log File Custom Monitor – retrieve data from log files

  3. DB Query Custom Monitor – retrieve data using database queries

  4. WMI Query Custom Monitor – retrieve data using Windows Management Instrumentation queries

In the New Monitor dialog select one of the four monitors available in the Customizable category:

 

 

Picture1.png

 

 

We’ll use a simple example, to take you through the life cycle of developing new Custom Monitor for SiteScope. Let’s say you would like to monitor your shipments table and get alerts if there are late shipments or there are more than 10 shipments in the next 3 days.

 

We’ll start by creating a new Custom Database monitor and enter all the database parameters:

 

 

Picture2.png

 

 

The next step is to create the queries. You can create one or more queries which would later be available via the data processing script.

 

 

Picture3.png

 

 

Now, we need to tell SiteScope what to do with the results of the queries. This is done using JavaScript, a common and well known scripting language and SiteScope documented interfaces. You can also import and leverage any regular Java class. You can start with the default sample code and tweak it to fit your needs.

 

 

Picture4.png

 

 

Here is the complete code I used:

 

Code snippet /*************************** Custom Database Monitor Script Example ***************************/

Import are used to access any regular Java classes

// Java imports

importPackage(java.lang);

                importPackage(java.text);     

                importPackage(java.util);

 

                // Logger for debug messages. The logger writes messages to <SiteScope>\logs\custom_monitors\custom_monitor.log

                var logger = myContext.getMonitorLog();

                logger.info("Processing Orders data");

myContext is a special Java object that we used in the monitor it gives the access to the collected data and also for assigning new counters and other data.

getInputData used to access the returned data, number or rows in the query and column values

                var query0Size = myContext.getInputData().getQueryResultSize(0);

                var ordersInWarning = 0;

                var ordersInError = 0;

                var queryResults = myContext.getInputData();

               

                SimpleDateFormat is a regular Java class used to parse date values

                var sdf = new SimpleDateFormat("yyyy-MM-dd");

                var now = new Date(System.currentTimeMillis());

               

               

// iterate through the returned values

                var index = 0;        

                while(index < query0Size) {                                        

                   var col1Value = queryResults.getValueAt(0 , index , "ORDER_SHIP_DATE");

                   var shipDate = sdf.parse(col1Value);

                   var dif = (shipDate.getTime() - now.getTime())/(1000*60*60*24);

   // if ship date is earlier than now, this order is late!

                   if(dif < 0){

                       ordersInError++;

                   }

   // if ship date is within the next 3 days, increments the warning counter

                   if(dif <= 3 && dif > 0){

                       ordersInWarning++;

                   }

                   index++;                

                } 

We use getScriptResult to add counters. In this example “Late Ship Orders” and “3 Days Ship Orders” will be the monitor counters        

                myContext.getScriptResult().setValue("Late Ship Orders" , ordersInError); 

                myContext.getScriptResult().setValue("3 Days Ship Orders" , ordersInWarning); 

 

/*********************************************************************************/

 

After you complete editing your processing script, save the monitor and the new counters will be added to the threshold panel and to the dashboard. Now you can set thresholds values and see the status of your orders in the dashboard.

 

 Picture5.png

  

 

Picture6.png

 

This is just a simple example, but you can see the power of this feature. Stay tuned for the next blog post  which will show you how to share content developed for SiteScope using the new HP Live Network community - https://hpln.hp.com/group/sitescope

 

Leave a Comment

We encourage you to share your comments on this post. Comments are moderated and will be reviewed
and posted as promptly as possible during regular business hours

To ensure your comment is published, be sure to follow the Community Guidelines.

Be sure to enter a unique name. You can't reuse a name that's already in use.
Be sure to enter a unique email address. You can't reuse an email address that's already in use.
Type the characters you see in the picture above.Type the words you hear.
Search
Showing results for 
Search instead for 
Do you mean 
About the Author
Beth Parker is a Product Marketing Manager for HP Software. Beth is responsible for outbound marketing and sales enablement for the HP Syst...
Featured


Follow Us
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.