Differences

This shows you the differences between two versions of the page.

Link to this comparison view

rb:check404 [18/02/2020 10:32] (current)
andrew created
Line 1: Line 1:
 +===== Check for 404 errors =====
 +
 +
 +<code bash>
 +#!/bin/bash
 +# Written Andrew Stringer 09-07-2014
 +# Nagios check, purpose to check for errors logged by apache.
 +
 +APP="​Your Service Name"
 +
 +STATE_OK=0
 +STATE_WARNING=1
 +STATE_CRITICAL=2
 +STATE_UNKNOWN=3
 +
 +#note, add 0 to make ERRORS404 always numeric, otherwise may be undef.
 +ERRORS404=$[`ssh -i /​home/​nagios/​.ssh/​nagios_dsa server.co.uk cat /​home/​nagios/​ssl-segment.log | grep 404 | wc -l` + 0]
 +
 +
 +if [[ ${ERRORS404} -ge 100 ]]; then
 +        echo "We have had ${ERRORS404} 404 errors in the last ten minutes on ${APP}. | 404ERRORS=${ERRORS404};​50;​100"​
 +        exit $STATE_CRITICAL
 +
 +elsif [[ ${ERRORS404} -ge 50 ]]
 +        echo "We have had ${ERRORS404} 404 errors in the last ten minutes on ${APP}. | 404ERRORS=${ERRORS404};​50;​100"​
 +        exit $STATE_WARNING
 +else
 +        echo "We have had ${ERRORS404} 404 errors in the last ten minutes on ${APP}. | 404ERRORS=${ERRORS404};​50;​100"​
 +        exit $STATE_OK
 +fi
 +
 +
 +#We should never reach this...
 +echo "An error has occurred"​
 +exit ${STATE_UNKNOWN}
 +
 +</​code>​
 +
  

rb/check404.txt ยท Last modified: 18/02/2020 10:32 by andrew