Wednesday, 26 March 2014

Exploring DotCMS Cont.

Looks like a very Robust CMS system that allows all kinds of content.
Also integrates many canvases for editing content either by typing HTML or using WUSIWUG.
The tool is very polished and the test site that comes with it is a very cool static site that is enterprise grade.

Though i didn't test how would it be able to handle lots of hits for content queries and didn't do comprehensive site creation with it.

Will continue to post more about it . . .

Thursday, 20 March 2014

Exploring DotCMS

The dotcms tool is proving to be a great content management system for free.
It has all the bells and whistles out of the box.
just finished its installation and now started playing with it.
Proves to be rather solid and very well organized.

Will post more as it goes.
http://dotcms.com/

Sunday, 2 March 2014

Generic multi instance startup script

Currently working on creating a generic multi instance start up script for TC server  (tomcat).
Features should include:
1- startall
2- stopall
3- start a set of TCs serving same part of the business
4- stop a set of TCs serving same part of the business
5- start 1 instance
6- stop 1 instance
7- print status of all TC instances

Once done will post the script here.
The script used a config file, will post it also :)

#set -x

if [ -z ${1} ]
then
        echo "missing property file"
        exit 1
fi
####
## need to initalize the APPS Associative array here.
typeset -A APPS
source ${1}

###
# Display the apps :)
#echo ${!APPS[@]}



####
## Setting action menu
actions="start stop status stopAll startAllDefault start_selective stop_selective"
if [ "$2" != "" ]; then
  action=$2
else
  echo "Please select an action:"
  select action in ${actions}; do
    case ${REPLY} in
      1|2|3|4|5|6|7) echo "Selection: ${action}"; break;;
      *) echo "Invalid Selection. Exiting."; exit 1;;
    esac
  done
fi
 
#set -x

if [ -z ${1} ]
then
        echo "missing property file"
        exit 1
fi
####
## need to initalize the APPS Associative array here.
typeset -A APPS
source ${1}

###
# Display the apps :)
#echo ${!APPS[@]}



####
## Setting action menu
actions="start stop status stopAll startAllDefault start_selective stop_selective"
if [ "$2" != "" ]; then
  action=$2
else
  echo "Please select an action:"
  select action in ${actions}; do
    case ${REPLY} in
      1|2|3|4|5|6|7) echo "Selection: ${action}"; break;;
      *) echo "Invalid Selection. Exiting."; exit 1;;
    esac
  done
fi
 
start|stop|status)
                for instance in `echo ${APP_SERVER_RUN_DEFAULT}|tr "," " "`
                do
                        HOST=`echo ${instance} |cut -d"_" -f1`
                        PORT=`echo ${instance} |cut -d"_" -f2`
                        echo ""
                        echo "Working on ${HOST}"
                        read -n1 -p "Do you want to preform the action: ${action} on ${instance} ?" reply
                        if [ "${reply}" = "y" ]
                        then
                                echo ""
                                ssh -q ${TARGET_USER_NAME}@${HOST} ${TARGET_TCS_INST_HOME}/${instance}/bin/tcruntime-ctl.sh ${action}
                        else
                                echo ""
                                echo "no action on ${instance}"
                        fi
                done
                echo "All Done"
        ;;

        start_selective)


                select APPkey in ${!APPS[@]}
                do
                        echo "${APPkey}: ${APPS[${APPkey}]}";
                        action=start
                        for instance in `echo ${APP_SERVER_RUN_DEFAULT}|tr "," " "`
                        do
                                HOST=`echo ${instance} |cut -d"_" -f1`
                                PORT=`echo ${instance} |cut -d"_" -f2`
                                FOUND=`echo ${APPS[${APPkey}]} |grep ${PORT} |wc -l`
                                #echo $FOUND
                                if [ ${FOUND} = "0" ]
                                then
                                        echo "skipping"
                                else
                                        echo ""
                                        echo "Working on ${HOST}"
read -n1 -p "Do you want to preform the action: ${action} on ${instance} ?" reply
                                        if [ "${reply}" = "y" ]
                                        then
                                                echo ""
                                                ssh -q ${TARGET_USER_NAME}@${HOST} ${TARGET_TCS_INST_HOME}/${instance}/bin/tcruntime-ctl.sh ${action}
                                        else
                                                echo ""
                                                echo "no action on ${instance}"
                                        fi
                                fi
                        done

                        #break the select loop
                        break
                done
        ;;

        stop_selective)

                select APPkey in ${!APPS[@]}
                do
                        echo "${APPkey}: ${APPS[${APPkey}]}";
                        action=stop
                        for instance in `echo ${APP_SERVER_RUN_DEFAULT}|tr "," " "`
                        do
                                HOST=`echo ${instance} |cut -d"_" -f1`
                                PORT=`echo ${instance} |cut -d"_" -f2`
                                FOUND=`echo ${APPS[${APPkey}]} |grep ${PORT} |wc -l`
                                #echo $FOUND
                                if [ ${FOUND} = "0" ]
                                then
                                        echo "skipping"
                                else
                                        echo ""
                                        echo "Working on ${HOST}"
                                        read -n1 -p "Do you want to preform the action: ${action} on ${instance} ?" reply
                                        if [ "${reply}" = "y" ]
                                        then
echo ""
                                                ssh -q ${TARGET_USER_NAME}@${HOST} ${TARGET_TCS_INST_HOME}/${instance}/bin/tcruntime-ctl.sh ${action}
                                                ssh -q ${TARGET_USER_NAME}@${HOST} rm -rf ${TARGET_TCS_INST_HOME}/${instance}/work/*
                                                ssh -q ${TARGET_USER_NAME}@${HOST} rm -rf ${TARGET_TCS_INST_HOME}/${instance}/temp/*
                                                ssh -q ${TARGET_USER_NAME}@${HOST} "find ${TARGET_TCS_INST_HOME}/${instance}/webapps/* -type d|grep -v ROOT|xargs rm -rf"
                                        else
                                                echo ""
                                                echo "no action on ${instance}"
                                        fi
                                fi
                        done

                        #break the select loop
                        break
                done

        ;;


esac
 

Tuesday, 18 February 2014

Exploring SVN / GIT and Jenkins integration

Was working on creating a test SVN repository for testing purposes.
I have worked extensively with CVS before in my experience in HP enterprise services, but done limited work with SVN.

SVN is much better CM tool and offers a set of decent web interfaces and integrates well with apache.
Jenkins also supports GIT, which would be my next logical step.
Jenkins can do a lot integrating with a CM tool from doing old style deployment to distributing codes and scripts to different parts of a given system.
Jenkins has the ability to managed remote nodes and can even work with standard password authentication. handles all the overhead beautifully :)

Setting up GIT is similar to SVN.
Now following the below link to setup a GIT repository for testing.
http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server

integrating git with Jenkins would work straight forward similar to SVN.

 

Monday, 3 February 2014

TC server JMX trap !

From: http://static.springsource.com/projects/tc-server/2.0/admin/htmlsingle/admin.html#manual



Warning: The value of the bind attribute of JmxSocketListener overrides the value of the java.rmi.server.hostname Java system property. This directly affects how names are bound in the RMI registries; by default, the names will be bound to localhost (127.0.0.1.) This in turn means that RMI clients running on a different host from the one hosting the tc Runtime instance will be unable to access the RMI objects because, from their perspective, the host name is incorrect. This is because, the host should be the name or IP address of the tc Runtime computer rather than localhost. When the tc Runtime instance starts, if it finds that the value of the bind attribute is different from or incompatible with the java.rmi.server.hostname Java system property, the instance will log a warning but will startup anyway and override the system property as described. If this causes problems in your particular environment, then you should change the value of the bind attribute to specify the actual hostname on which the tc Runtime runs rather than the default 127.0.0.1 value.


The above has cause me to work for 4 hours looping in circles !!!
Tomcat just rocks !!

Thursday, 30 January 2014

JMX on TC Server (Tomcat)

Currently working on a PoC to enable remote JMX on TC server.

The config to do this goes into 3 places:
1- Setenv.sh:
needs to put in JVM parameters to allow JMX remotely using authentication

JMX_OPTS="-Dcom.sun.management.jmxremote
  -Dcom.sun.management.jmxremote.port=16001
  -Dcom.sun.management.jmxremote.ssl=false
  -Dcom.sun.management.jmxremote.authenticate=true
  -Dcom.sun.management.jmxremote.password.file=${CATALINA_BASE}/conf/jmxremote.password
  -Dcom.sun.management.jmxremote.access.file=${CATALINA_BASE}/conf/jmxremote.access"

2- jmxremote.access:
[root@khofo05 conf]# cat jmxremote.access
#admin readonly
admin readwrite
[root@khofo05 conf]#

3- jmxremote.password
[root@khofo05 conf]# cat jmxremote.password
# The "admin" role has password "springsource".
admin springsource
[root@khofo05 conf]#

The above is sufficient to have an authenticated remote JMX up and running on any tomcat.

I wanted to explore using SSL, for more protection since JMX would allow altering server parameters if readwrite rule is required, but since I need JMX  for monitoring purpose is would just need to have read only rules.

After some reading and consulting my colleges i decided to abandon JMX and go with Jstatd instead.

AWK string manipulations

The below script is used to scan a full text file line by line for a certain pattern.
Once this pattern is found,
The script does another pattern matching to do another change in that same line.

[root@khofo05 sherif]$  awk -v FILENAME=./server.xml_20131127_1 -f ./change_ds.awk >server.xml
[root@khofo05 sherif]$ cat change_ds.awk
BEGIN{
        i=0;
        line="";
        while (getline line < FILENAME)
        {
                gotit=match(line,"DB1");
                if (gotit == 0)
                {
                        print(line);
                }
                else if (gotit > 0 )
                {
                        #print ("match------",line);
                        newsvr=gsub("db111oracle.example.com","db123oracle.example.com",line);
                        newsid=gsub("DB1","DB3",line);
                        #print (newsvr,newsid,line);
                        print (line);
                        #break;
                }
        }
}
[root@khofo05 sherif]$



The above is an example for a mass change in a server.xml file for changing a Datasource definition from a SID/host to another SID/host.
Would be useful if multiple datasources are involved.