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 {} \;

jeudi 6 avril 2017

Simplify RDP






Having longer session on windows Server 2008