cogAdmin tool to manager an XWiki/Tomcat instance
TypeOther
Developed by

Alexandru Stancu

LicenseGNU Lesser General Public License 2.1

View Source

Description

Xinit is a bash script that can be used to manage an tomcat instance and to monitor XWiki availability. It was mainly tested and used on Debian systems but it should also run on a RedHad based OS.

Xinit is supposed to run on a server where only XWiki is running. I strongly recommend to not use it on a server where other java applications are running. At this moment xinit is not able to make a difference between an XWiki java process and other java processes running for other applications.

The main features of Xinit are:

  • Check XWiki availability
  • Check Tomcat process (java process)
  • Automatic restarts when XWiki is not responding or when java process is not running.
  • Send notifications by e-mail and jabber
  • Manage OpenOffice Daemon
  • Send reports about disk usage, database size, mysql queries, cpu and memory used for the specified daemons, java thread dumps, connections state for the specified port numbers, tomcat logs.
  • Supports Basic Authentication
  • Manage JVM settings and also able to start JVM in debug mode with remote access.
Xinit has its own configuration file. It can be found in /etc/xinit/xinit.cfg . This file contains all the parameters Xinit supports and all the features available. Please read this file before start using Xinit.

Usage

After you have installed Xinit (please see the installation section) it has two main files you need to use. One is the configuration file and another one is the script used to manage xwiki. This script can be found in /etc/init.d/xwiki.sh 

If you run xwiki.sh without any options it will print a list of all parameters it supports. Only root is able to run xwiki.sh

After doing all the configuration in xinit.cfg you can use xinit in a cron to check XWiki availability. For example the following cron configuration will check XWiki every 5 minutes and Tomcat process every minute.

*/1 * * * * /etc/init.d/xwiki.sh check-proc >/dev/null 2>&1
*/5 * * * * /etc/init.d/xwiki.sh check-http >/dev/null 2>&1

Xinit will automatically restart Tomcat in case XWiki is not responding in an amount of time or if the java process is not running. In the same time it will send email notifications to the emails addresses specified in xinit.cfg file. Also the time xinit should wait for XWiki to respond can be set in xinit.cfg .

Before start using check-proc and check-http options I strongly recommend to use test-proc and test-http options. They are doing the same thing as check options except the fact that they will not restart the wiki in case it is not responding or java process is not running. This options allows you to test the environment and see if the results are the expected ones. 

check-http

This is the most important feature of Xinit this is why I'm going to offer more information about it. So to enable this feature edit xinit.cfg file and set CHECK_HTTP="yes". You'll find a dedicated section for this feature in the configuration file.

Also in the configuration file you'll find more parameters that you can use to customize the way how Xinit is checking XWiki availability. 

The idea related to check-http feature is that Xinit is checking XWiki availability using the HTTP response code it receives after doing a request to XWiki instance.

That means you can configure Xinit to expect any of the HTTP/1.1 response code and based on the response code it receives it can decide if the wiki is responding or not in the amount of time specified in xinit.cfg.

Example: supposing you have an public wiki that can be accessed using http://xwiki.domain.tld . To configure Xinit to check the availability of that wiki do the following changes in xinit.cfg:

CHECK_HTTP="yes"
EXPECT_HTTP_RESPONSE_CODE="200"
CHECK_HTTP_URL="http://xwiki.domain.tld"
Please read xinit.cfg file for the description of the most used HTTP response codes.

After this you can run /etc/init.d/xwiki.sh test-http to see the results. If everything is ok then you can configure a cron job as specified above.

If the wiki is protected by htaccess you can set USE_BASIC_AUTH="yes" and set HTACCESS_USERNAME and HTACCESS_PASSWORD parameters in xinit.cfg to let Xinit be able bypass the basic authentication.

If the wiki page you are trying to access requires an authentication at xwiki level you can set Xinit to expect code 401. You'll receive "401 Unauthorized" response when try to access such a page. This way Xinit is still able to check XWiki availability. But make sure the 401 you received it not transmitted by the front-end (in case of htaccess).

Other important parameter is USE_DNS which by default is set to "yes". This parameter makes Xinit to not restart Tomcat in case it was not able to resolve the domain specified by the CHECK_HTTP_URL parameter. You can set it to "no" if you want to reverse the behavior.

You can also instruct Xinit how much time to wait for a response. This can be set using the following parameters:

CHECK_HTTP_TIMEOUT
CHECK_HTTP_TRIES
CHECK_HTTP_WAITRETRY

Prerequisites & Installation Instructions

Some packages must be installed before start uisng xinit. For Debian system you can just simply run

apt-get install coreutils sysvinit-utils procps sendxmpp mysql-client-5.1 bsd-mailx curl

For RedHat Based systems you can look for the equivalent packages.

After that, download the source code of xinit and run ./install.sh

Tags:
Created by Alexandru Stancu on 2012/05/29 14:56
    

Download XWiki

My Recent Modifications

Get Connected