jjjw420 / splunk-ibm-websphere-mq-add-on

IBM Websphere MQ add-on for Splunk
3 stars 6 forks source link
ibm-websphere-mq splunk-v8

splunk-ibm-websphere-mq-add-on - TA-mq

By Hannes Wagener - 2015

Overview

This is a Splunk modular input add-on for IBM Websphere MQ. Currently two data inputs are supported. One for creating events from messages on IBM Websphere queues and another for channel status statistics.

Created from the Splunk modular input examples.

Features

Dependencies

Setup

IMPORTANT: The plugin folder has been renamed from "mq_ta" to "TA-mq". Make sure that you take this into account if you are upgrading the plugin.

Installation

Upgrade

Response Handlers

Even though the included response handlers works very well, you are encouraged to create your own response handlers to handle a specific type or format of MQ message. Every site that has IBM MQ will have custom formats for mesages and which will be written in a variety of different codepages depending on the platform.
By creating your own response handler you can parse your specific MQ message and index the event in Splunk so that it's attributes are accessible for searches. Let the included response handlers serve as examples to your own.

DefaultQueueResponseHandler

DefaultChannelStatusResponseHandler

BrokerEventResponseHandler

Logging

Any modular input log errors will get written to $SPLUNK_HOME/var/log/splunk/splunkd.log. Debug logging can be "enabled by changing the "ExecProcessor" property under "Server logging" to DEBUG.

Troubleshooting

How to find a Splunk Python2 compatible "_ctypes.so" (pre Splunk V8)

The number one problem most people experience with the installation is finding a compatible ctypes library for Splunk's Python2 interpreter(particulary _ctypes.so).

Splunk's Python2 interpreter was built using UCS2 whereas most of the recent builds on Ubuntu, CentOS, RHEL, etc. is built using UCS4 making the two incompatible. Splunk V8 comes with the ctypes library installed for both the Python2 and Python3 interpreters by default making the installation much simpler. But earlier versions of Splunk does not include a ctypes library by default.

Determining what type of _ctypes.so you require.

The easiest way to see whether a Python interpreter was built using UCS2 or UCS4 is to check the sys.maxunicode value.
For a UCS2 build the value returned will be 65535. On a UCS4 build the value returned will be 1114111.

For instance - running the python2 interpreter that comes with Splunk:

    
  $ /opt/splunk/bin/python2
  Python 2.7.15 (default, Jun 24 2019, 17:39:18)
  [GCC 5.3.0] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import sys
  >>> print sys.maxunicode
  65535
  >>>

The 65535 value means that Splunk's Python2 interpreter was built using UCS2.

Determining if an existing _ctypes.so was built using UCS2 or UCS4

The quickest way to determine if a _ctypes.so was built using UCS2 or UCS4 is to simply print the enclosed strings and searching for "UCS".

For instance - a _ctypes bullt using UCS4(incompatble with Splunk's Python2) will have the following output:

  $ strings _ctypes.so | grep UCS
  PyUnicodeUCS4_AsWideChar
  PyUnicodeUCS4_FromEncodedObject
  PyUnicodeUCS4_FromWideChar
  PyUnicodeUCS4_AsEncodedString
  PyUnicodeUCS4_FromUnicode

A version that will be compatible with Splunk's Python2 will have output that looks as follows:

  $ strings lib-dynload/_ctypes.so  | grep UCS
  PyUnicodeUCS2_AsWideChar
  PyUnicodeUCS2_FromEncodedObject
  PyUnicodeUCS2_FromWideChar
  PyUnicodeUCS2_AsEncodedString
  PyUnicodeUCS2_FromUnicode
  PyUnicodeUCS2_FromWideChar
  PyUnicodeUCS2_FromUnicode
  PyUnicodeUCS2_FromEncodedObject
  PyUnicodeUCS2_AsWideChar
  PyUnicodeUCS2_AsEncodedString
  PyUnicodeUCS2_AsWideChar
  PyUnicodeUCS2_FromEncodedObject
  PyUnicodeUCS2_FromWideChar
  PyUnicodeUCS2_AsEncodedString
  PyUnicodeUCS2_FromUnicode

NOTE: If no strings containing "UCS" was found the library is NOT compatible and almost certainly a Python3 version that cannot be used with Python2.

Where to find a compatible _ctypes.so

DISCLAIMER

You are free to use this code in any way you like, subject to the Python & IBM disclaimers & copyrights. I make no representations about the suitability of this software for any purpose. It is provided "AS-IS" without warranty of any kind, either express or implied.