Checking Drupal Status with Nagios and WebInject

Summary

A few weeks back I found a post on the Drupal forums about monitoring the status report page with Nagios and Webinject.  Having lots of practice with Nagios and Webinject, I knew this was possible but noone had provided an example.  So I finally got around to creating the Webinject script today and posted it.  Below is the complete process including the Nagios info I used.

 

Webinect XML Script

<testcases repeat="1">
<testvar varname="BASE_URL">http://www.domain.com/</testvar>
<testvar varname="LOGIN1">username</testvar>
<testvar varname="PASSWD1">password</testvar>
<case
id="1"
description1="Connecting to Login Page"
method="get"
url="${BASE_URL}?q=user"
verifypositive="Enter the password that accompanies your username"
errormessage="Unable to load login page"
/>
<case
id="2"
description1="Authentication"
method="post"
url="${BASE_URL}?q=user"
postbody="name=${LOGIN1}&pass=${PASSWD1}&form_id=user_login&op=Log+in"
verifypositive="${BASE_URL}\?q=users/${LOGIN1}"
errormessage="Login Post Problem"
/>
<case
id="3"
description1="Status Report Page"
method="get"
url="${BASE_URL}?q=admin/reports/status"
verifynegative="Out of date"
verifypositive="Drupal core update status"
errormessage="Status Page Alert!"
/>
</testcases>

Nagios Command File Entry

define command {
  command_name webinject
command_line /usr/local/nagios/webinject/webinject.pl -c nagios/$ARG1$ nagios/$ARG2$
}

Nagios Check Entry

define service {
  use template1
  host_name server
  service_description  status-report
  check_command webinject!nagios.xml!drupal_status.xml
}

Thoughts

The webinject script looks for something that is "Out of date" on the Status Report and will alert appropriately based on your Nagios configuration. The first step is not necessarily required, but it helps in troubleshooting if the login page for the site is not loading correctly and preventing the check from executing correctly.