Welcome to docs.opsview.com

Using Selenium with Opsview

Selenium is a suite of tools to automate web application testing. This makes it ideal for performing in-depth web site monitoring from Opsview.

This article describes how to configure Selenium so that you can perform automated testing from your Opsview system.


These instructions cover how to install Selenium on Opsview systems running Debian or Ubuntu Linux.

We recommend that you install Selenium on at least one of your Opsview Slave servers in order to perform checks. We recommend that you do not install selenium on a stand alone Opsview Master server.

Selenium will place an additional load on your Opsview Slave server. We recommend that you dedicate the following recources to Selenium monitoring:

Server ResourceQuantity
Memory1 GB
CPU1x core

We recommend that you analyse CPU and Memory utilisation before installation in order to assess impact.


Note: All commands specified in this document should be run with system 'root' user privileges unless otherwise stated

The following packages are required in order to run Selenium:

  • Xserver - X Windows Server
  • Xvfb - X11 virtual framebuffer
  • X Windows Fonts
  • Firefox web browser

X Server Installation

To install you should run the following command

apt-get install xserver-xorg xserver-xorg-core xauth xvfb xfonts-100dpi xfonts-75dpi

Browser Installation

Ubuntu Systems

Install Firefox

apt-get install firefox 

Debian Systems

Mozilla firefox is rebranded 'Iceweasel' in Debian distributions.

Install Iceweasel

apt-get install iceweasel 

Configuring Xvfb

We want xvfb to be running all the time, so that we can run selenium tests whenever we please.

To do this, we create an init.d script:


# Thanks to Dan Straw
# http://www.danstraw.com/

XVFBARGS=":99 -nolisten tcp -fbdir /var/run"
case "$1" in
        echo -n "Starting virtual X frame buffer: Xvfb"
        start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
        echo "."
        echo -n "Stopping virtual X frame buffer: Xvfb"
        start-stop-daemon --stop --quiet --pidfile $PIDFILE
        echo "."
        $0 stop
        $0 start
        echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
        exit 1

exit 0

Use 'update-rc.d' to install System-V style init script links:

cd /etc/init.d
update-rc.d xvfb defaults

Start The Xvfb daemon:

/etc/init.d/xvfb start 

Selenium Configuration

Create directories required by Selenium:

mkdir /usr/lib/selenium /var/log/selenium

Download the Selenium code:

cd /usr/lib/selenium
wget -c http://selenium.googlecode.com/files/selenium-java-2.0b3.jar -O selenium-server.jar

We want Selenium to be running all the time. To do this, we create an init script:


# Thanks to Dan Straw
# http://www.danstraw.com/

case "${1:-''}" in
    if test -f /tmp/selenium.pid
        echo "Selenium is already running."
        env DISPLAY=:99 /usr/bin/java -jar /usr/lib/selenium/selenium-server.jar -port 4444 > /var/log/selenium/selenium-output.log 2> /var/log/selenium/selenium-error.log & echo $! > /tmp/selenium.pid
        echo "Starting Selenium..."

        if test $error -gt 0
            echo "${bon}Error $error! Couldn't start Selenium!${boff}"
    if test -f /tmp/selenium.pid
        echo "Stopping Selenium..."
        PID=`cat /tmp/selenium.pid`
        kill -3 $PID
        if kill -9 $PID ;
               sleep 2
               test -f /tmp/selenium.pid && rm -f /tmp/selenium.pid
                echo "Selenium could not be stopped..."
                echo "Selenium is not running."
    if test -f /tmp/selenium.pid
        kill -HUP `cat /tmp/selenium.pid`
        test -f /tmp/selenium.pid && rm -f /tmp/selenium.pid
        sleep 1
        env DISPLAY=:99 /usr/bin/java -jar /usr/lib/selenium/selenium-server.jar -port 4444 > /var/log/selenium/selenium-output.log 2> /var/log/selenium/selenium-error.log & echo $! > /tmp/selenium.pid
        echo "Reload Selenium..."
        echo "Selenium isn't running..."
    *)      # no parameter specified
        echo "Usage: $SELF start|stop|restart|reload|force-reload|status"
        exit 1

Use 'update-rc.d' to install System-V style init script links:

cd /etc/init.d
update-rc.d selenium defaults

Start the Selenium daemon:

/etc/init.d/selenium start 

Installing the Selenium Plugin

If the 'check_selenium' plugin does not already exist on your Opsview system you must follow these steps:

Install Plugin

Open a console connection to your Opsview Master server and run the following commands:

Check out plugin from Subversion repository

cd /tmp
svn co https://secure.opsera.com/svn/opsview/trunk/opsview-core/nagios-plugins

Copy check_selenium to Opsview's plugin directory

cp /tmp/check_selenium /usr/local/nagios/libexec
chmod 755 /usr/local/nagios/libexec/check_seleium
chown nagios:nagios /usr/local/nagios/libexec/check_seleium

Distribute Plugin to Slave Servers

As the 'nagios' user run these commands:

cd /usr/local/nagios
bin/send2slaves -p

Reload Opsview

From the Opsview UI initiate a reload: Server → Status and Reload

Creating a Selenium Test Case

Install Selenium IDE

You must install the Selenium IDE as a Firefox Plugin. The Selenium website has good instructions on how to do this:

Update: Selenium IDE can no longer export Perl “out of the box”, so we must install this script here:

Create a Test Case

  1. Follow these instructions to create a test case:
  2. Export the test case in 'Perl' format using the “Export Test Case As…” Option

Install Test Case on your Opsview Server

* Copy the test case to /usr/local/nagios/etc on your Opsview Slave server

Configure Opsview

  • Create a Service Check referencing the check_selenium plugin
  • Create a Host Template referencing the Service Check
  • Associate the Host Template to a Host on your Opsview system
  • Reload your Opsview system

Debugging the check

In order to debug problems via the Linux command shell:

  1. Establish a console connection to your Opsview server
  2. As the 'nagios' user run the following command:
  /usr/local/nagios/libexec/check_selenium -f /usr/local/nagios/etc/<name-of-test-case>.pl

The plugin should give you a result similar to:

SELENIUM OK - All tests passed. total_tests=17, failed_tests=0, ok_tests=17 | total_tests=17;; failed_tests=0;; time=22.340717 seconds;;


For a more detailed explanation on installing Selenium Server on Debian see:

Also for more infomation on Running Selenium tests on Debian headlessly using Iceweasel and Firefox see: