OpenCraft
Follow OC!
  • Home
  • About
  • Solutions
  • Portfolio
  • Clients
  • Blog
  • Contact

Run webinject (nagios plugin) for drupal projects

Tue, 2008-08-12 15:59
Tags:
  • coding
  • drupal
  • nagios
By: 
Ahmed Mowafy

First we will define webinject and nagios.

WebInject: Webinject is a free tool for automated testing of web applications and web services. It can be used to test individual system components that have HTTP interfaces (JSP, ASP, CGI, PHP, AJAX, Servlets, HTML Forms, XML/SOAP Web Services, REST, etc), and can be used as a test harness to create a suite of [HTTP level] automated functional, acceptance, and regression tests. A test harness allows you to run many test cases and collect/report your results. WebInject offers real-time results display and may also be used for monitoring system response times.
WebInject can be used as a complete test framework that is controlled by the WebInject User Interface (GUI). Optionally, it can be used as a standalone test runner (text/console application) which can be integrated and called from other test frameworks or applications more.

Nagios: Nagios is an open source host, service, and network monitoring program. It is very popular and used by many big companies and organizations for enterprise monitoring. Nagios was originally designed to run under Linux, but should run on other Unix variants as well. Nagios is a very powerful, very flexible monitoring solution, with many plugins available to do almost anything, and with a large number of options for notification and service monitoring. Nagios is based on a central server that runs external commands or plugins to test distributed hosts and services more.

What is the aim for using webinject as a plugin in nagios for our drupal projects?
The aim for using webinject is to check that our deployment projects is down or not then login to the site and checks that all services are running ok in status report page.

Configure webinject
First you must install WebInject and the necessary Perl modules on your Nagios server.
Then you have to modify the config.xml and add this line in it to enable the Nagios plugin mode:

<reporttype>nagios</reporttype>

Now you would setup a test case file:

<testcases repeat="1">
   <case
       id="1"
       method="get"
       description1="Check site"
       url="/user/login"
       verifyresponsecode="200"
       errormessage="Site is down"
   />

First case is to check the site.

<case
      id="2"
      method="post"
      description1="Login to site"
      url="/user/login"
      verifyresponsecode="302"
      errormessage="Can't loging to the site"
  />

Second case is to login to the site.

  <case
      id="3"
      description1="Check status page"
      type="table"
      tablename="system-status-report"
      method="get"
      description1="Check status page"
      url="/admin/logs/status"
      verifynegative='\<tr class="error'
      verifyresponsecode="200"
  />
 
 </testcases>

Third case is to check status report table in /admin/logs/status page.
We make a patch in webinject.pl file to look in the status report table by giving the 'type' argument the html tag that we are searching for (that is in our case is table) and in 'tablename' we put the class of the table. 'verifynegative' argument is string in response for negative verification. The case fails if this string exists in the HTTP response, and in this case we are search for any 'tr' with class error in the table.We also add in the patch 'verifywarning' argument that is return WARNING case to nagios if this string exists in the HTTP response.

As we see in 'url' argument base url not defined because in the patch we define base url in the execution command line also the admin user name and password for the site, this can be done by launching:

./webinject.pl -c config.xml testcasefile.xml <a href="http://www.mysitename.com" title="http://www.mysitename.com">http://www.mysitename.com</a> username password

If anyone interested in webinject plugin the patch file for version 1.41 will be in the attached file.

AttachmentSize
webinject.patch14.36 KB
  • amowafy's blog

Comments

by anonymous (not verified) | Wed, 2009-07-08 13:44

thanks

I am interested with this 'testing tool'. It seems that achieving your desired application with the chances of checking it for mistakes beforehand saves up time and lessens stress. This is good.

Our work

PricewaterhouseCoopers

PricewaterhouseCoopers needed a dynamic Web portal to manage the...

Reuters Intranet

Reuters Business Direct team approached OpenCraft to propose an...

View our complete portfolio

Related posts

  • Beware PHP $_REQUEST!
  • Coloring 1pixelout flash player in audio module
  • Apache MultiViews automatically appends file extensions
  • How to associate default users with projects in 'Case Tracker' module?
  • Enabling clean URLs for Drupal on a clean Ubuntu

More posts by this author

  • How to associate default users with projects in 'Case Tracker' module?

OpenCraft

  • About
  • Team
  • Process
  • Community
  • Media Kit
  • Portfolio
  • Clients
  • Industries
    • Social economic development
    • Multimedia culture
  • Services
    • Drupal development
    • Information architecture
    • Open source software development
    • Social network engineering
  • Request quote
  • Contact
  • Search
Blog

Our profiles at:

Drupal Google
rss

Creative Commons License
search