jeudi 8 mars 2018

Filtering on IP and FQDN on HTTPD Virtual Host

Here is a sample file to filter on IP

NameVirtualHost *:80
ProxyPreserveHost On







#Redirection for www Host on another Website

ServerName www.mycompany-france.com
Redirect / http://www.mycompany.com/


#Redirection for error host to display the specific message "You are not authorized to access from this ip
 
ServerName error.
mycompany-france.com


# Document to display in case of authorization refused# you may indicate in that document the procedure to follow to add an ip
ErrorDocument 403 http://error.mycompany-france.com/error/authreq.html


# The place where the IP are added.

Order deny,allow
Deny from all
Allow from 80.231.232.69 193.56.36.2 193.202.91.11 90.89.210.95

# The application server for My company work council
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
ServerName workcouncil.mycompany-france.com


mercredi 28 février 2018

R rough guide



Working directory
getwd()

setwd("D:\\data\\Core kpi\\workspace\\tekpi-service\\src\\test\\resources\\data\\performance")

Loading data from external files

testplan.1_users.20171228 <- data="" ore="" read.csv="" u="">kpi
/workspace/tekpi-service/src/test/resources/data/performance/testplan-per-query-aggregate-1_users-20171228.csv")

Converting from Posix Date

In jmeter, the date are stored in POSIX format (number of millis since 1970), in order to generate propely the date. Use the following commande.

.1_users.20171228$timeStamp/1000,origin ="1970-01-01", tz = "GMT"))

View a table
View(testplan.1_users.20171228)

Install a package
install.packages("ggplot2")

load a library
library("ggplot2")

dataTestFiles<- u="">dir
(pattern = "testplan-per-query-aggregate-.*-20180125.*")

Process a batch of file
testplan<-null span="">
for (filename in dataTestFiles) {
  print(filename);
  nbUserStr<-sub u="">testplan
-per-query-aggregate-","",filename)
  nbUserStr<-sub nbuserstr="" span="" users="">
  nbUserStr<- u="">strsplit
(nbUserStr,"-")[[1]][1]
  nbUser<-as .numeric="" nbuserstr="" span="">
  print(substr(filename,30,30));
  temptestplan <- filename="" read.csv="" span="">
  temptestplan$nbuser=nbUser;
  splittedData <- data.frame="" do.call="" u="">rbind
', strsplit(as.character(temptestplan$label),'-',fixed=TRUE)))
  temptestplan<- u="">cbind
(temptestplan,splittedData)
  temptestplan$session=filename;
  testplan<- u="">rbind
(testplan,temptestplan)
}

Agregate on function
aggregate(x=testplanclean$elapsed,by=list(testplanclean$session),FUN='mean')
aggregate(x=testplanclean$elapsed,by=list(testplanclean$session),FUN='var')
aggregate(x=testplanclean$elapsed,by=list(testplanclean$session),FUN='max')
nbReqSession<-aggregate x="<u">testplanclean
$elapsed,by=list(testplanclean$session),FUN='length')
startSession<-aggregate x="<u">testplanclean
$timeStamp,by=list(testplanclean$session),FUN='min')
endSession<-aggregate x="<u">testplanclean
$timeStamp,by=list(testplanclean$session),FUN='max')
intensite<- u="">cbind
(nbReqSession[1],nbReqSession[2]/(endSession[2]-startSession[2])*60000)
testplanclean$nbuserlabel<-paste u="">testplanclean
$nbuser, " user: ",testplanclean$X1)

# Time elapsed per User and type of graph
timeElapsedGraph <- u="">ggplot
(testplanclean, aes(nbuserlabel,elapsed/1000,color=X1))
timeElapsedGraph + geom_boxplot() + labs(y="Temps de r�ponse (s)",x="Utilisateurs simultan�s")+ scale_x_discrete(labels=c(timeElapsedGraph$nbuser))

# Time elapsed per Filter
timeElapsedPerFilterGraph <- u="">ggplot
(testplanclean, aes(X3,elapsed/1000))
timeElapsedPerFilterGraph + stat_boxplot() + labs(y="Temps de r�ponse (s)",x="Type de filtre")

# Time elapsed per aircraft
timeElapsedPerAircraftGraph <- u="">ggplot
(testplanclean, aes(X2,elapsed/1000))
timeElapsedPerAircraftGraph + stat_boxplot() + labs(y="Temps de r�ponse (s)",x="Aircraft")

# Time elapsed  type of graph
timeElapsedGraph <- u="">ggplot
(testplanclean, aes(X1,elapsed/1000))
timeElapsedGraph + geom_boxplot() + labs(y="Temps de r�ponse (s)",x="Type of Graph")


hist(testplanclean$timeStamp/60000)

aggregate(x=testplan$responseCode,by=list(testplan$label,testplan$responseCode),FUN='length')


intensiteChart<- u="">ggplot
(intensite,aes(Group.1,x))+theme(axis.text.x=element_blank(),  axis.ticks.x=element_blank())
intensiteChart+geom_point()+geom_smooth(method="lm",color="Red")+labs(y="Request per minutes",x="Stress of the scenario")
intensite

Package pour traiter les dates
install.packages('lubridate')
library(lubridate)
access_log$Date<-dmy_hms access_log="" span="">


vendredi 23 février 2018

Migrate Liferay 6 to Liferay 7 on MySQL


1- Do a copy of the backup

Modify the portal-ext.properties


redirect.url.security.mode=ip
redirect.url.domains.allowed=localhost,workcouncil.infosys.com
redirect.url.ips.allowed=127.0.0.1,privateIp,PublicIp,SERVER_IP

Resolve to your virtual host in etc/host


Modify the config of osgi
 vi osgi/configs/com.liferay.portal.workflow.kaleo.runtime.internal.notification.EmailNotificationSender.cfg

fromAddress=someone@yahoo.fr

2 - Change collation on columns
ALTER TABLE AssetCategory             CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE AssetEntry                CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE AssetVocabulary           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE BlogsEntry                CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE BookmarksEntry            CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE BookmarksFolder           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE CalEvent                  CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE Calendar                  CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE CalendarBooking           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE CalendarResource          CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DDLRecordSet              CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DDMContent                CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DDMDataProviderInstance   CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DDMStructure              CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DDMStructureVersion       CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DDMTemplate               CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DDMTemplateVersion        CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DLFileEntry               CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DLFileEntryType           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DLFileVersion             CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE DLFolder                  CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE ExportImportConfiguration CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE Group_                    CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE JournalArticle            CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE JournalFeed               CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE JournalFolder             CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE KaleoAction               CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE KaleoDefinition           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE KaleoNode                 CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE KaleoNotification         CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE KaleoTask                 CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE KaleoTimer                CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE KaleoTransition           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE Layout                    CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE LayoutBranch              CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE LayoutPrototype           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE LayoutRevision            CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE LayoutSetBranch           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE LayoutSetPrototype        CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE MBCategory                CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE MDRAction                 CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE MDRRule                   CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE MDRRuleGroup              CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE Marketplace_App           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE PasswordPolicy            CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE PollsChoice               CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE PollsQuestion             CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE QUARTZ_JOB_DETAILS        CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE QUARTZ_TRIGGERS           CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE Repository                CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE Role_                     CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE ShoppingCategory          CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE ShoppingCoupon            CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE ShoppingItem              CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE ShoppingItemField         CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE ShoppingOrderItem         CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE SyncDLObject              CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE Team                      CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE UserGroup                 CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE UserIdMapper              CONVERT TO CHARACTER SET utf8 ;
ALTER TABLE WikiNode                  CONVERT TO CHARACTER SET utf8 ;

jeudi 30 novembre 2017

Service et runlevel

Lister les service
  systemctl list-unit-files

Listing

 chkconfig --list

Changing

 chkconfig --level 345 mysqld on


Desactiver un service sur CentOs 7
 systemctl disable postfix.service

mercredi 23 août 2017

Monitoring application with a simple bash under linux



 Edit a cron file

 vi /etc/cron.hourly/monitorhttpd.sh


#!/bin/bash
ps -ef |grep `cat /var/run/httpd/httpd.pid`|grep httpd>/tmp/httpjenkinscount
NBPCS=`wc -l

if [ "$NBPCS" -eq "0" ]; then
    service httpd start
fi



#!/bin/bash
ps -ef |grep `cat /var/run/tomcat-jenkins/tomcat.pid`|grep java>/tmp/tomcatjenkinscount
NBPCS=`wc -l

if [ "$NBPCS" -eq "0" ]; then
    sudo -ujenkins -- "/local/home/jenkins/tomcat-7/bin/shutdown.sh"
    sleep 30
    rm -f /var/run/tomcat-jenkins/tomcat.pid
    sudo -ujenkins -- "/local/home/jenkins/tomcat-7/bin/startup.sh"
fi 


But you can also perform some more complex monitoring by testing call to url (end to end test)
vi ./autorestartscript.sh

#!/bin/sh
rm -f /tmp/status
wget https://myserver/myapp/status --no-check-certificate -O /tmp/status
RETOUR=$?
KOCOUNT=`cat /tmp/status|grep KO|wc -w`
if [ $KOCOUNT -ge 1 ] || [ $RETOUR -ge 1 ];
then
service tomcat6_myapp stop;
sleep 30
service tomcat6_myapp start;
service httpd_myapp restart;
fi

dimanche 23 juillet 2017

How to redirect to different AJP connector based on server name only (same context path)



When you have two domains pointing to the same IP address, how to server different page only based on the URL.

-  Setup 2 tomcat listening on AJP port 8019 and 8009

- declare two domains on you DNS page

Then modify the apache configuration as follow.



NameVirtualHost *:80
ProxyPreserveHost On

ProxyPass  /  ajp://localhost:8009/
ProxyPassReverse /  ajp://localhost:8009/
ServerName virtualserver1.mydomain.com



ServerName virtualserver2.mydomain.com
ProxyPass / ajp://localhost:8019/
ProxyPassReverse /  ajp://localhost:8019/


mercredi 24 mai 2017

Automatical periodic backup with simple bash script



Here is a very basic way to create a periodic backup of some of your folder in a LINUX environment

Create an cron file /etc/cron.montlhy/backup-tomcat

#!/bin/sh
SCOPE=monthly
tar -cvzf /mnt/nas/backup-tomcat/tomcat-`date +%Y%m%d`-$SCOPE.tgz -C/home/clement tomcat-8
find /mnt/nas/backup-tomcat/ -name \*$SCOPE\* -mtime +365 -exec rm -f {} \;