Errornotify

From James Dooley's Wiki
Revision as of 13:29, 15 April 2011 by 10.30.6.195 (talk) (Created page with "==Overview== A simple script I wrote to email me a summery of apache error messages in the last 24 hours. ==Script== <code>[bash,n]#!/bin/bash grep "`date | cut -d " " -f2,3`" ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

A simple script I wrote to email me a summery of apache error messages in the last 24 hours.

Script

[bash,n]#!/bin/bash grep "`date | cut -d " " -f2,3`" /usr/local/apache/logs/error_log | grep -v "ModSec" | cut -d "]" -f2- | sort | uniq -c | sort -nr > unformatted.txt grep "`date | cut -d " " -f2,3`" /usr/local/apache/logs/error_log | grep "ModSec" | cut -d "]" -f2- | sort | cut -d "]" -f1,3- | rev | cut -d "[" -f2- | rev | sort | uniq -c | sort -nr > modsec.txt


echo -e "Daily Apache Error report for server1.infusedsites.com \n\n\n" > email.txt

echo -e "\n\n====Error Messages====\n" >> email.txt grep "\[error\]" unformatted.txt >> email.txt

echo -e "\n\n====Warnings====\n" >> email.txt grep "\[warn\]" unformatted.txt >> email.txt

echo -e "\n\n====Notice====\n" >> email.txt grep "\[notice\]" unformatted.txt >> email.txt


echo -e "\n\n====ModSec====\n" >> email.txt cat modsec.txt >> email.txt

cat email.txt | mail -s "Daily Apache Error Log Report" james@jamesdooley.us

rm -f modsec.txt unformatted.txt email.txt

What to change