LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-05-2004, 07:55 PM   #1
dough29
LQ Newbie
 
Registered: Nov 2004
Posts: 2

Rep: Reputation: 0
Events on Log analyse


Hello ! I'm French so sorry if my English isn't the best.

I would like to have a shell script making events analysing my logs in /var/log/

For example, by running tail -f /var/log/apache/access.log - I would like, for each GET requests, to run a command like /usr/bin/beep to make simple.

Thank you in advance !!
 
Old 11-07-2004, 02:00 PM   #2
mgatny
Member
 
Registered: Mar 2004
Posts: 41

Rep: Reputation: 15
Save the follow shell script as beep.sh, then run:
chmod +x beep.sh

Then run:
tail -f /var/log/apache/access.log | beep.sh GET

The argument to beep.sh is the string you want to match on. So if you wanted to look for HEAD requests instead of GET, run it like this:
tail -f /var/log/apache/access.log | beep.sh HEAD

Or for a particular IP address:
tail -f /var/log/apache/access.log | beep.sh "192.168.0.123"

... You get the idea. Also, your English is quite good

Code:
 #!/bin/sh

while [ 1 ]; do
        read foo;
        echo $foo | grep "$1" > /dev/null 2>&1
        if [ $? -eq 0 ]; then
                /usr/bin/beep
        fi
done

Last edited by mgatny; 11-07-2004 at 02:02 PM.
 
Old 11-07-2004, 02:20 PM   #3
dough29
LQ Newbie
 
Registered: Nov 2004
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks a lot !

It works verry fine.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help analyse grub types.h ewt3y Programming 1 08-14-2005 05:43 PM
is there any tool to analyse a core dump? jundu88 Programming 1 04-14-2005 03:04 PM
logfile analyse saavik Linux - Networking 4 03-30-2005 06:14 AM
Can anyone analyse this message? Fraxis Linux - Software 6 01-02-2002 07:36 PM
want help to analyse networking in kernel cybercop12us Programming 1 10-24-2001 04:15 PM


All times are GMT -5. The time now is 09:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration