Install check_centreon_waa and selenium

Introduction

This howto describes the installation of Centreon Web Application Analytics plugin. This plugin monitor your web application availability running by a scenario. To write a scenario, the plugin uses Selenium IDE to be installed in Firefox browser.

How it work ?

  • Nagios run check_centreon_waa plugin with the parameter a scenario
  • check_centreon_waa connect to Selenium server.
  • Selenium server use a X server (Xvfb), start Firefox and run the scenario

Prerequistes

Add EPEL repository :

# rpm -ivh http://mirror.chpc.utah.edu/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Last versions used is check_centreon_waa-1.0.3.tar.gz and selenium-server-standalone-2.31.0.jar. Perhaps, there are new updates.

Run commands :

# yum install -y firefox xorg-x11-server-Xvfb xorg-x11-xauth java-1.6.0-openjdk perl-Test-WWW-Selenium perl-XML-XPath
# cd /usr/src
# wget http://forge.centreon.com/attachments/download/1524/check_centreon_waa-1.0.3.tar.gz
# wget http://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar

Disable EPEL Repository, edit /etc/yum.repos.d/epel.repo file

[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

Install Files

# cd /usr/src
# tar xzf check_centreon_waa-1.0.3.tar.gz
# cd check_centreon_waa-1.0.3
# cp extras/centos/init-xvfb /etc/init.d/xvfb
# chmod +x /etc/init.d/xvfb
# chkconfig --add xvfb
# cp extras/centos/init-selenium /etc/init.d/selenium
# chmod +x /etc/init.d/selenium
# chkconfig --add selenium
# cp extras/centos/default-xvfb /etc/default/xvfb
# cp extras/centos/default-selenium /etc/default/selenium
# cp check_centreon_waa /usr/lib/nagios/plugins/
# chmod +x /usr/lib/nagios/plugins/check_centreon_waa
# mkdir -p /var/lib/centreon_waa

 

Post install

XVFB

Modify /etc/default/xvfb file :

RUN_AT_STARTUP="YES"
FBDIR="/usr/local/labkey/"

Create directory :

# mkdir -p /usr/local/labkey/

Start xvfb :

# /etc/init.d/xvfb start

Selenium

# mkdir /opt/selenium
# mv /usr/src/selenium-server-standalone-2.31.0.jar /opt/selenium
# cd /opt/selenium
# ln -s  selenium-server-standalone-2.31.0.jar selenium-server-standalone.jar

Modify /etc/default/selenium file :

# Configuration for /etc/init.d/selenium

# If run selenium at startup default: NO
RUN_AT_STARTUP="YES"

# Path to selenium JAR
SELENIUM_LIB="/opt/selenium"

# Selenium port default: 4444
SELENIUM_PORT=4444

# Selenium user default: selenium
SELENIUM_USER="selenium"

# Selenium log dir default: /var/log/selenium
SELENIUM_LOGDIR="/var/log/selenium"

# The firefox profile directory for use in selenium. Run "firefox -ProfileManager" to create a new profile and custom it.
# Example SELENIUM_FFPROFILE=/var/run/selenium/.mozilla/firefox/XXXXXX.selenium
SELENIUM_FFPROFILE=""

# X display port default: :99
X_DISPLAY=":99"

Add user :

# useradd -s /bin/false -d /var/run/selenium -m selenium
# mkdir -p /var/log/selenium
# chown selenium:selenium /var/log/selenium

Patch  /etc/init.d/selenium (line 32) :

su -s /bin/bash - ${SELENIUM_USER} -c "DISPLAY=${X_DISPLAY} nohup ${JAVA_BIN} -jar ${SELENIUM_LIB}/selenium-server-standalone.jar -port ${SELENIUM_PORT} ${PROFILE_FIREFOX} >${SELENIUM_LOGDIR}/selenium.log 2>${SELENIUM_LOGDIR}/selenium_err.log & echo $! >${PIDFILE}"

Start selenium :

# /etc/init.d/selenium start

 

Setting FireFox

Connect by ssh to FAN server and enabled X11 forwarding

On your computer, run

$ ssh -X root@FANSERVER

Run firefox :

# firefox -ProfileManager
  • Click on “Create Profile” and Next

  • Enter a profile name : selenium
  • Choose folder : /opt/selenium

  • Click on Finish
  • Start Firefox

 

Install Selenium IDE

Go to http://seleniumhq.org/download

Download the latest version (1.10.0 released) and allow the installation in firefox

Restart firefox

 

Run Selenium IDE :

Create a test (scenario web)

An example, our test have several steps :

  • Connect to http://www.fullyautomatednagios.org
  • Verify text or word is present
  • Go an another page “Documentation”

Run the Selenium IDE and http://www.fullyautomatednagios.org in Base URL :

Start the recording :

 

In firefox, go to http://www.fullyautomatednagios.org

Select “Home” word

Right clic and select “verifyTextPresent Home”

 

In the IDE window, you can see the changes

 

In the banner, clic on “Documentation”

 

Stop the recording :

Play the test :

 

Selenium play the test :

Check the result :

 

Save the test in the directory “/var/lib/centreon_waa” : webtest-FAN.html

 

Nagios config files

Create a new command check :

define command{
    command_name    check_centreon_waa
    command_line    $USER1$/check_centreon_waa -c $ARG2$ -w $ARG3$ -d /var/lib/centreon_waa/ -t $ARG1$ -r localhost:4444
}

Create a new service :

define service{
    host_name                CheckScenarioWeb
    service_description      ScenarioWeb_FAN
    use                      generic-service
    check_command            check_centreon_waa!webtest-FAN!30!20
}

 

 

No comments yet.


six + = 7

 
No trackbacks yet.