#!/bin/ksh ############################################################################### # # Name: check_maxq.ksh # # Author: Robert Towster # # Description: Check website with MAXQ # # Dependencies: maxq from http://maxq.tigris.org/ # # Arguments: TESTNAME # # Returns: 0 - success # 1 - warning # 2 - critical # ############################################################################### # # MODIFICATION HISTORY: # # Date User ID /or Name Description # ---- ----------------- ----------- # 20120306 Robert Towster Script created # ############################################################################### # # INSTRUCTIONS: # # Step 1: install maxq # Step 2: modify this script "MAXQDIR" and "TESTFILEDIR" to match the proper paths # # USAGE: # # Step 1: run maxq to record web session based upon maxq documentation. # (this will start the proxy) $MAXQDIR/bin/maxq -p 8090 -d # Step 2: (optional) Modify saved session to look for specific data in the response # Step 3: setup nagios to run this script with name of the saved session # # # # Notes for modification of saved session to generate error if text is missing. # Within the session file you have to add a line to error if certain data not present # Syntax is below: # # self.assertEquals("Assert number 2 failed", 200, self.getResponseCode()) # (add the line below to debug output. It will print full response) # self.printResponse() # (add the line below to fail if certain text not present) # self.assertTrue(self.responseContains("Login success")) # Validator.validateResponse(self, self.getMethod(), url, params) # # ############################################################################### # GLOBAL VARIABLES ############################################################################### MAXQDIR=/opt/nagiosplugins/maxq-1.0.3 TESTFILEDIR=$MAXQDIR TESTNAME=$1 ############################################################################### # Usage Check ############################################################################### if [ $# -lt 1 ]; then echo "No TESTNAME supplied!" exit 2 fi ############################################################################### # execute test ############################################################################### /usr/bin/time -f "%e" -o /tmp/time.$$ $MAXQDIR/bin/maxq -r $TESTFILEDIR/$TESTNAME > /dev/null 2> /dev/null XIT=$? ELAPSED=`tail -1 /tmp/time.$$` rm -f /tmp/time.$$ ############################################################################### # Format Outputs ############################################################################### MSG="$TESTNAME response" PERFMSG="response=$ELAPSED;;;; exit=$XIT;;;;" ############################################################################### # Return Results ############################################################################### if [ $XIT -gt 0 ]; then echo "CRITICAL: $MSG |$PERFMSG" exit 2 else echo "OK: $MSG |$PERFMSG" fi exit 0