Difference between revisions of "Errornotify"

From James Dooley's Wiki
Jump to: navigation, search
(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`" ...")
 
(Overview)
Line 1: Line 1:
 
==Overview==
 
==Overview==
 
A simple script I wrote to email me a summery of apache error messages in the last 24 hours.
 
A simple script I wrote to email me a summery of apache error messages in the last 24 hours.
 +
 +
Cuts out uniq data such as IP addresses and unique_ids for modsec.
  
 
==Script==
 
==Script==

Revision as of 13:30, 15 April 2011

Overview

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

Cuts out uniq data such as IP addresses and unique_ids for modsec.

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