Created
July 13, 2012 16:46
-
-
Save philcryer/3105918 to your computer and use it in GitHub Desktop.
Finds 50x errors in Varnishncsa logs and writes daily reports for later analysis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Desc: Finds 50x errors in Varnishncsa logs and writes daily reports for later analysis | |
# Tags: varnish, varnishlog, varnishncsa, varnishncsa logs, 500 errors, error reports, logs | |
TODAY_GREP=`date +%d/%b/%Y` | |
TODAY=`date +%Y%m%d` | |
REPORT_DIR="/tmp/varnish-500-report" | |
REPORT_FILE="${REPORT_DIR}/${TODAY}" | |
VARNISHNCSA_LOG="/var/log/varnish/varnishncsa.log" | |
if [ ! -f "${VARNISHNCSA_LOG}" ]; then | |
echo "FAILED: Varnishncsa log not found, is varnishncsa running?"; exit 1 | |
fi | |
if [ ! -d "${REPORT_DIR}" ]; then | |
mkdir ${REPORT_DIR} | |
fi | |
cat ${VARNISHNCSA_LOG} ${VARNISHNCSA_LOG}.[0-9] | grep "\" 50[0-9] " | grep "\[${TODAY_GREP}\:" > ${REPORT_FILE}.tmp | |
COUNT=`cat ${REPORT_FILE}.tmp | wc -l` | |
mv ${REPORT_FILE}.tmp ${REPORT_FILE}_${COUNT}.txt | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment