Monday, October 17, 2016

DB2 Commands

Managing databases

Creating databases

create database <database-name> using codeset UTF-8 territory en
  
// For example (remember DB2 has a restrictions to 8 characters for databases' name):
create database MYDBNAME using codeset UTF-8 territory en

Changing number of concurrent databases

If you receive and error like this:
SQL1041N  The maximum number of concurrent databases have already been started. SQLSTATE=57032
Run following command:
db2 update dbm cfg using NUMDB <number-of-concurrent-databases>
  
// For example:
db2 update dbm cfg using NUMDB 20
  
// You should see something like this:
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully.
SQL1362W  One or more of the parameters submitted for immediate modification were not changed dynamically. Client changes will not be effective until the next time the application is started or the TERMINATE command has been issued. Server changes will not be effective until the next DB2START command.

Starting and stopping DB2


Before restarting any IBM DB2 server, I would recommend to display all applications and users that are connected to the specific database that you want to stop. To ensure that no vital or critical applications are running.
Following command list all applications
db2 list applications

If you change any configuration parameter, you will probably need to restart, so, stop database server with:
db2stop
  
// Once IBM DB2 is stopped you will see this message
SQL1064N  DB2STOP processing was successful.
Now, for starting IBM DB2 again, run following command:
db2start
  
// If everything was ok, this message would appear
SQL1063N  DB2START processing was successful.

Working with schemas

Creating a new schema

CREATE SCHEMA <schema-name>
  
// For example:
CREATE SCHEMA CSUSER
  
// After running the command a message will be displayed:
DB20000I  The SQL command completed successfully.

Obtaining users

If you want to list schema users, just run following command:
SELECT SCHEMANAME FROM syscat.schemata

As you can see part of the information about schemas and users is stored in syscat.schemata.

Grant privileges

GRANT ALL ON <schema-name>.<table-name> TO USER <user>
  
// For example:
GRANT ALL ON LCUSER.WIKI_PAGES TO USER LCUSER

Getting information about databases and tables

Connect to the database

db2 connect to <database-name>
  
// For example
db2 connect to MYDB

List information about tables

List all tables:
db2 list tables for all
To list all tables in selected schema, use:
db2 list tables for schema <schema-name>
  
// For example:
db2 list tables for schema CSUSER
To describe a table, type:
db2 describe table <table-schema.table-name>
  
// For example:
db2 describe table CSUSER.WIKI_PAGES

List information about databases

List databases:
db2 list database directory show detail | grep -B6 -i indirect | grep "Database name"
If you just want the database names, without the titles, use:
db2 list database directory show detail | grep -B6 -i indirect | grep "Database name" | sed "s/.*= //"

HANDLING ISSUES WHEN LOAD COMMAND IS IN PENDING STATE

[db2inst1@host1 ~]$ touch test.del
[db2inst1@host1 ~]$ LOAD from 'test.del' OF DEL TERMINATE INTO db2inst1.reporter_status
-bash: LOAD: command not found
[db2inst1@host1 ~]$ db2 LOAD from 'test.del' OF DEL TERMINATE INTO db2inst1.reporter_status
SQL3501W  The table space(s) in which the table resides will not be placed in
backup pending state since forward recovery is disabled for the database.

SQL3110N  The utility has completed processing.  "0" rows were read from the
input file.


Number of rows read         = 0
Number of rows skipped      = 0
Number of rows loaded       = 0
Number of rows rejected     = 0
Number of rows deleted      = 0
Number of rows committed    = 0

[db2inst1@host1 ~]$ db2 set integrity for db2inst1.reporter_status immediate checked
DB21034E  The command was processed as an SQL statement because it was not a
valid Command Line Processor command.  During SQL processing it returned:
SQL3600N  The IMMEDIATE CHECKED option of the SET INTEGRITY statement is not
valid since the table "DB2INST1.REPORTER_STATUS" is a user maintained
materialized query table or is not in the Set Integrity Pending state. 
SQLSTATE=51027
[db2inst1@host1 ~]$ db2 "select count(*) from reporter_status"

1         
-----------
     243724

  1 record(s) selected.



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


Install Perl Modules

perl -e 'use FileHandle; print $FileHandle::VERSION."\n"'


perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.960001)
Enter 'h' for help.

cpan>  install Text::CSV


If MCPAN returns can't find cpan, then as root
yum install perl-CPAN







Tuesday, October 11, 2016

Changing default JVM memory for WebGUI/Impact

Modifying JVM Memory Sizes

For WebGUI

Stop the JazzSM server
cd /opt/IBM/JazzSM/profile/bin directory.

# ./wsadmin.sh -lang jython -conntype NONE
WASX7357I: By request, this scripting client is not connected to any server process. Certain configuration and application operations will be available in local mode.
*sys-package-mgr*: processing new jar, '/opt/IBM/WebSphere/AppServer/java/jre/lib/deploy.jar'
*sys-package-mgr*: processing new jar, '/opt/IBM/WebSphere/AppServer/java/jre/lib/javaws.jar'
*sys-package-mgr*: processing new jar, '/opt/IBM/WebSphere/AppServer/java/jre/lib/j9zip.jar'
*sys-package-mgr*: processing new jar, '/opt/IBM/WebSphere/AppServer/java/jre/lib/xmldsigfw.jar'
*sys-package-mgr*: processing new jar, '/opt/IBM/WebSphere/AppServer/java/jre/lib/plugin.jar'
WASX7031I: For help, enter: "print Help.help()"

wsadmin>jvm=AdminConfig.list("JavaVirtualMachine")
wsadmin>print 'initialHeapSize: ' + AdminConfig.showAttribute(jvm, 'initialHeapSize')
initialHeapSize: 512

wsadmin>print 'maximumHeapSize: ' + AdminConfig.showAttribute(jvm, 'maximumHeapSize')       
maximumHeapSize: 4096

wsadmin>
AdminConfig.modify(jvm, '[[initialHeapSize xxx]]')
AdminConfig.modify(jvm, '[[maximumHeapSize xxx]]')
AdminConfig.save()

exit

xxx is the new heap size value, in megabytes

Restart JazzSM.

cd /opt/IBM/JazzSM/profile/bin

[root@dash bin]# ./stopServer.sh server1
Oct 24, 2016 4:47:16 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
ADMU0116I: Tool information is being logged in file
           /opt/IBM/JazzSM/profile/logs/server1/stopServer.log
ADMU0128I: Starting tool with the JazzSMProfile profile
ADMU3100I: Reading configuration for server: server1
Realm/Cell Name: <default>
Username: smadmin
Password:      
 ADMU3201I: Server stop request issued. Waiting for stop status.
ADMU4000I: Server server1 stop completed.

[root@dash bin]# ./startServer.sh server1
ADMU0116I: Tool information is being logged in file
           /opt/IBM/JazzSM/profile/logs/server1/startServer.log
ADMU0128I: Starting tool with the JazzSMProfile profile
ADMU3100I: Reading configuration for server: server1
ADMU3200I: Server launched. Waiting for initialization status.

Impact GUI/Core


    Stop a server by using the relevant command:
        On UNIX use $NCHOME/bin/stopGUIServer.sh or $NCHOME/bin/stopImpactServer.sh.
    Edit the file $IMPACT_HOME\wlp\usr\servers\<instance>\jvm.options.

    <instance>
        For GUI Server it is ImpactUI.
        For Impact Server it is the name of the Server Instance you provided during install time, the default is NCI.

    For your environment, specify the appropriate -Xms or -Xmx.
    Start the server by using the relevant command:
        On UNIX use $NCHOME/bin/startGUIServer.sh or $NCHOME/bin/startImpactServer.sh.

CORE FILES ARE HERE

/opt/IBM/tivoli/impact/wlp/usr/server/NCI

Friday, October 7, 2016

Inserting CSV file data into DB2 Reporter_Status table

We used this db2 syntax to load the data into the reporter_status database from file built via perl script

db2 connect to reporter

db2 LOAD FROM "/tmp/db2load/data_out01" OF DEL MODIFIED BY identityignore generatedignore rowchangetimestampignore timestampforma
t=\"YYYY-MM-DD hh:mm:ss\" implieddecimal  INSERT INTO DB2INST1.REPORTER_STATUS


The first two (2) lines of the input file look like:

"ch3p-gen-imn-be02 Queue Depth OGANGI SVR DEMO SMPP  1",497596055,"ch3p-gen-imn-be02","ch3p-gen-imn-be02","Socket Probe on samiam","IMNQ.ksh to socket 3","Queue Depth","OGANGI SVR DEMO SMPP ",0,"1 pending messages for OGANGI SVR DEMO SMPP  /imn_data/fq/imports/ch3p-gen-imn-be02/router/10992/MO",2016-01-27 07:41:02,2016-01-27 07:40:32,2016-01-27 07:40:32,0,1,1,1150,0,"",65534,0,0,"",360,0,0,"OGANGI SVR DEMO SMPP ","",0,0,"",0,"",0,0,"","","","","","","","",0,0,"","",2016-01-27 07:43:49,0,"NCOMS_P",497596055
"ch3p-gen-imn-be02 Queue Depth LexisNexis WS Prod  1",497596056,"ch3p-gen-imn-be02","ch3p-gen-imn-be02","Socket Probe on samiam","IMNQ.ksh to socket 3","Queue Depth","LexisNexis WS Prod ",0,"1 pending messages for LexisNexis WS Prod  /imn_data/fq/imports/ch3p-gen-imn-be02/router/11075/MO",2016-01-27 07:41:02,2016-01-27 07:40:32,2016-01-27 07:40:32,0,1,1,1150,0,"",65534,0,0,"",360,0,0,"LexisNexis WS Prod ","",0,0,"",0,"",0,0,"","","","","","","","",0,0,"","",2016-01-27 07:43:49,0,"NCOMS_P",497596056



<=============  PERL SCRIPT BELOW ==========================>>>

#!/usr/bin/perl

#use strict;
#use warnings;
use Text::CSV;
use Time::ParseDate;
use Time::Piece;


my $inputfile = "/home/wmcain/Desktop/RFP_POC/Syniverse/DataExtract_3/SCC_30DAYS.csv";
#my $inputfile = "data/data_in02";
open my $fh, "<", $inputfile or die "$inputfile: $!";

my $outputfile = "/home/wmcain/Desktop/RFP_POC/Syniverse/DataExtract_3/SCC_30DAYS.csv_extract_withTIcketInfo";
#my $outputfile = "/tmp/db2load/data_out02";
open (OUT, ">$outputfile");

my $csv = Text::CSV->new ({
    binary => 1,
    #sep_char => ',',
    always_quote => 0,        # set to 1 to keep your numbers quoted
});



while (my $row = $csv->getline ($fh)) {
    chomp($row);
    s/\n/ /g for @$row;
    s/\r\n/ /g for @$row;
    $line=$csv->string($row);
    s/\n/ /g for $line;
    $status  = $csv->parse($line);
    @columns = $csv->fields($line);
    $lm=substr($columns[10],0,18);
    $fo=substr($columns[11],0,18);
    $lo=substr($columns[12],0,18);
    $da=substr($columns[47],0,18);
    $t = Time::Piece->strptime( "$lm", "%d-%b-%y %H.%M.%S");
    $lastModified = $t->strftime("%Y-%m-%d %H:%M:%S");
    $t = Time::Piece->strptime( "$fo", "%d-%b-%y %H.%M.%S");
    $firstOccurrence = $t->strftime("%Y-%m-%d %H:%M:%S");
    $t = Time::Piece->strptime( "$lo", "%d-%b-%y %H.%M.%S");
    $lastOccurrence = $t->strftime("%Y-%m-%d %H:%M:%S");
    $t = Time::Piece->strptime( "$da", "%d-%b-%y %H.%M.%S");
    $deletedAt = $t->strftime("%Y-%m-%d %H:%M:%S");
    foreach (@columns){
      s/\"//g for $_;
    }
    print OUT "\"$columns[0]\","; #IDENTIFIER
    print OUT "$columns[1],"; #SERIAL
    print OUT "\"$columns[2]\","; #NODE
    print OUT "\"$columns[3]\","; #NODEALIAS
    print OUT "\"$columns[4]\","; #MANAGER
    print OUT "\"$columns[5]\","; #AGENT
    print OUT "\"$columns[6]\","; #ALERTGROUP
    print OUT "\"$columns[7]\","; #ALERTKEY
    print OUT "$columns[8],"; #SEVERITY
    print OUT "\"$columns[9]\","; #SUMMARY
    print OUT "$lastModified,"; #LASTMODIFIED
    print OUT "$firstOccurrence,"; #FIRSTOCCURRENCE
    print OUT "$lastOccurrence,"; #LASTOCCURRENCE
    print OUT "$columns[13],"; #POLL
    print OUT "$columns[14],"; #TYPE
    print OUT "$columns[15],"; #TALLY
    print OUT "$columns[16],"; #CLASS
    print OUT "$columns[17],"; #GRADE
    print OUT "\"$columns[18]\","; #LOCATION
    print OUT "$columns[19],"; #OWNERUID
    print OUT "$columns[20],"; #OWNERGID
    print OUT "$columns[21],"; #ACKNOWLEDGED
    print OUT "\"$columns[22]\","; #EVENTID
    print OUT "$columns[23],"; #EXPIRETIME
    print OUT "$columns[24],"; #PROCESSREQ
    print OUT "$columns[25],"; #SUPPRESSESCL
    print OUT "\"$columns[26]\","; #CUSTOMER
    print OUT "\"$columns[27]\","; #SERVICE
    print OUT "$columns[28],"; #PHYSICALSLOT
    print OUT "$columns[29],"; #PHYSICALPORT
    print OUT "\"$columns[30]\","; #PHYSICALCARD
    print OUT "$columns[31],"; #TASKLIST
    print OUT "\"$columns[32]\","; #NMOSSERIAL
    print OUT "$columns[33],"; #NMOSOBJINST
    print OUT "$columns[34],"; #NMOSCAUSETYPE
    print OUT "\"$columns[35]\","; #LOCALNODEALIAS
    print OUT "\"$columns[36]\","; #LOCALPRIOBJ
    print OUT "\"$columns[37]\","; #LOCALSECOBJ
    print OUT "\"$columns[38]\","; #LOCALROOTOBJ
    print OUT "\"$columns[39]\","; #REMOTENODEALIAS
    print OUT "\"$columns[40]\","; #REMOTEPRIOBJ
    print OUT "\"$columns[41]\","; #REMOTESECOBJ
    print OUT "\"$columns[42]\","; #REMOTEROOTOBJ
    print OUT "$columns[43],"; #X733EVENTTYPE
    print OUT "$columns[44],"; #X733PROBABLECAUSE
    print OUT "\"$columns[45]\","; #X733SPECIFICPROB
    print OUT "\"$columns[46]\","; #X733CORRNOTIF
    print OUT "$deletedAt,"; #DELETEDAT
    print OUT "$columns[48],"; #ORIGINALSEVERITY
    print OUT "\"$columns[49]\","; #SERVERNAME
    print OUT "\"$columns[50]\","; #SERVERSERIAL
    print OUT "\"$columns[110]\","; #TICKET_ELIGIBLE
    print OUT "\"$columns[153]\","; #ARS_TICKETABLE
    print OUT "\"$columns[154]\","; #ARS_INCIDENT
    print OUT "\"$columns[155]\""; #ARS_TICKETSTATUS
    print OUT "\r\n";
    }
close $fh;
close OUT;

Sending data from a remote LFA to Log Analysis

  1. The Log file to check is the GenericReceiver.log. All data that flows into LA will be reported in this log file. Sometimes, if there is something wrong, it goes through silently, and you wouldn't know it. Other times, it will go through, but with a very high level message about the timestamp being wrong, or something like that. If you want to see more detailed logging, edit this file:

/opt/IBM/LogAnalysis/wlp/usr/servers/Unity/apps/Unity.war/WEB-INF/classes/log4j.properties

and change the setting for the log4j.logger.UnityGenericReceiver to DEBUG, then restart unity.  You will then see EVERYTHING that comes in, so its very verbose! Useful for knowing just what is going into the API.

  1. When you configure your remote log file agent, these setting are the most important:
a)     conf/lo/[subnode].conf:
LogSources=/gsa/hurgsa/home/w/o/woolnom/IHS_log/error_log_2016-04-29

This is the pattern to match the log file/s that you want to stream through. The file name can be a pattern like *.log, but the directory path can't. If you have multiple directories and file, use a comma to seperate each directory and filename.

ServerLocation=marco.hursley.ibm.com
ServerPort=5529

This is the Log Analysis host name and EIF port
b)     conf/lo/[subnode].fmt
The two most important settings are:

hostname huraix.hursley.ibm.com
-file /gsa/hurgsa/home/w/o/woolnom/IHS_log/access_log_2016-04-29

The host name MUST match the EXACT host name you set in the data source properties.
The file MUST match the EXACT path you specify in data source properties you configure in the Log Analysis Admin Data Sources screen.
NOTE: hostname and file name and the host and log path values you set in the datasource can actually be anything. As long as they are unique, they don't have to be the physical values. This is ONLY true when you create a Custom data source. Speaking of which....

  1. When you create a datasource and you are streaming data from a remote agent, make sure you create it as a Custom data source. This is frequently an area of confusion, but the options for creating data sources boil down to this:
a)     Local: A log file that resides on the Local Log Analysis Filesystem
b)     Remote: A log file that resides on a REMOTE node that you will stream using the embedded Log File Agent in Log Analysis, by supplying ssh credentials.
SO, LOCAL AND REMOTE DATA SOURCES ARE COUPLED TO THE LOG FILE AGENT RUNNING ON THE LOG ANALYSIS SERVER
    • Custom: Use this for everything else. This sets up the data source and assumes the generic receiver api will recieve data from a seperate agent installed remotely.
IF YOU ARE USING A REMOTE LOG FILE AGENT, CREATE YOUR DATA SOURCE AS A CUSTOM DATA SOURCE AND ENSURE THE HOST AND PATH SETTINGS MATCH THE LFA SETTINGS I DESCRIBE ABOVE!
If you use logstash, you will always create a custom data source.
I hope this helps. If you still have problems after this, its probably down to chosing the wrong source type, or a mismatch between your data and the version the pack was written for. You will gather this from the verbose DEBUG logging.

Thursday, August 4, 2016

Bill Cain Notes - AWS Setup

One time only Setup CLI into AWS:
    http://docs.aws.amazon.com/cli/latest/userguide/installing.html#cli-test-the-setup
        $ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
        $ unzip awscli-bundle.zip
        $ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

One time only:  "aws configure"

Each Day run this to get current day login string:   "aws ecr get-login --region us-east-1"

----------------------------------------------------------------------------------------------------

If all your AWS instances do not have BTRFS file system formatting, then the default max disk space
size for docker containers will be 10GB.  This is too small for the IBM Dash Docker container.

Steps to setup docker service on rhel7 to have large enough to support the IBM Dash docker container
    1. stop docker
    2. remove directory /var/lib/docker (this will remove any pulled images)
    3. edit /usr/lib/systemd/system/docker.service
            update line starting with ExecStart to :
            ExecStart=/usr/bin/docker daemon -H fd://  --storage-driver devicemapper --storage-opt dm.basesize=50G
        save the file
    4. systemctl daemon-reload
    5. start docker

----------------------------------------------------------------------------------------------------

Steps to upload NOI Docker containers:

Example to connect:
    docker login  -u AWS  -p <big_long_encrypted_hash>  -e none   https://093244773991.dkr.ecr.us-east-1.amazonaws.com

Example to tag an existing container:
    run - to tag Dash container       "docker tag noi1401-ifix/dash:latest 093244773991.dkr.ecr.us-east-1.amazonaws.com/itsm01:dash"
    run - to tag Impactcore container "docker tag noi1401-ifix/impactcore:latest 093244773991.dkr.ecr.us-east-1.amazonaws.com/itsm01:impactcore"

Example to load an existing local container after it has been tagged using AWS syntax
    docker push 093244773991.dkr.ecr.us-east-1.amazonaws.com/itsm01:dash

----------------------------------------------------------------------------------------------------

Create your AWS instance (virtual machine)

----------------------------------------------------------------------------------------------------

Connecting to your AWS instance
    https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

# Setup the aws command line environment (aws configure)

# Get info about specific instance (validate its existence)
    aws ec2 get-console-output --instance-id i-0ea22089a33d69cdd
                or
                aws ec2 get-console-output --headers --instance-id i-0ea22089a33d69cdd

# Obtain the PEM certificate file (Private Key File when Instance was created)

# ssh in Linux
    chmod 400 /root/Desktop/itsm-noi-14.pem
    ssh -i /root/Desktop/itsm-noi-14.pem ec2-user@ec2-54-235-4-35.compute-1.amazonaws.com

----------------------------------------------------------------------------------------------------

Docker setup Once logged into AWS instance

- setup docker repo - https://docs.docker.com/engine/installation/linux/rhel/
                             sudo tee /etc/yum.repos.d/docker.repo <<-EOF
                                    [dockerrepo]
                                    name=Docker Repository
                                    baseurl=https://yum.dockerproject.org/repo/main/centos/7
                                    enabled=1
                                    gpgcheck=1
                                    gpgkey=https://yum.dockerproject.org/gpg
                                    EOF
- install docker-engine (sudo yum install docker-engine)
- download AWS command line tool
- Install AWS command line tools
- run "aws configure"
- run "aws ecr get-login --region us-east-1"  <-- this produces the next line for "docker login"
- run "docker login  -u AWS  -p <big_long_encrypted_hash>  -e none   https://093244773991.dkr.ecr.us-east-1.amazonaws.com"
- run - download Omnibus container  "docker pull 093244773991.dkr.ecr.us-east-1.amazonaws.com/itsm01:omnibus"
    (This pulls the docker container from the AWS repository to local host)
    Now tag the pulled AWS container to have the same name which the IBM deployment scripts use:
        run "docker tag 093244773991.dkr.ecr.us-east-1.amazonaws.com/itsm01:omnibus noi1401-ifix/omnibus:latest"

- run (if not using the IBM deployment scripts) ...  "docker run -d -i --ulimit nofile=8192:8192 --ulimit nproc=16384:16384 -p 4100:4100 -p 45037:45037 -p 162:162 -p 162:162/udp -p 9002:9001 -p 9093:9090 -p 9098:9095 -p 9998-9999:9998-9999 -h omnibus --name=omnibus -u netcool c6cae41ef50b"  #( This is not including the other parameters to build the /etc/hosts file for this container which is part of an NOI install - eg multiple docker containers)

----------------------------------------------------------------------------------------------------

Copy IBM Created docker images into AWS instance (as needed - this is not needed if "docker push" steps were performed above
    scp -i /root/Desktop/itsm-noi-14.pem database.tgz  ec2-user@ec2-54-164-87-185.compute-1.amazonaws.com:/home/ec2-user/database

----------------------------------------------------------------------------------------------------

Ensure there is sufficient disk space in your AWS instance
     -AND-
The filesystem space must be formatted "btrfs"
Create BTRFS file system for docker images
    (recall an additional storage block space has been allocated to our AWS instance)
    (recall also Docker loads its file system in /var/lib/docker)
        lsblk  (lists device files)
        mkfs.btrfs /dev/xvdb
        mkdir /opt/IBMDocker
        Edit /etc/fstab , add entry
              --->  /dev/xvdb                                 /opt/IBMDocker                  btrfs   defaults        0 0
        mount -a

----------------------------------------------------------------------------------------------------

Copying files from AWS S3 storage into your AWS instance
    - setup aws authentication session
    - run "aws s3 cp s3://noidockerimages/dash.tgz My_dash.tgz"

----------------------------------------------------------------------------------------------------

Uploading DB2 docker tarball - this is the case if not using AWS Docker service (basically we build our own private docker hub within our AWS instance)

    Ensure all unix commands required by IBM deployment script are present
       
  mkdir /tmp/database ( This becomes full path /home/ec2-user/database )
        (perform the scp copy for each IBM docker instance tarball file)
  scp -i /root/Desktop/itsm-noi-14.pem   database.tgz   ec2-user@ec2-54-164-87-185.compute-1.amazonaws.com:/home/ec2-user/database

----------------------------------------------------------------------------------------------------

Using existing IBM docker deployment script. (So this ignores the AWS Docker service)
    Setup passwordless ssh for "root" account in your AWS instance
        cd /root/.ssh
        cp authorized_keys authorized_keys.OLD
        cat id_rsa.pub >> authorized_keys
        ssh root@172.31.8.223   (validation step)

    Ensure all unix commands required by IBM deployment script ( ./noi-docker.sh ) are present
        yum install bind-utils.x86_64   

    Start AWS container networking in proper order required for Docker port maps
        systemctl stop docker
        systemctl restart firewalld
        iptables -I INPUT 1 -i docker0 -j ACCEPT   <---- You might need to run this after starting the docker service
        systemctl start docker
        ./noi-docker.sh -start database omnibus impactcore impactgui dash

Thursday, July 21, 2016

Adding SWAP to AWS EC2 Instance

[root@ip-172-31-8-223 /]# more /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Nov  9 20:20:10 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=379de64d-ea11-4f5b-ae6a-0aa50ff7b24d /                       xfs     defaults        0 0
/dev/xvdf                                 /opt/IBMDocker                  btrfs   defaults        0 0
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# more /etc/mnttab
/etc/mnttab: No such file or directory
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# lsblk
NAME                                                                                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda                                                                                  202:0    0   10G  0 disk
├─xvda1                                                                               202:1    0    1M  0 part
└─xvda2                                                                               202:2    0   10G  0 part /
xvdf                                                                                  202:80   0  150G  0 disk /opt/IBMDocker
xvdg                                                                                  202:96   0   20G  0 disk
loop0                                                                                   7:0    0  100G  0 loop
└─docker-0:36-3241-pool                                                               253:0    0  100G  0 dm
  ├─docker-0:36-3241-d54f81e9015ddc70c47a99fa8f2b682cbddde4a2bf8544e346447eb013adbcdc 253:1    0   50G  0 dm
  ├─docker-0:36-3241-3c373a7b8bc9c4a2d22e4c6d82ff112d22679dc226834175f4b7a0fc71eec85b 253:2    0   50G  0 dm
  ├─docker-0:36-3241-5ac5006fbca47bcedcfe9c3140cfbfa96b739d1e1a943287607915cd20b8011c 253:3    0   50G  0 dm
  ├─docker-0:36-3241-eaa5b76f2e987165319fb006d1850f7283d9071f01175f17da3d05126fbb7423 253:4    0   50G  0 dm
  ├─docker-0:36-3241-6bf3bda9ecc67ad639fb127bcdd91610b2dfb3b7b8c8479494bad342fb34c801 253:5    0   50G  0 dm
  └─docker-0:36-3241-3149fd173c6a79bfcd1dfb0c94d07a77caf3e1bd605106b0f8ad9affcae29ef3 253:6    0   50G  0 dm
loop1                                                                                   7:1    0    2G  0 loop
└─docker-0:36-3241-pool                                                               253:0    0  100G  0 dm
  ├─docker-0:36-3241-d54f81e9015ddc70c47a99fa8f2b682cbddde4a2bf8544e346447eb013adbcdc 253:1    0   50G  0 dm
  ├─docker-0:36-3241-3c373a7b8bc9c4a2d22e4c6d82ff112d22679dc226834175f4b7a0fc71eec85b 253:2    0   50G  0 dm
  ├─docker-0:36-3241-5ac5006fbca47bcedcfe9c3140cfbfa96b739d1e1a943287607915cd20b8011c 253:3    0   50G  0 dm
  ├─docker-0:36-3241-eaa5b76f2e987165319fb006d1850f7283d9071f01175f17da3d05126fbb7423 253:4    0   50G  0 dm
  ├─docker-0:36-3241-6bf3bda9ecc67ad639fb127bcdd91610b2dfb3b7b8c8479494bad342fb34c801 253:5    0   50G  0 dm
  └─docker-0:36-3241-3149fd173c6a79bfcd1dfb0c94d07a77caf3e1bd605106b0f8ad9affcae29ef3 253:6    0   50G  0 dm
[root@ip-172-31-8-223 /]# mkswap -f /dev/xvdg
Setting up swapspace version 1, size = 20971516 KiB
no label, UUID=e322f4a9-cfdb-4906-9c45-74362ba4fac6
[root@ip-172-31-8-223 /]# swapon /dev/xvdg
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# lsblk
NAME                                                                                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda                                                                                  202:0    0   10G  0 disk
├─xvda1                                                                               202:1    0    1M  0 part
└─xvda2                                                                               202:2    0   10G  0 part /
xvdf                                                                                  202:80   0  150G  0 disk /opt/IBMDocker
xvdg                                                                                  202:96   0   20G  0 disk [SWAP]
loop0                                                                                   7:0    0  100G  0 loop
└─docker-0:36-3241-pool                                                               253:0    0  100G  0 dm
  ├─docker-0:36-3241-d54f81e9015ddc70c47a99fa8f2b682cbddde4a2bf8544e346447eb013adbcdc 253:1    0   50G  0 dm
  ├─docker-0:36-3241-3c373a7b8bc9c4a2d22e4c6d82ff112d22679dc226834175f4b7a0fc71eec85b 253:2    0   50G  0 dm
  ├─docker-0:36-3241-5ac5006fbca47bcedcfe9c3140cfbfa96b739d1e1a943287607915cd20b8011c 253:3    0   50G  0 dm
  ├─docker-0:36-3241-eaa5b76f2e987165319fb006d1850f7283d9071f01175f17da3d05126fbb7423 253:4    0   50G  0 dm
  ├─docker-0:36-3241-6bf3bda9ecc67ad639fb127bcdd91610b2dfb3b7b8c8479494bad342fb34c801 253:5    0   50G  0 dm
  └─docker-0:36-3241-3149fd173c6a79bfcd1dfb0c94d07a77caf3e1bd605106b0f8ad9affcae29ef3 253:6    0   50G  0 dm
loop1                                                                                   7:1    0    2G  0 loop
└─docker-0:36-3241-pool                                                               253:0    0  100G  0 dm
  ├─docker-0:36-3241-d54f81e9015ddc70c47a99fa8f2b682cbddde4a2bf8544e346447eb013adbcdc 253:1    0   50G  0 dm
  ├─docker-0:36-3241-3c373a7b8bc9c4a2d22e4c6d82ff112d22679dc226834175f4b7a0fc71eec85b 253:2    0   50G  0 dm
  ├─docker-0:36-3241-5ac5006fbca47bcedcfe9c3140cfbfa96b739d1e1a943287607915cd20b8011c 253:3    0   50G  0 dm
  ├─docker-0:36-3241-eaa5b76f2e987165319fb006d1850f7283d9071f01175f17da3d05126fbb7423 253:4    0   50G  0 dm
  ├─docker-0:36-3241-6bf3bda9ecc67ad639fb127bcdd91610b2dfb3b7b8c8479494bad342fb34c801 253:5    0   50G  0 dm
  └─docker-0:36-3241-3149fd173c6a79bfcd1dfb0c94d07a77caf3e1bd605106b0f8ad9affcae29ef3 253:6    0   50G  0 dm
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# swapon -v
NAME      TYPE      SIZE USED PRIO
/dev/xvdg partition  20G   0B   -1
[root@ip-172-31-8-223 /]#


[root@ip-172-31-8-223 /]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Nov  9 20:20:10 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=379de64d-ea11-4f5b-ae6a-0aa50ff7b24d /                       xfs     defaults        0 0
/dev/xvdf                                 /opt/IBMDocker                  btrfs   defaults        0 0
/dev/xvdg       swap    swap defaults   0       0
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# swapon -v
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Nov  9 20:20:10 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=379de64d-ea11-4f5b-ae6a-0aa50ff7b24d /                       xfs     defaults        0 0
/dev/xvdf                                 /opt/IBMDocker                  btrfs   defaults        0 0
/dev/xvdg       swap    swap defaults   0       0
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# swapoff -a
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# swapon -a
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]#
[root@ip-172-31-8-223 /]# swapon -v
NAME      TYPE      SIZE USED PRIO
/dev/xvdg partition  20G   0B   -1

Saturday, July 16, 2016

Displaying status and percentage in DASH widget

http://www.ibm.com/support/knowledgecenter/SSSHYH_7.1.0.4/com.ibm.netcoolimpact.doc/solution/uidataprovider_status_and_precentages_widget_t.html

Displaying status and percentage in a widget

You can show status and percentage in topology, tree, table, and list widgets by using policies or data types. To show status and percentages in a widget, you must create a script in JavaScript format in the data type if the policy uses the GetByFilter function.

About this task

For data types, SQL, SNMP, and internal data types are supported. For policies the GetByFilter, DirectSQL and Impact Object, and Array Of Impact Objects are supported.
  1. Create the data type.
  2. In the data type configuration window, add the script to the Define Custom Types and Values (JavaScript) area.
    Restriction: Not all functions that are provided by JavaScript are supported. If you get a syntax error for a known JavaScript function, check that the function is supported in an Impact policy.
  3. Click the Check Syntax and Preview Sample Result button to preview the results and to check the syntax of the script.
For DirectSQL and Impact Object, Array Of Impact Objects, the Status, and Percentage can be specified when you create the schema definition. For policies, you can use IPL or JavaScript for the DirectSQL or GetByFilter functions.
The script uses the following syntax for data types and for policies that use the GetByFilter function.
ImpactUICustomValues.put("FieldName,Type",VariableName);
Where Type is either Percentage or Status. VariableName, can be a variable or hardcoded value. Always cast the variable name to String to avoid any error even if the value is numeric. See the following examples:
ImpactUICustomValues.put("MyField,Percentage",""+VariableName);
ImpactUICustomValues.put("MyField,Percentage","120");
ImpactUICustomValues.put("FieldName,Percentage",""+(field1/40));
The status field expects the value to be similar to the Topology widget configuration:
Table 1. Status field values
Status Number
Critical 5
Major 4
Minor 3
Warning 2
Intermediate or Indeterminate.
  • Either status is available when the connection to Netcool/Impact uses https.
  • If the connection is https, go to $IMPACT_HOME/etc/server.props and set the property
    • impact.uidataprovider.useiconfromprovider=true
  • For all examples, you can replace Intermediate with Indeterminate when needed.
1
There is no limit to how many fields you can put in the variable ImpactUICustomValues. The variable must be at the very end of the script. Anything before the variable must be in JavaScript and can be anything if the variable ImpactUICustomValues is populated correctly.
Example 1:
Assigns the field name from the table to be the status or the percentage and assigns the field value. This example assigns SHAREDOWN and PROFIT as the percentages, and STANDING as the status.
ImpactUICustomValues.put("SHAREUP,Percentage",SHAREUP);
ImpactUICustomValues.put("SHAREDOWN,Percentage",SHAREDOWN);
ImpactUICustomValues.put("PROFIT,Percentage",PROFIT);
ImpactUICustomValues.put("STANDING,Status",STANDING);
Example 2:
This example has an extra calculation to determine the value of percentage or status fields. The percentage assumes the maximum value to use is 100. Then, a factor is used to scale the values that are based on the maximum value that is expected by the user. The status and percentage is scaled based on a factor.
var status = "Normal";
var down = 0;
var up = 0;
var factor = ( TOTAL / 100);
down = (DOWN / factor);
up = (UP / factor);
var statusFactor = (DOWN / TOTAL) * 100;
if ( statusFactor >= 50) {
   status = "Critical";
} else if ( statusFactor >= 30 ) {
   status = "Major";
} else if (statusFactor >= 20) {
   status = "Minor";
} else if (statusFactor >= 10 ) {
  status = "Warning";
} else {
   status = "Normal";
}
ImpactUICustomValues.put("DownPercentage,Percentage",""+down);
ImpactUICustomValues.put("UpPercentage,Percentage",""+up);
ImpactUICustomValues.put("NetworkStatus,Status",""+status);
Example 3:
This example uses extra fields that do not exist in the table and used to be the Status and Percentage. The values are the exact values that come from fields that exist in the table. Calculation can be used to assign different values:
ImpactUICustomValues.put("CPUPercentUsage,Percentage",CPUUsage);
ImpactUICustomValues.put("RAMPercentUsage,Percentage",RAMUsage);
ImpactUICustomValues.put("DiskPercentUsage,Percentage",DiskUsage);
ImpactUICustomValues.put("NetworkAvailability,Status",NetworkStatus);
Tip: The Table or List widget shows duplicate entries or have missing data when you compare the data to the data type data items. Check the data source to ensure that all keys are unique.
Tip: In an instance where you use a policy function to create a dynamic filter, and you get a message in the policy log. The messages states that the filter variable is not defined in policy. No eventing occurs between widgets. Check that you are not using any special characters in the custom value in the data type for example, ImpactUICustomValues.put("CPU%,Percentage",""+value). The widgets do not support special characters in field names.
Tip: If a data type field type is incorrectly defined, for example the field is defined as an integer, but contains float values the widget fails to load. The widget shows a message similar to this example:
Failed to load
To resolve the issue, edit the data type field and select the correct data type float.

Wednesday, July 13, 2016

LA Insight pack for AWS Cloudwatch



o install the file:
copy it over to /opt/IBM/LogAnalysis/unity_content
cd to the directory above
../utilities/pkg_mgmt.sh -install AWS_v1.0.0.3.zip
this will install the insight pack with two new source types.  you can see these in the admin settings under "source types" tab:
aws_log and aws_metric
You can then create 2 new data sources in the Log Analysis admin screen for each file
In the admin settings tab, go to data sources and create 2 new data sources:  one for each log you want to load (metric and log)
First tab:  Local for a local file on the same computer as the la instance you are looking at.  Remote will ask you for SSH credentials for the remote server the log file resides on
second tab:  either use browse to select your file or manually input its location, use aws_metric or aws_log depending on the file you entered
third tab:  only mandatory field is the name.  Give it something meaningful.
>>>> you should see a message saying data was ingested.
Check this by going to search:

To see the LFA configs for these:
/opt/IBM/LogAnalysis/IBM-LFA-6.30/config/lo
there will be an fmt and conf pair