Thursday, May 10, 2018

Integrate Nagios with Netcool

http://askaralikhan.blogspot.com/2010/02/sending-snmp-traps-from-nagios.html


Sending SNMP Traps from Nagios

As well as receiving SNMP traps in Nagios, you can send SNMP traps from Nagios to a remote SNMP management station like HP OpenView (NNM) or the like. The easiest way to do this is to create a notification command that generates an SNMP trap. This way, you can use an SNMP management station as a notification destination. This will mean that the trap will be sent every time a notification is scheduled.


Prerequisites:

net-snmp, net-snmp-utils should be installed on Monitoring host running Nagios

Connectivity between management station and nagios has been stablished and nagios can connect and send snmptraps to snmptrap 162/udp port on management station.


1. First of all define notification command, below is the commands for service and hosts in commands.cfg

# 'send-service-trap' command definition
define command{
      command_name send-service-trap
      command_line /usr/local/bin/send-service-trap manager public "$HOSTNAME$" "$SERVICEDESC$" $SERVICESTATEID$ "$SERVICEOUTPUT$"
}

# 'send-host-trap' command definition
define command{
                command_name send-host-trap
                command_line /usr/local/bin/send-host-trap manager public "$HOSTNAME$" $HOSTSTATEID$ "$HOSTOUTPUT$"
}

Both the commands call the shell scripts send-service-trap and send-host-trap in /usr/local/bin/. Passing the hostname or IP address of the destination management station and the target community string, manager and public, respectively.

A number of macros are also passed to the shell script representing the hostname, the service description, the service/host state in numeric form, and the output of the host/service check.

The snmptrap tool generates SNMP traps and can send them to remote management stations. The traps are generated according to a Nagios
MIB available from the same Sourceforge project as the Nagios plug-ins. You can download the MIB from http://prdownloads.sourceforge.net/nagiosplug/nagiosmib-1.0.0.tar.gz?download.

The package contains two MIB files: a root MIB file containing basic definitions for Nagios OIDs called NAGIOS-ROOT-MIB and an MIB containing events and traps called NAGIOS-NOTIFY-MIB. You will need to install both MIB files into your SNMP management device; for example, if your trap daemon is the snmptrapd daemon, you would generally copy these files to the /usr/share/snmp/mibs directory. When you start the snmptrapd daemon, you load the MIB files using the -m
and -M options:

Also copy the MIBs files on localhost where Nagios is running under snmp/mibs

/usr/sbin/snmptrapd -m ALL -M /usr/share/snmp/mibs -Lf /var/log/snmptrapd.log


Tip:  There is an excellent HOWTO on how to use snmptrap to send traps here.

Note: Your own SNMP management station, such as HP OpenView or the like, will have its own method of loading MIB files. You should refer to its documentation for that.

2. Define a contact for Management station

Need to define a contact for management station in the same way we create for other contact person, to receive SNMP traps from Nagios whereever Nagios send notificaiton for host/service

define contact{
        contact_name                             managementstation
        use                                              generic-contact
        alias                                            Management Station
        service_notification_options    w,u,c,r
        host_notification_options         d,u,r
        service_notification_commands   send-service-trap
        host_notification_commands      send-host-trap
        }


3. Add the new conatct to contactgroup for hosts/services for which you want to send SNMP traps

define contactgroup{
        contactgroup_name       linuxadmins
        alias                                Linux Servers Administrators
        members                         me, managementstation
}

Now whenever there is a alert for linux servers Nagios will notify contact "managementstation" which in turn call the commands send-service-trap/send-host-trap accordingly depends on host or service alert.

4. send-service-trap/send-host-trap Shell Script

===/usr/local/bin/send-service-trap ====
# Arguments:
# $1 = Management Station
# $2 = Community String
# $3 = host_name
# $4 = service_description (Description of the service)
# $5 = return_code (An integer that determines the state
#       of the service check, 0=OK, 1=WARNING, 2=CRITICAL,
#       3=UNKNOWN).
# $6 = plugin_output (A text string that should be used
#       as the plugin output for the service check)
#
#
/usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "$3" nSvcDesc s "$4" nSvcStateID i $5 nSvcOutput s "$6"


===/usr/local/bin/send-host-trap=======
# Arguments:
# $1 = Management Station
# $2 = Community String
# $3 = host_name
# $4 = HostStatID A number that corresponds to the current state of the host: 0=UP, 1=DOWN, 2=UNREACHABLE.
# $5 = HOSTOUTPUT The first line of text output from the last host check (i.e. "Ping OK").
#
#
/usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s "$3" nHostStateID i $4 nHostOutput s "$5"


The shell script receives all the incoming variables and passes them to the snmptrap command

-v = snmp version
-c = community string
$1 = Management Station IP address or hostname

The next two single quotes are special characters representing the uptime portion of a trap. They will be replaced with the current uptime of the system generating the trap when the snmptrap command is executed.

The enterprise OID is specified next; in this case it is NAGIOS-NOTIFY-MIB::nSvcEvent and NAGIOS-NOTIFY-MIB::nHostEvent. The NAGIOS-NOTIFY-MIB is the name of the MIB module being referenced, and the nSvcEvent/nHostEvent is the trap defined for sending service events. Together these form the enterprise OID.

Next specified a list of individual OIDs and their variables that I’m passing as part of the trap. They are, in order, the hostname, the service description, the host/service status ID in numerical form, and the output of the host/service check.

Enclosing the values ones that might contain multiword data in quotation marks so that they are passed cleanly to the command.

Tip:  You can find these and other OIDs that you can use with the traps and notifications defined in the NAGIOS-ROOT-MIB and NAGIOS-NOTIFY-MIB MIB files.

21 comments:

  1. I have successfully configured sending SNMP traps from Nagios to HP NNM.
    Reply
  2. Thank you for your very helpful posting. It enabled me to get Nagios sending traps very quickly.
    Reply
  3. I Configured everthing you mentioned in your perfect tutorial but i even cannot send snmptraps via the snmptrap command snmptrap -v 1 -c public manager "" "" 6 99 ""
    Reply
  4. Everything is fine now. I was not able to receive snmptraps from nagios on the other management station because the snmpd version 5.4.rc2 on nagios had a bug. The bug was that snmptrap sends its traps on port 161 and not on 162.
    Reply
  5. N.B. typo:
    smnptrapd.log should be snmptrapd.log!
    Reply
  6. Hi Askar,
    Thanks for the very straight forward steps to be followed. 1 thing is missing, I'm a guy new to nagios maybe because of that..I configured nagios and it monitors my network and send email alerts. Now I need to send alerts in form of traps to 'Management Host' in my parent company. So I have just done all that you presented here. Am I done or should I make some more changes?
    Should I replace the arguments on the script below OR where do I mention the management host IP address.
    Can I check the traps in my own nagios machine as well??
    ===/usr/local/bin/send-host-trap=======
    # Arguments:
    # $1 = Management Station
    # $2 = Community String
    # $3 = host_name
    # $4 = HostStatID A number that corresponds to the current state of the host: 0=UP, 1=DOWN, 2=UNREACHABLE.
    # $5 = HOSTOUTPUT The first line of text output from the last host check (i.e. "Ping OK").
    #
    #
    /usr/bin/snmptrap -v 2c -c $2 $1 '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s "$3" nHostStateID i $4 nHostOutput s "$5"

    Thanks in Advance!!!
    Hamid
    Reply

    Replies


    1. Refer to 1) First of all define notification command, below is the commands for service and hosts in commands.cfg

      command_line /usr/local/bin/send-service-trap manager public <-- manager is the hostname of management station, edit /etc/hosts file on your Nagios server and put something like this in it

      # SNMP Manager Station
      xxx.xx.xx.xx manager

      replace xx.xxx. with the IP of your management station, after that nagios should able to resolve 'manager' you can also confirm by..

      ping manager

      If you followed everything correctly Nagios should be forwarding SNMP traps to the management station.

      you need to coordinate with the guy managing the Management Station in your parent company make sure they copied the Nagios MIBs to correct location and loaded.

      Sending and receiving traps in nagios is bit complicated specially to those who are new to Nagios. If stuck i would recommend to Google.
  7. I am not much involve with Nagios or open source in general due to nature of my current job and environment. Therefore I wouldn't of great help if someone come up with a question.
    Reply
  8. Hello Askar,

    This is Mohammed Azhar Hussain I am running Nagios 3.3.1 on centos it working fine but I have one doubt about SNMP-2 when my monitoring switch port down it only shows SNMP-2 but there is no any notification alert. Could you please help me to assign notification on this service.

    Thanks & Regards
    Mohammed Azhar Hussain
    Reply
  9. Hi Askar,

    how is it possible to change integer type of nHostStateID and nSvcStateID to string type ?
    I'm using SNMPc software which have a problem to recognize state by number but should be work with string.

    Thanks,
    Jiri
    Reply

    Replies


    1. Hi Jiri,
      I am afraid can't be of much help here due to job switch I am not working on this from last two years.
  10. Hi Askar,
    I configured by using your reference, but enterprises OID cannot send. Can you give me a solution.

    Thanks
    Ramana
    Reply
  11. The MIBS are not available in the path http://prdownloads.sourceforge.net/nagiosplug/nagiosmib-1.0.0.tar.gz?download as per the article. Can they be downloaded from https://www.nagios.org/downloads/nagios-plugins/ ?
    Reply

    Replies


    1. https://github.com/nagios-plugins/nagios-mib/tree/master/MIB
  12. Hello Everyone,

    Sending traps from Nagios side is working fine after following up the steps above. But on the other side (NMS: HP SiteScope) is recognizing the trap as string and didn't recognize the OIDs correctly!
    Can anyone please advise?

    Thanks in advance,,,
    Tamer Moalla
    Reply
  13. I have deployed Nagios core on one VM. This receives all the traps from my application and forward it to other NMS system. I want to filter some traps not to be forward to NMS system.

    How I can achieve this scenario.
    Reply
  14. Somewhat helpful, I am still confused as our management wants host availability check using SNMP ? Is it possible ? What will be the result in case of remote host unreachable.
    Reply
  15. Thanks for this post, realy helpfully for me, i have a question, how i can add values to the trap, i.e. i need sen the host ip address and host father, how i can do it?
    Reply
  16. This comment has been removed by the author.
    Reply
  17. Hi,

    I would like to know if is it possible to send SNMP traps from Nagios to another host, using the free version of Nagios (Nagios Core).

    If you look at the next link (https://assets.nagios.com/handouts/nagiosxi/Nagios-XI-vs-Nagios-Core-Feature-Comparison.pdf), it says "Send & Receive SNMP Traps" is a feature of Nagios XI (payment version), not Nagios Core (free version). But if you look at this link (https://www.nagios.com/solutions/snmp-traps/), it says both solutions (Nagios XI and Nagios Core) provide that feature.

    What solution would I need to send SNMP traps to another host? Could I do it using the free version of Nagios? Thanks.

    Cordially,

    Albert
    Reply

Friday, August 4, 2017

Docker Install

                       Steps to install Docker RHEL 7.2 Minimum
                      
First you must install RHEL 7.2 minimum version from the following site.
You must register to have access to ISO's on this site.  Follow the instructions
to register.
https://ftp3.linux.ibm.com/

Once you have RHEL 7.2 minimum installed you will need to add repositories in order to have access to Docker
Below are the instructions to do so.

STEP 1:

First you need to register your version of RHEL.  
Copy paste the following section at the bottom of this step between hashs (Register start) & (Register End)
    Into a script on your RHEL server.
    Run the script. 
    Make sure the script you paste the following text into is exectuable.
    Make sure the correct path to bash is set on the first line of the script
    User your credentials you created to register for the software when prompted. 
    The user password isn't your w3 user id & password unless thats what you set it to.
    This password will not change when you change your w3 password every 3 months
   
#############################################################################################################################################################################################
#########################Register Start#######################################################################################################################################################
#!/bin/bash
############################################################################
#
#               ------------------------------------------
#               THIS SCRIPT PROVIDED AS IS WITHOUT SUPPORT
#               ------------------------------------------
#
# Author: Vinicius Silva <vesoares@br.ibm.com>
# Version: 0.5
# Description: Wrapper script for subscription-manager to register RHEL 6
#              and RHEL 7 systems with the internal Red Hat Satellite using
#              FTP3 credentials.
#
# The following environment variables can be used:
#
#   FTP3USER=user@cc.ibm.com        FTP3 Account
#   FTP3PASS=mypasswd               FTP3 Password
#
# You must be root to run this script. The user id and password will be
# prompted for if the environment variables are not set.
#
# example uses might be:
#
#  1.  ./ibm-rhsm.sh
#  2.  FTP3USER=user@cc.ibm.com ./ibm-rhsm.sh
#
# The first example is a good way to test this script. The second example
# shows how to set the FTP3USER environment variable on the command line.
#
# NOTE: Some parts of this script were extracted
#       from the good old ibm-yum.sh script.
#
############################################################################


## default host
if [ -z "$FTP3HOST" ] ; then
    FTP3HOST="ftp3.linux.ibm.com"
fi

## other vars that most likely should not change
API_URL="https://ftp3.linux.ibm.com/rpc/index.php"
KATELLO_CERT_RPM="katello-ca-consumer-rhs.linux.ibm.com"
IBM_RHSM_REG_LOG=ibm-rhsm.log

## these are detected automatically
ARCH=
VERSION=
RELEASE=

## registration successfull
SUCCESS=

## system already registered check
PROCEED=

## Functions

# 0 = green; 1 = red; 2 = yellow
formatted_echo() {
    case $2 in
        0   ) echo -e "\r\t\t\t\t\t\t\t\e[32m$1\e[0m";;
        1   ) echo -e "\r\t\t\t\t\t\t\t\e[31m$1\e[0m";;
        2   ) echo -e "\r\t\t\t\t\t\t\t\e[33m$1\e[0m";;
        *   ) echo $1;;
    esac
}

run_curl() {
    user=$1
    pass=$2

    curl -ks $API_URL  -H "Content-Type: text/xml" -d "<?xml version='1.0' encoding='UTF-8'?><methodCall><methodName>user.create_activation_key</methodName> <params><param><value>$user</value></param> <param><value>$pass</value></param></params> </methodCall>" | grep -oPm1 "(?<=<string>)[^<]+"

    if [ $? != 0 ]; then
        echo
        echo "An error has occurred while trying to create the activation key."
        echo "Aborting..."
        echo
        exit 1
    fi
}

## this is called on exit
clean_up() {
    if [ -z "$SUCCESS" ]; then
        rpm -q --quiet $KATELLO_CERT_RPM
        if [ $? -eq 0 ]; then
            echo "Cleaning up..."
            rpm -e $KATELLO_CERT_RPM
        fi
        exit 1
    fi
    exit 0
}

## clean up proper if something goes bad
trap clean_up EXIT HUP INT QUIT TERM;


## must be root to run this
if [ `whoami` != "root" ] ; then
    echo "You must run this script as root. Goodbye."
    echo ""
    exit 1
fi

## initialize the log file
cat /dev/null > $IBM_RHSM_REG_LOG
echo `date` >> $IBM_RHSM_REG_LOG
echo "Starting the registration process..." >> $IBM_RHSM_REG_LOG

## system is already registered?
REGSTATUS=`subscription-manager status | grep Overall | cut -f2 -d':' | tr -d ' '`
if [ "$REGSTATUS" == "Current" ]; then
    echo "This system is already registered."
    echo -n "Would like to proceed? (y/n): "
    read PROCEED

    if [ "$PROCEED" != "y" -a "$PROCEED" != "Y" ]; then
        echo "Aborting..."
        exit 1
    fi
fi

## get the userid
if [ -z "$FTP3USER" ] ; then
    echo -n "User ID: "
    read FTP3USER

    if [ -z "$FTP3USER" ] ; then
        echo ""
        echo "Missing userid. Either set the environment variable"
        echo "FTP3USER to your user id or enter a user id when prompted."
        echo "Goodbye."
        echo ""
        exit 1
    fi
fi

## get the password
if [ -z "$FTP3PASS" ] ; then
    echo -n "Password for $FTP3USER: "
    stty -echo
    read -r FTP3PASS
    stty echo
    echo ""
    echo ""

    if [ -z "$FTP3PASS" ] ; then
        echo "Missing password. Either set the environment variable"
        echo "FTP3PASS to your user password or enter a password when"
        echo "prompted. Goodbye."
        echo ""
        exit 1
    fi
fi

echo -n "* Performing initial checks... "

## get the version and release, most likely only works on RHEL
VERREL=`rpm -qf --qf "%{NAME}-%{VERSION}\n" /etc/redhat-release`
if [ $? != 0 ] ; then
    formatted_echo "FAIL" 1
    echo "Failed to find system version and release with the"
    echo "command \"rpm -q redhat-release\". Is this system"
    echo "running Red Hat Enterprise Linux?"
    echo ""
    exit 1
fi

## split something like "redhat-release-server-7.1" into "7" and "server"
RELEASE=`echo $VERREL | cut -f4 -d"-" | cut -b1`
VERSION=`echo $VERREL | cut -f3 -d"-"`

## verify support for this release
case $RELEASE in
    7   ) : ;;
    6   ) : ;;
    *   ) RELEASE= ;;
esac

## verify support for this version
case $VERSION in
    server      ) : ;;
    workstation ) : ;;
    *           ) VERSION= ;;
esac

if [ -z "$VERSION" ] || [ -z "$RELEASE" ] ; then
    formatted_echo "FAIL" 1
    echo "Unknown or unsupported system version and release: $VERREL"
    echo "Try reporting this to ftpadmin@linux.ibm.com with the"
    echo "full output of uname -a and the contents of /etc/redhat-release"
    echo ""
    exit 1
fi

## get the system arch
# TODO: Refactor this by declaring and reusing the $ARCH variable
case `uname -m` in
    x86_64      ) ARCH="x86_64"
                  LABEL="$VERSION"
                  ;;
    ppc64le     ) ARCH="ppc64le"
                  LABEL="for-power-le"
                  ;;
    ppc64       ) ARCH="ppc64"
                  LABEL="for-power"
                  ;;
    s390x       ) ARCH="s390x"
                  LABEL="for-system-z"
                  ;;
    *           ) ARCH=;;
esac

## check if we got a good arch
if [ -z "$ARCH" ] ; then
    # TODO: Move the following lines inside the default case (*) statement
    formatted_echo "FAIL" 1
    echo "Unsupported system architecture: `uname -m`"
    echo "If you have any questions, please open a support request at:"
    echo -e "http://ltc.linux.ibm.com/support/ltctools.php.\n"
    exit 1
fi

formatted_echo "OK" 0
echo "Detected a RHEL $RELEASE $VERSION..." >> $IBM_RHSM_REG_LOG

## system is registered to the old RHN Satellite?
REGSTATUS=`rpm -q rhn-org-trusted-ssl-cert-1.0-10`
if [ $? -eq 0 ]; then
    echo "This system is registered to the old RHN Satellite. "
    echo -n "Would like to proceed and remove current associations? (y/n): "
    read PROCEED

    if [ "$PROCEED" != "y" -a "$PROCEED" != "Y" ]; then
        echo "Aborting..."
        exit 1
    fi
    yum remove rhn-org-trusted-ssl-cert-1.0-10 -y &>> $IBM_RHSM_REG_LOG
    sed -i 's/enabled\ =\ 1/enabled\ =\ 0/g' /etc/yum/pluginconf.d/rhnplugin.conf
fi

# Encode the username for use in URLs
FTP3USERENC=`echo $FTP3USER | sed s/@/%40/g`

# Encode user password for use in URLs
FTP3PASSENC=`echo -n $FTP3PASS | od -tx1 -An | tr -d '\n' | sed 's/ /%/g'`

echo -n "* Check the server certificate... "
rpm -qa | grep -s katello-ca-consumer > /dev/null
if [ $? -ne 0 ]; then
    formatted_echo "WARN" 2
    echo "The server certificate is not installed." >> $IBM_RHSM_REG_LOG

    echo -n "* -> Installing server certificate... " | tee -a $IBM_RHSM_REG_LOG
    echo >> $IBM_RHSM_REG_LOG
    rpm -Uvh http://rhs.linux.ibm.com/pub/katello-ca-consumer-latest.noarch.rpm &>> $IBM_RHSM_REG_LOG
    if [ $? -ne 0 ]; then
        formatted_echo "FAIL" 1
        echo "An error has occurred while trying to install the server certificate." >> $IBM_RHSM_REG_LOG
        echo "Aborting..."
        echo
        exit 1
    else
        formatted_echo "OK" 0
    fi
else
    formatted_echo "OK" 0
    echo "Server certificate is already installed." >> $IBM_RHSM_REG_LOG
fi

## Get activation key
# in case an existing key is not found, a new one will be created.
echo -n "* Searching for an activation key... "

ACTIVATION_KEY=`run_curl $FTP3USERENC $FTP3PASSENC`

if [ -z "$ACTIVATION_KEY" ]; then
    formatted_echo "FAIL" 1
    echo
    echo -n "An error has ocurred: "
    echo "No activation key."
    echo "There was a problem while creating your activation key."
    echo "Please, make sure you are connected to the IBM network and using a valid FTP3 account."
    echo "Aborting."
    echo
    exit 1
elif [ "$ACTIVATION_KEY" == "Account not found" -o "$ACTIVATION_KEY" == "Wrong username or password" ]; then
    formatted_echo "FAIL" 1
    echo
    echo "An error has ocurred: $ACTIVATION_KEY"
    echo "Please, make sure you're using the correct FTP3 username and password."
    echo "Aborting."
    echo
    exit 1
elif [ "$ACTIVATION_KEY" == "The account $FTP3USER does not have access to Red Hat content" ]; then
    formatted_echo "FAIL" 1
    echo
    echo "An error has ocurred: $ACTIVATION_KEY"
    echo -n "You may request access on the \"My Account\" page: "
    echo "https://ftp3.linux.ibm.com/myaccount/access.php."
    echo "Aborting."
    echo
    exit 1
fi
formatted_echo "OK" 0
echo "Activation key: $ACTIVATION_KEY" >> $IBM_RHSM_REG_LOG
echo "(You may copy this activation key for future use)" >> $IBM_RHSM_REG_LOG

## system registration
echo -n "* Registering the system... "
REGSTATUS=`subscription-manager register --org Default_Organization --activationkey="$ACTIVATION_KEY"`

if [ `echo $REGSTATUS | grep -c "The system has been registered"` -ne 1 ]; then
    formatted_echo "FAIL" 1
    echo "An error has occurred while trying to register the system."
    echo "You may try to register it later using the following command:"
    echo "subscription-manager register --org Default_Organization --activationkey=\"$ACTIVATION_KEY\""
    echo
    exit 1
else
    echo "System successfully registered!" >> $IBM_RHSM_REG_LOG
    formatted_echo "OK" 0
fi

## Disable all repositories
echo -n "* Disable all repositories... " | tee -a $IBM_RHSM_REG_LOG
echo >> $IBM_RHSM_REG_LOG

subscription-manager repos --disable=* >> $IBM_RHSM_REG_LOG
if [ $? -ne 0 ]; then
    formatted_echo "FAIL" 1
    #echo "An error has occurred while disabling all the repositories." >> $IBM_RHSM_REG_LOG
else
    formatted_echo "OK" 0
fi

## Enable RHEL 7 repositories
echo -n "* Enable RHEL $RELEASE repositories... " | tee -a $IBM_RHSM_REG_LOG
echo >> $IBM_RHSM_REG_LOG

arr=("-supplementary-" "-optional-" "-")
for REPO in "${arr[@]}"; do
    subscription-manager repos --enable=rhel-$RELEASE-${LABEL}${REPO}rpms >> $IBM_RHSM_REG_LOG
    if [ $? -ne 0 ]; then
        ENABLE_REPOS=0
    fi
done

if [ -z $ENABLE_REPOS ]; then
    formatted_echo "OK" 0
else
    formatted_echo "FAIL" 1
fi

SUCCESS=0

echo
echo "Registration completed!" | tee -a $IBM_RHSM_REG_LOG

exit 0
#############################################################################################################################################################################################
#########################Register Finished###################################################################################################################################################

* Performing initial checks...              OK
* Check the server certificate...               WARN
* -> Installing server certificate...           OK
* Searching for an activation key...            OK
* Registering the system... This system is already registered. Use --force to override
                            FAIL
An error has occurred while trying to register the system.
You may try to register it later using the following command:
subscription-manager register --org Default_Organization --activationkey="dgosseli@us.ibm.com_2017-08-04_12_01_11"

Cleaning up...



Step 2: Run the following command

# subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

Step 3: Run the following command
# subscription-manager repos --enable=rhel-7-server-extras-rpms
Repo 'rhel-7-server-extras-rpms' is enabled for this system.

Step 4: Run the following command
# subscription-manager repos --enable=rhel-7-server-optional-rpms
Repo 'rhel-7-server-optional-rpms' is enabled for this system.

Step 5fd: Install docker

yum install docker

RedHat Subscription Manager






  1. Download the registration script from FTP3.
  2. Run the script and provide your FTP3 credentials when prompted
    [root@rhel-7 ~]# ./ibm-rhsm.sh
    User ID:
    Password for <username>@<cc>.ibm.com:
      
  3. It will perform some intial checks and install the local certificate
    * Performing initial checks...                  OK
    * Check the server certificate...               WARN
    * -> Installing server certificate...           OK
      
  4. The script will try to generate an activation key and use it to register the system
    * Searching for an activation key...            OK
    * Registering the system...                     OK
      
  5. After the activation key is generated, the system is registered and the main repositories enabled
    * Disable all repositories...                   OK
    * Enable RHEL 7 repositories...                 OK
    
    Registration completed!
      
We're done! You may now use YUM to update your RHEL systems and install packages. =)
Tip: Having trouble with the yum command? Check out the yum man pages for more information. Also, try using yum clean all before trying again. It cleans out the packages' cache information, headers, metadata and etc.



* Check the server certificate... WARN
* -> Installing server certificate... OK
* Searching for an activation key... OK
* Registering the system... OK
* Disable all repositories... OK
* Enable RHEL 7 repositories... OK

Registration completed!
[root@dishwasher tmp]# subscription-manager repos --enable=rhel-7-server-optional-rpms
Repository 'rhel-7-server-optional-rpms' is enabled for this system.
 
9:32:01 AM

#!/bin/bash
############################################################################
#
#               ------------------------------------------
#               THIS SCRIPT PROVIDED AS IS WITHOUT SUPPORT
#               ------------------------------------------
#
# Author: Vinicius Silva <vesoares@br.ibm.com>
# Version: 0.5
# Description: Wrapper script for subscription-manager to register RHEL 6
#              and RHEL 7 systems with the internal Red Hat Satellite using
#              FTP3 credentials.
#
# The following environment variables can be used:
#
#   FTP3USER=user@cc.ibm.com        FTP3 Account
#   FTP3PASS=mypasswd               FTP3 Password
#
# You must be root to run this script. The user id and password will be
# prompted for if the environment variables are not set.
#
# example uses might be:
#
#  1.  ./ibm-rhsm.sh
#  2.  FTP3USER=user@cc.ibm.com ./ibm-rhsm.sh
#
# The first example is a good way to test this script. The second example
# shows how to set the FTP3USER environment variable on the command line.
#
# NOTE: Some parts of this script were extracted
#       from the good old ibm-yum.sh script.
#
############################################################################


## default host
if [ -z "$FTP3HOST" ] ; then
    FTP3HOST="ftp3.linux.ibm.com"
fi

## other vars that most likely should not change
API_URL="https://ftp3.linux.ibm.com/rpc/index.php"
KATELLO_CERT_RPM="katello-ca-consumer-rhs.linux.ibm.com"
IBM_RHSM_REG_LOG=ibm-rhsm.log

## these are detected automatically
ARCH=
VERSION=
RELEASE=

## registration successfull
SUCCESS=

## system already registered check
PROCEED=

## Functions

# 0 = green; 1 = red; 2 = yellow
formatted_echo() {
    case $2 in
        0   ) echo -e "\r\t\t\t\t\t\t\t\e[32m$1\e[0m";;
        1   ) echo -e "\r\t\t\t\t\t\t\t\e[31m$1\e[0m";;
        2   ) echo -e "\r\t\t\t\t\t\t\t\e[33m$1\e[0m";;
        *   ) echo $1;;
    esac
}

run_curl() {
    user=$1
    pass=$2

    curl -ks $API_URL  -H "Content-Type: text/xml" -d "<?xml version='1.0' encoding='UTF-8'?><methodCall><methodName>user.create_activation_key</methodName> <params><param><value>$user</value></param> <param><value>$pass</value></param></params> </methodCall>" | grep -oPm1 "(?<=<string>)[^<]+"

    if [ $? != 0 ]; then
        echo
        echo "An error has occurred while trying to create the activation key."
        echo "Aborting..."
        echo
        exit 1
    fi
}

## this is called on exit
clean_up() {
    if [ -z "$SUCCESS" ]; then
        rpm -q --quiet $KATELLO_CERT_RPM
        if [ $? -eq 0 ]; then
            echo "Cleaning up..."
            rpm -e $KATELLO_CERT_RPM
        fi
        exit 1
    fi
    exit 0
}

## clean up proper if something goes bad
trap clean_up EXIT HUP INT QUIT TERM;


## must be root to run this
if [ `whoami` != "root" ] ; then
    echo "You must run this script as root. Goodbye."
    echo ""
    exit 1
fi

## initialize the log file
cat /dev/null > $IBM_RHSM_REG_LOG
echo `date` >> $IBM_RHSM_REG_LOG
echo "Starting the registration process..." >> $IBM_RHSM_REG_LOG

## system is already registered?
REGSTATUS=`subscription-manager status | grep Overall | cut -f2 -d':' | tr -d ' '`
if [ "$REGSTATUS" == "Current" ]; then
    echo "This system is already registered."
    echo -n "Would like to proceed? (y/n): "
    read PROCEED

    if [ "$PROCEED" != "y" -a "$PROCEED" != "Y" ]; then
        echo "Aborting..."
        exit 1
    fi
fi

## get the userid
if [ -z "$FTP3USER" ] ; then
    echo -n "User ID: "
    read FTP3USER

    if [ -z "$FTP3USER" ] ; then
        echo ""
        echo "Missing userid. Either set the environment variable"
        echo "FTP3USER to your user id or enter a user id when prompted."
        echo "Goodbye."
        echo ""
        exit 1
    fi
fi

## get the password
if [ -z "$FTP3PASS" ] ; then
    echo -n "Password for $FTP3USER: "
    stty -echo
    read -r FTP3PASS
    stty echo
    echo ""
    echo ""

    if [ -z "$FTP3PASS" ] ; then
        echo "Missing password. Either set the environment variable"
        echo "FTP3PASS to your user password or enter a password when"
        echo "prompted. Goodbye."
        echo ""
        exit 1
    fi
fi

echo -n "* Performing initial checks... "

## get the version and release, most likely only works on RHEL
VERREL=`rpm -qf --qf "%{NAME}-%{VERSION}\n" /etc/redhat-release`
if [ $? != 0 ] ; then
    formatted_echo "FAIL" 1
    echo "Failed to find system version and release with the"
    echo "command \"rpm -q redhat-release\". Is this system"
    echo "running Red Hat Enterprise Linux?"
    echo ""
    exit 1
fi

## split something like "redhat-release-server-7.1" into "7" and "server"
RELEASE=`echo $VERREL | cut -f4 -d"-" | cut -b1`
VERSION=`echo $VERREL | cut -f3 -d"-"`

## verify support for this release
case $RELEASE in
    7   ) : ;;
    6   ) : ;;
    *   ) RELEASE= ;;
esac

## verify support for this version
case $VERSION in
    server      ) : ;;
    workstation ) : ;;
    *           ) VERSION= ;;
esac

if [ -z "$VERSION" ] || [ -z "$RELEASE" ] ; then
    formatted_echo "FAIL" 1
    echo "Unknown or unsupported system version and release: $VERREL"
    echo "Try reporting this to ftpadmin@linux.ibm.com with the"
    echo "full output of uname -a and the contents of /etc/redhat-release"
    echo ""
    exit 1
fi

## get the system arch
# TODO: Refactor this by declaring and reusing the $ARCH variable
case `uname -m` in
    x86_64      ) ARCH="x86_64"
                  LABEL="$VERSION"
                  ;;
    ppc64le     ) ARCH="ppc64le"
                  LABEL="for-power-le"
                  ;;
    ppc64       ) ARCH="ppc64"
                  LABEL="for-power"
                  ;;
    s390x       ) ARCH="s390x"
                  LABEL="for-system-z"
                  ;;
    *           ) ARCH=;;
esac

## check if we got a good arch
if [ -z "$ARCH" ] ; then
    # TODO: Move the following lines inside the default case (*) statement
    formatted_echo "FAIL" 1
    echo "Unsupported system architecture: `uname -m`"
    echo "If you have any questions, please open a support request at:"
    echo -e "http://ltc.linux.ibm.com/support/ltctools.php.\n"
    exit 1
fi

formatted_echo "OK" 0
echo "Detected a RHEL $RELEASE $VERSION..." >> $IBM_RHSM_REG_LOG

## system is registered to the old RHN Satellite?
REGSTATUS=`rpm -q rhn-org-trusted-ssl-cert-1.0-10`
if [ $? -eq 0 ]; then
    echo "This system is registered to the old RHN Satellite. "
    echo -n "Would like to proceed and remove current associations? (y/n): "
    read PROCEED

    if [ "$PROCEED" != "y" -a "$PROCEED" != "Y" ]; then
        echo "Aborting..."
        exit 1
    fi
    yum remove rhn-org-trusted-ssl-cert-1.0-10 -y &>> $IBM_RHSM_REG_LOG
    sed -i 's/enabled\ =\ 1/enabled\ =\ 0/g' /etc/yum/pluginconf.d/rhnplugin.conf
fi

# Encode the username for use in URLs
FTP3USERENC=`echo $FTP3USER | sed s/@/%40/g`

# Encode user password for use in URLs
FTP3PASSENC=`echo -n $FTP3PASS | od -tx1 -An | tr -d '\n' | sed 's/ /%/g'`

echo -n "* Check the server certificate... "
rpm -qa | grep -s katello-ca-consumer > /dev/null
if [ $? -ne 0 ]; then
    formatted_echo "WARN" 2
    echo "The server certificate is not installed." >> $IBM_RHSM_REG_LOG

    echo -n "* -> Installing server certificate... " | tee -a $IBM_RHSM_REG_LOG
    echo >> $IBM_RHSM_REG_LOG
    rpm -Uvh http://rhs.linux.ibm.com/pub/katello-ca-consumer-latest.noarch.rpm &>> $IBM_RHSM_REG_LOG
    if [ $? -ne 0 ]; then
        formatted_echo "FAIL" 1
        echo "An error has occurred while trying to install the server certificate." >> $IBM_RHSM_REG_LOG
        echo "Aborting..."
        echo
        exit 1
    else
        formatted_echo "OK" 0
    fi
else
    formatted_echo "OK" 0
    echo "Server certificate is already installed." >> $IBM_RHSM_REG_LOG
fi

## Get activation key
# in case an existing key is not found, a new one will be created.
echo -n "* Searching for an activation key... "

ACTIVATION_KEY=`run_curl $FTP3USERENC $FTP3PASSENC`

if [ -z "$ACTIVATION_KEY" ]; then
    formatted_echo "FAIL" 1
    echo
    echo -n "An error has ocurred: "
    echo "No activation key."
    echo "There was a problem while creating your activation key."
    echo "Please, make sure you are connected to the IBM network and using a valid FTP3 account."
    echo "Aborting."
    echo
    exit 1
elif [ "$ACTIVATION_KEY" == "Account not found" -o "$ACTIVATION_KEY" == "Wrong username or password" ]; then
    formatted_echo "FAIL" 1
    echo
    echo "An error has ocurred: $ACTIVATION_KEY"
    echo "Please, make sure you're using the correct FTP3 username and password."
    echo "Aborting."
    echo
    exit 1
elif [ "$ACTIVATION_KEY" == "The account $FTP3USER does not have access to Red Hat content" ]; then
    formatted_echo "FAIL" 1
    echo
    echo "An error has ocurred: $ACTIVATION_KEY"
    echo -n "You may request access on the \"My Account\" page: "
    echo "https://ftp3.linux.ibm.com/myaccount/access.php."
    echo "Aborting."
    echo
    exit 1
fi
formatted_echo "OK" 0
echo "Activation key: $ACTIVATION_KEY" >> $IBM_RHSM_REG_LOG
echo "(You may copy this activation key for future use)" >> $IBM_RHSM_REG_LOG

## system registration
echo -n "* Registering the system... "
REGSTATUS=`subscription-manager register --org Default_Organization --activationkey="$ACTIVATION_KEY"`

if [ `echo $REGSTATUS | grep -c "The system has been registered"` -ne 1 ]; then
    formatted_echo "FAIL" 1
    echo "An error has occurred while trying to register the system."
    echo "You may try to register it later using the following command:"
    echo "subscription-manager register --org Default_Organization --activationkey=\"$ACTIVATION_KEY\""
    echo
    exit 1
else
    echo "System successfully registered!" >> $IBM_RHSM_REG_LOG
    formatted_echo "OK" 0
fi

## Disable all repositories
echo -n "* Disable all repositories... " | tee -a $IBM_RHSM_REG_LOG
echo >> $IBM_RHSM_REG_LOG

subscription-manager repos --disable=* >> $IBM_RHSM_REG_LOG
if [ $? -ne 0 ]; then
    formatted_echo "FAIL" 1
    #echo "An error has occurred while disabling all the repositories." >> $IBM_RHSM_REG_LOG
else
    formatted_echo "OK" 0
fi

## Enable RHEL 7 repositories
echo -n "* Enable RHEL $RELEASE repositories... " | tee -a $IBM_RHSM_REG_LOG
echo >> $IBM_RHSM_REG_LOG

arr=("-supplementary-" "-optional-" "-")
for REPO in "${arr[@]}"; do
    subscription-manager repos --enable=rhel-$RELEASE-${LABEL}${REPO}rpms >> $IBM_RHSM_REG_LOG
    if [ $? -ne 0 ]; then
        ENABLE_REPOS=0
    fi
done

if [ -z $ENABLE_REPOS ]; then
    formatted_echo "OK" 0
else
    formatted_echo "FAIL" 1
fi

SUCCESS=0

echo
echo "Registration completed!" | tee -a $IBM_RHSM_REG_LOG

exit 0

Tuesday, July 25, 2017

AWS Host Name Change

http://www.joshwieder.net/2016/01/setting-hostname-amazon-aws-ec2-rhel-centos.html

Setting a hostname for your Amazon AWS EC2 server running RHEL or CentOS 7

So it turns out that setting your AWS EC2 server's hostname to be persistent across reboots is a surprising pain in the ass, at least with my usual OS of choice - RedHat/CentOS Linux.

If you're like me, setting a hostname is the sort of trivial non-task that at this point you really feel like you dont need to RTFM to figure out. You know about `hostnamectl set-hostname`. You've tried `nmcli general hostname`. You've manually set /etc/hostname. None of its persists past a reboot. Which can make life very difficult for those planning to use EC2 for email or dozens of other tasks.

Here's how to do it the right way, the first time. I'll also describe some circumstances that setting your own hostname will break things, and why its such a hassle to get this done in AWS in the first place.

Amazon relies on cloud-init to manage a variety of initialization tasks for its cloud servers; cloud-init was originally built to support Ubuntu images, but it is now used for a variety of different Amazon distros, including RHEL, CentOS and "Amazon linux". cloud-init is manged through a series of configuration files and modules; you can use them to add SSH keys, setup chef & puppet recipes, install SSL certificates, and all sorts of stuff. Think of it as a very fancy kickstart script.

By default, Amazon resets your server's hostname to the Public DNS entry for the IP address assigned to your server. These default hosts look something like this: ec2-111-222-333-444.compute-1.amazonaws.com for an IP address 111.222.333.444. If you have an Elastic IP Address, this hostname can be viewed through your EC2 Console by navigating to Network & Security -> Elastic IPs. The hostname is viewable in the "Public DNS" column. Because of this behavior, all of the default methods for assigning a hostname to your server are over-ridden on reboot. There is no way to change the hostname through the EC2 Console after your server has been built.

Here's the part of the walk through where I describe some circumstances where messing with your hostname can break stuff. If you have not assigned at least one Elastic IP Address (EIP) to your server, I strongly advise against messing with your server's hostname. Without an EIP, Amazon changes your server's public IP, private IP and hostname to whatever is available at the moment in your region. I haven't tried it, but I strongly suspect that making the changes in this walkthrough without an EIP will either just not work or will break something. There may be circumstances where you would want to accomplish this; hacks probably exist but this walkthrough ain't it.

Here's what to do:


Update the /etc/hostname file with your new hostname:
    [centos@... ~]$ sudo vi /etc/hostname
Initially, this file will contain the hostname assigned by Amazon. Delete this value and replace it with your preferred hostname. With vi, you must enter "INSERT MODE" to make changes to a document by pressing the i key.
NOTE: the official Amazon walkthrough tells you to add your hostname like this: HOSTNAME=persistent_host_name - that is incorrect. The correct way is to just put your hostname in there; if you want your hostname to be www.example.com than the contents of /etc/hostname should be www.example.com. The official walkthrough also tells readers to use vim using the syntax #vim <filename>. Although installed by default with RHEL 7 & CentOS 7, vim has to be launched using #vi <filename>. 
Save and exit the vi editor. After you've made you're changes, press ESCAPE to exit INSERT MODE, then press SHIFT and : [colon] simultaneously to issue a command to the vi editor. Type wq, and then press Enter to save changes and exit back to the command prompt.

Update the /etc/hosts file with the new hostname.
    [centos@... ~]$ sudo vi /etc/hosts
Change the entry beginning with 127.0.0.1 to read as follows:
127.0.0.1 www.example.com localhost.localdomain localhost
Save and exit the vi editor.

Update the /etc/sysconfig/network file.
    [centos@... ~]$ sudo vi /etc/sysconfig/network
Update the /etc/sysconfig/network file with the following values:
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=www.example.com
Save and exit the vi editor.
Change your server's primary cloud-init configuration file
    [centos@... ~]$ sudo vi /etc/cloud/cloud.cfg
Add the following string at the bottom of the file to ensure that the hostname change stays after a reboot.
    preserve_hostname: true
NOTE: At the bottom of /etc/cloud/cloud.cfg, you may find a line that appears to be commented out, like this: # vim:syntax=yaml - the preserve_hostname line must go at the very bottom of the file, even beneath the commented out line, or else it won't work.
Save and exit the vi editor.
Run the following command to reboot the instance to pick up the new hostname:
    [centos@... ~]$ sudo reboot 
After you reboot your server, execute the hostname command to check that your changes have stayed put.
    [centos@... ~]$ hostname
The command should return the new hostname:
    [centos@... ~]$ hostname
    www.example.com

And that's about it, sports fans. I ripped off most of this from an Amazon KB article on the topic, with a few updates where the KB had some mistakes. This has been an issue with AWS for a while, and there appears to be a lot of confusion on the internet on how to get this accomplished, so I hope that by making this available more people will be able to get this resolved without wasting time.

Monday, July 10, 2017

tcpdump. tcprewrite


## Get TCP DUMP Capture for traps on port 162 using

 tcpdump -s8192 -w <file name-1 > udp port 162



## Run rewrite script against this dump file to change the MAC and IP Address

rewrite.sh <file name> <New file name>

you need to install a module called tcpreply from tcpreply.org



========================

## rewrite.sh

#!/bin/bash

tcprewrite --pnat 216.83.186.66/32:216.203.1.131/32 --dmac 08:00:20:d2:19:93  -i$1 -o$2

here ## I am changing the production trap server IP to 216.203.1.131 lab server ip and adding lb servers MAC ADDR.

$1 is captured file name and $2 is new capture file with lab servers IP and MAC address.

tvprewrite --pnat=<OLDIP>/32:<NEWIP>/32 --enet-dmac <NEW-MAC> -i <old-PCAP-File> -o <new-PCAP-File>



=======================


## read this new file to confirm if headers have changed

tcpdump -r <New file name> -vv ( TWO Vs)

tcpdump -r <pcap-File> -vv > readable.out

cat readable.out | awk '{print $3}' | sort | uniq  (this is to check what source ip sending data)

## Replay this file to genrate the traps

tcpreply -i etho -o <New file name>

This will send the traps to mttrapd probe running on port 162 on Lab server.

tcpdump -nvvv dst port 162



- I have seen mttrapd probe didn't process these alarms because the firewalld was running and blocking the traffic

systemctl stop firewalld

Thursday, October 27, 2016

Script to read file and send events into object server

Script to read file and generate insert statements for nco_sql and then send events into object server


#!/opt/IBM/tivoli/netcool/precision/perl/bin/perl

use Date::Parse;
use Text::CSV;

# Control Variables:
$InputCSVFileToParse="/home/ncoadmin/DockerMount/Scripts/08-12-16.csv";

## Do not set both variables to 1 at same time
$GenerateCSVSuitedForDB2insert=0;       # Use this variable to generate csv to load directly into db2
$GenerateCSVSuitedForOmnibusGLFProbe=1; # Use this variable to generate csv file for event replay
 

open my $fh, "<", $InputCSVFileToParse or die "$InputCSVFileToParse $!";

undef($csv);

if( $GenerateCSVSuitedForOmnibusGLFProbe == 1)
{
print "\n\n";
print ">>>>>>>>>>>>>>>> Begin of format with Omnibus fields and well suited for GLF probe processing\n";
print "\n\n";

my $csv = Text::CSV->new ({
always_quote => 0,
    binary    => 1, # Allow special character. Always set this
    auto_diag => 1, # Report irregularities immediately
eol => "\n"
    });

while (my $row = $csv->getline ($fh)) {

$FO = str2time($row->[11]);
$LO= str2time($row->[12]);
print "\n";
print "insert into alerts.status (FirstOccurrence,LastOccurrence,Manager,Node,NodeAlias,Identifier,AlertGroup,AlertKey,Location,Summary,Severity,Type,ExpireTime) values ($FO,$LO,'$row->[4]','$row->[2]','$row->[3]','$row->[0]','$row->[6]','$row->[7]','$row->[18]','$row->[9]',$row->[8],$row->[14],600)\;\n";
}
print "\n\n";
print ">>>>>>>>>>>>>>>> End of format with Omnibus fields and well suited for GLF probe processing\n";

}

print "\n\n";
close $fh;



OUTPUT OF THE SCRIPT BELOW

[netcool@omnibus bin]$ ./nco_sql -server NCOMS -user root  
Password:
1> insert into alerts.status (FirstOccurrence,LastOccurrence,Manager,Node,NodeAlias,Identifier,AlertGroup,AlertKey,Location,Summary,Severity,Type,ExpireTime) values (1471047551,1471047551,'MTTrapd Probe','10.31.34.1','10.31.34.1','10.31.34.1 ccmHistoryEventEntry.521500 Configuration Change 13 Cisco-Configuration Management MTTrapd Probe 1 1 3 2','Configuration Change','ccmHistoryEventEntry.521500','(null)','Configuration Changed via Command Line  ( Source: Running Configuration-:- Destination: Command Source )',2,13,600);



#!/opt/IBM/tivoli/netcool/precision/perl/bin/perl

use Time::HiRes qw(usleep nanosleep);

$file="/home/netcool/Desktop/21July/21July_ReadFromOracle6.log.sql";
$printSTDOUT = 1;
$sendToOmnibus=1;


open(f1,"$file") or die "No file $file\n";
@Array=<f1>;
close(f1);
chomp(@Array);

$loopCount = 0;
open(f2,"|/opt/IBM/tivoli/netcool/omnibus/bin/nco_sql -server NOI_AGG_P -user root -password object00");
$countTheInserts=0;
foreach $i (@Array)
{
$loopCount = $loopCount +1;
print "$i\n" if($printSTDOUT);
print "-----------------------------------------------\n" if($printSTDOUT);
print f2 "$i\n" if($sendToOmnibus);
if( $loopCount % 101 == 0 ) # Break the nco_sql insert statements into chunks
{
$countTheInserts = $countTheInserts + 1;
print f2 "go\n" if($sendToOmnibus);
print "HEY BILL - loopCount=$loopCount\n" if($printSTDOUT);
print "HEY BILL it inserted $countTheInserts\n" if($printSTDOUT);
}
#usleep(100000);
#sleep(1);
print "loopCount=$loopCount\n";
}
close(f2);
print "loopCount=$loopCount\n";
 

Monday, October 24, 2016

Db2 Import - Load Commands

db2 LOAD FROM "/mnt/ImportFiles/0813.loadFile" OF DEL MODIFIED BY identityignore generatedignore rowchangetimestampignore timestampformat=\"YYYY-MM-DD hh:mm:ss\" implieddecimal  INSERT INTO DB2INST1.REPORTER_STATUS


Tuesday, October 18, 2016

Changing DB2 logfile Size

Use the following procedure to increase the size of the DB2 transaction log (logfilsiz):

1. Determine the current log file size setting by issuing the command:
    Unix
      su - <db2instance> 
      db2 list db directory # to list the database name 
      db2 connect to <databaseName> 
      db2 get db config for <databaseName> | grep -i logfilsiz
    Example:
      su - ldapdb2 
      db2 connect to amdb 
      db2 get db config for amdb | grep -i logfilsiz 
    Windows operating system
      open a DB2CMD window 
      set DB2INSTANCE=<databaseName> from the ibmslapd.conf file 
      db2 list db directory 
      db2 connect to <databaseName> 
      db2 get db config for <databaseName> 
      check the value for logfilsiz 
2. Increase the size of the log file size setting by issuing the command:
      db2 UPDATE db cfg for <databaseName> using LOGFILSIZ <new_value> 
    Example:
      db2 UPDATE db cfg for amdb using LOGFILSIZ 5000

3. Stop the ibmslapd process. 
ibmslapd -k -I <instance name> 

4. Issue the commands:
      db2 force applications all 
      db2stop force

5. Restart ibmslapd process.