We cannot see log entries in the qos_processor.log to understand if our enrichment.rb script is working or not

Document ID : KB000010805
Last Modified Date : 14/02/2018
Show Technical Document Details
Introduction:

Using the enrichment.rb to enrich QoS data, the messages added with our own added $logger.info statements are not seen in the qos_processor.log.

 

Background:

It is possible to add log statements to the enrichment.rb ruby script to trace what is working or not working.

For more information on using the qos_processor, please see this documentation: Documentation on qos_processor

 

This Knowledge Base article discusses how to add log messages to a separate log file for debugging.

Please note that Technical Support cannot assist with writing custom scripts.  These steps should help you identify how to fix your custom script.

Environment:
UIM 8.33, 8.51Linux / WindowsDBMS: MySQL, Oracle, MS SQL
Instructions:

The following instructions detail how to debug an enrichment.rb script in a sandbox environment.  

1- Shorten the duration of the Monitor Enrichment Execution Interval to "1"

     Open Raw Configure for the "qos_processor" probe (hold down the CTRL key and right click the qos_processor probe to select "Raw Configure" from the right click context menu).

     Change the key under "setup" > monitor-enrichment-execution-interval to "1".

2- Modify your custom enrichment.rb script under: "/opt/nimsoft/probes/slm/qos_processor/scripts".

    Add or confirm  these entries at the top of the file:

     require 'java'

     require 'logger'

#  An extra log just for this script so that it is easier to debug

log = Logger.new('/opt/nimsoft/probes/slm/qos_processor/scripts/qosextra-log.txt',4,1024000)

log.level = Logger::INFO

#  log.level = Logger::INFO - set this to INFO for increased logging - default WARN

3- Add log.info statements to the appropriate sections to understand where the script is breaking.

    For example: 

if File.exist? "/opt/nimsoft/probes/slm/qos_processor/lib/mysql-connector-java-5.1.35.jar"

     log.info("Driver jar file exists !")

 

 

     require "/opt/nimsoft/probes/slm/qos_processor/lib/mysql-connector-java-5.1.35.jar"

...

else

 

    log.info("No jar file found ! Make sure you have /opt/nimsoft/probes/slm/qos_processor/lib/mysql-connector-java-5.1.35.jar file.")

 

and in the database connection section:

     begin

 

         dbserver=ip+":"+port

 

        url = driver+dbserver+"/"+db

        java.lang.Class.forName(driverClass, true, java.lang.Thread.currentThread.getContextClassLoader)

        log.info("About to connect...")

        con = java.sql.DriverManager.getConnection(url,user,passwd);

         if con

 

            log.info("Connection good to "+dbserver)

        else

            log.info("Connection failed")

        end

         b = con.create_statement

 

        rs=b.execute_query(query)

        while(rs.next())

log.info("Probe: "+$monitor.probe+" Old Origin: "+$monitor.origin) #value=rs.getObject(1)#use this if date format is needed value=rs.getString("customer"); $monitor.origin=value

log.info("Probe: "+$monitor.probe+" New Origin: "+$monitor.origin)

        end

    end

        rs.close

        con.close()

 

4- Save the script.  The qos_processor will pick up the changes automatically.

5- Test the script from the "/opt/nimsoft/probes/slm/qos_processor/test/" folder:

/opt/nimsoft/jre/jre8u102/bin/java -jar /opt/nimsoft/probes/slm/qos_processor/lib/JRubyScriptRunner-8.4.0.jar ../scripts/enrichment.rb

Validate you do not receive any scripting or parsing errors.

6- Wait 5-10 minutes and check the "/opt/nimsoft/probes/slm/qos_processor/scripts/qosextra-log.txt" log file.

    Sample log entry:

less /opt/nimsoft/probes/slm/qos_processor/scripts/qosextra-log.txt

I, [2017-12-04T15:15:35.281000 #27186]  INFO -- : **************Script Run**************** 

I, [2017-12-04T15:15:35.282000 #27186]  INFO -- : Driver jar file exists !

I, [2017-12-04T15:15:35.283000 #27186]  INFO -- : About to connect...

I, [2017-12-04T15:15:35.316000 #27186]  INFO -- : Connection good to .... < jdbc url > ...

I, [2017-12-04T15:15:35.317000 #27186]  INFO -- : Probe: net_connect Old Origin: nimsoft_lab_com_hub 

I, [2017-12-04T15:15:35.318000 #27186]  INFO -- : Probe: net_connect New Origin: Devices 

I, [2017-12-04T15:15:35.322000 #27186]  INFO -- : **************Script Run**************** 

Additional Information:

TEC000005340 How to use qos_processor to enrich/modify QoS messages

Documentation on qos_processor

Documentation on Ruby Logger