Overview

Skill Level: Any Skill Level

This recipe explains how to implement the event integration between ScienceLogic running at IBM Cloud and Netcool running on premise inside customer's IT infrastructure using Json payload.

Ingredients

For this recipe the following prerequisites are expected:

  • an existing and working Netcool environment on premise;
  • an existing ScienceLogic EM7 instance running at IBM Cloud;
  • network flow (outbound to internet) between ScienceLogic in the cloud and the on premise network;
  • at least 1 new VM on premise available.

Step-by-step

  1. Install the MessageBus Probe (in case it does not exists already)

    The messagebus probe is used to receive JSON event messages from ScienceLogic EM7 solution.

    The probe needs to be installed and connected to the existing Netcool environment so the received events can be used later on the current integrations available, like ticketing, paging, emailing, automations and others.

    For more information on how to install the Netcool MessageBus Probe component, please refer to the documentation available on the following link.

    https://www.ibm.com/support/knowledgecenter/SSSHTQ/messbuspr-pdf.pdf

  2. Install the ScienceLogic EM7 Phone Home Data Collector

    The ScienceLogic EM7 Phone Home Data Collector is used to create an outbound flow out to IBM Cloud and connect to the ScienceLogic EM7 environment.

    Events will be sent using this Data Collector to the MessageBus Probe already attached to the existing Netcool environment.

    For more information on how to install the ScienceLogic EM7 Phone Home Data Collector component, please refer to the documentation available on the following link.

    https://portal.sciencelogic.com/files/documentation/8-6-1/index.htm#Web_Install_Configure/Installation/installation_title_page.htm%3FTocPath%3DSection%2520II.%2520Installation%2520and%2520Configuration%7CInstallation%2520and%2520Initial%2520Configuration%7C_____0

     

  3. Architecture Overview with the new components attached

    The message will be sent from the cloud to the on premise netcool using those 2 new components – The Data Collector and the MessageBus Probe.

    After the new components being added to the solution, the event message flow should be like presented on the following picture.

     

    ScienceLogic_SystemContext_EventManagement_Flow

  4. Required settings on the ScienceLogic side

    The integration uses the RunBook feature available on the tool. Required actions are described below.

    4.1) Create a new credential for the MessageBus probe authentication;

    1_Credential

    4.2) Create a new RunBook/Automation;

    2_Action

    4.3) Create a new RunBook/Action;

     3_Automation

     

    Here below is the Action code used. For other runbook variables please refer to the following link.

    https://portal.sciencelogic.com/files/documentation/8-6-1/index.htm#Web_Events_and_Automation/Run_Book_Automation/run_book_variables.htm?Highlight=EM7_VALUES

    import json
    import time
    from silo_common.database import local_db
    import requests
    from requests.auth import HTTPBasicAuth

    #Globals:
    RBA_NAME = 'Netcool OMNIbus: Web Services Event'
    RBA_VERSION = '0.4.0'
    DEBUG_LOGGING = True # True is on, False is Off
    LOG_FILE = '/data/tmp/omnibus.log' #touch file and chmod 644

    #Functions:
    def logger_debug(log_message=None, log_var=None):
    if DEBUG_LOGGING is True:
    m = '%s %s\n' % (str(log_message), str(log_var))
    with open(LOG_FILE, "a+") as myfile:
    myfile.write(m)

    def make_display_notes(notes):
    if isinstance(notes, list):
    for note in notes:
    logger_debug(note,'')
    note = '<br>'.join(notes)
    return "<p><font style='font: 9pt Helvetica;'>%s</font>" % (str(note))
    elif isinstance(notes, str):
    logger_debug(notes,'')
    return "<p><font style='font: 9pt Helvetica;'>%s</font>" % (str(notes))

    def omni_request(json_dict):
    ##Use credential data to detemine the URL
    if 'http' in str(EM7_ACTION_CRED['cred_host']).lower():
    url = "%s:%s" % (str(EM7_ACTION_CRED['cred_host']).strip(), str(EM7_ACTION_CRED['cred_port']))
    else:
    url = "http://%s:%s" % (str(EM7_ACTION_CRED['cred_host']).strip(), str(EM7_ACTION_CRED['cred_port']))
    ##set basic JSON header
    headers = {'content-type': 'application/json'}
    ##convert data into JSON format
    try:
    json_data = json.dumps(json_dict)
    except Exception, e:
    logger_debug('JSON Handler Exception in omni_request():', str(e))
    except:
    logger_debug('JSON Handler Exception in omni_request():', '')
    ##make the request to Omnibus WS API
    try:
    r = requests.post(url, headers=headers, data=json_data, verify=False, timeout=5)
    #look for a return status of 200 (Okay)
    if r.status_code == 200:
    return True
    ##handle exceptions if they happen
    except Exception, e:
    logger_debug('HTTP Request Exception in omni_request():', str(e))
    except:
    logger_debug('HTTP Request Exception in omni_request():', '')
    return False


    ##begin logging

    logger_debug("------------------------------------------------------", '')
    logger_debug(RBA_NAME, RBA_VERSION)
    logger_debug("Event ID:", str(EM7_VALUES['%e']))
    logger_debug("Device Name:", str(EM7_VALUES['%X']))
    logger_debug("Device ID:", str(EM7_VALUES['%x']))

    ##lets make sure we have a valid credential
    if isinstance(EM7_ACTION_CRED, dict) \
    and 'cred_type' in EM7_ACTION_CRED \
    and str(EM7_ACTION_CRED['cred_type']) == "5":

    ##initialize the notes list
    NOTE_LIST = [] ##create a custom message.
    OMNI_MESSAGE = """%s: %s""" % (EM7_VALUES['%X'], EM7_VALUES['%M'])
    ##create the payload dictionary in Python
    JSON_PAYLOAD = {
    "source": "ScienceLogic",
    "msg": OMNI_MESSAGE,
    "ClassName": str(EM7_VALUES['%_category_name']),
    "InstanceId": str(EM7_VALUES['%Y']),
    "customer_code": str(EM7_VALUES['%o']),
    "origin": str(EM7_VALUES['%a']),
    "hostname": str(EM7_VALUES['%X']),
    "Component": 'Unix',
    "appl_id": str(EM7_VALUES['%_class_name']),
    "resource_id": str(EM7_VALUES['%X']),
    "severity": str(EM7_VALUES['%S'])
    }

    if isinstance(JSON_PAYLOAD, dict):
    for key, val in JSON_PAYLOAD.iteritems():
    logger_debug(key, val)
    NOTE_LIST.append("%s == %s" % (key, val))

    start_time = time.time()
    if omni_request(JSON_PAYLOAD) == True:
    elapsed_time = time.time() - start_time
    ##append notes list and convert to final notificaiton message
    NOTE_LIST.append('Omnibus Request Okay')
    NOTE_LIST.append('Run Time: %s' % (elapsed_time))
    EM7_RESULT = make_display_notes(NOTE_LIST)

    else:
    err = 'Netcool Omnibus Request Failed'
    EM7_RESULT = make_display_notes(err)
    else:
    err = 'Error Incorrect Credential Type, Quitting'
    EM7_RESULT = make_display_notes(err)
  5. Required configuration files on the Netcool side

    The Probe has 2 important files, the props and the rules files.

    For the props, the most important informations are shown below. Other config lines are also required, but they are generic to all probe (like AuthUserName and AuthPassword), so not described in here.

    # Probe Specific Properties
    MessagePayload : ‘json’
    TransportFile : ‘$OMNIHOME/java/conf/httpWebhookTransport.properties’
    TransportType : ‘HTTP’
    RulesFile : ‘/opt/IBM/GSMA/probe/MsgBus/rules/gsma_eif.rules’

    For the rules, the GSMA EIF rules file was used for this integration. Please refer to the GSMA documentation for more information.

Join The Discussion