Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Shell script for continuously monitoring log file


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Shell script for continuously monitoring log file

Hi
I have written below log monitoring script to egrep multiple words and redirect the output to a text file and its working fine but I want to add some more below given functionality to it, which is very advance and im not very good in it, so please help if you can Smilie
  1. I am egrepping all the error codes, so I want rather than egrepping all error codes, I should grep for HTTP/1.1 200 which is successful code and which ever line does not have this redirects output to output file.
  2. ignore any line which has /akamai/sureroute
  3. right now I am using cron to run this script every 5 min, so my script will send the same error again and again, so I want the script not to send the same error more than 3 times. (based on the time stamp).
  4. for e.g. if server goes down I do not want 1000's error messages, so if there are more than 100 error messages, script should send only 1 mail.
=====================================

Code:
find /home/bharat/ -type f -name "apache_logs.txt" |while read file
  do
    RESULT=$(egrep "[^0](400|401|403|404|405|406|407|408|409|410|411|412|413|414|415|416|417|418|422|425|426|428|429|431|451|500|501|502|503|504|505|511)" $file)
      if [[ ! -z $RESULT ]]
         then
            echo "Error(s) in $file on $HOSTNAME at "$(date)": $RESULT">> email_result.txt
     fi
  done


Last edited by rbatte1; 4 Weeks Ago at 09:24 AM..
# 2  
I think best for you to attempt to modify your script with your new requirements and try to code yourself first, before asking others to do your work for you.

This is always better than posting some a script and then asking others to change it for you to meet your new requirements.

Thanks.
This User Gave Thanks to Neo For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Monitoring script for Log file
vij05
Hi, Iam new to unix , plz help me to write below script. I need to write a script for Monitoring log file when any error occurs it has to send a mail to specified users and it should be always pick latest error not the existing one and the script should be able to send mail all errors (more...... UNIX for Beginners Questions & Answers
1
UNIX for Beginners Questions & Answers
Shell Script for continuously checking status of a another script running in background, and immedia
ketanraut
Hi, I want to write a script which continuously checking status of a script running in background by nohup command. And if same script is not running then immediately start the script...please help.. i am using below command to run script nohup system_traps.sh & but in some...... Shell Programming and Scripting
9
Shell Programming and Scripting
Shell Script for monitoring File system.
vjauhari
Hi, need help to write one shell script to monitor UNIX file systems and if any changes happend like deletion of any file, adding new file, time stamp changed, permisson changed etc. Script need to send alert mail to defined person/mail id. I request someone to help me to create the...... Shell Programming and Scripting
1
Shell Programming and Scripting
Parsing log file continuously
rchaitanya
Hi i have a log file, which keeps appending, i want to find "exceptions" in that log file and copy those exceptions to another file. i am using grep exception filename >> location where to copy but as the file is appending, am not able to view. i am using tail -f command , ...... UNIX for Dummies Questions & Answers
5
UNIX for Dummies Questions & Answers
Shell Script to continuously scan a log file
novice82
Hello members, I have some doubts on how to write a script that can reports success / failure of a batch job ? 1. Run a batch job: 2. Wait and search for a particular string in the Log file: tail -f log01*.txt | egrep -v "^SUCCESSFUL" echo "continue with the other tasks" ...... Shell Programming and Scripting
1
Shell Programming and Scripting

Featured Tech Videos