Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-13-2009, 06:51 AM   #1
Registered: Jan 2008
Posts: 34

Rep: Reputation: 15
Arrow Script to Monitor Different IP's in the Live Logs

Dear All,

Basically I need a shell script to monitor different IP's in the live logs.

The problem is I am new to shell scripting and dont know much about the scripting.

Look at the below line, the pattern will be always like this:

[2009-02-13 15:34:53,768] DEBUG - Start! PaymentGatewayFactory - getPaymentGateway (2, 100.00,Mohit Aggarwal,1942, 1,, , 9821934958)

I want to extract the different IP's from this line every time when this kind of line adds to the logs.

Once the IP's are extracted and moved to another file, I want to compare them with previously existing IP's instantly and if the count of any particular IP will be more than predefined Value that IP should be Displayed on the Screen.

Hope you got, what is the problem ?

Please do help me in this matter.....

Thanks and regards,

Akhtar Bhat.
Old 02-13-2009, 08:58 AM   #2
Registered: Sep 2007
Location: Las Vegas, NV
Distribution: Fedora / CentOS
Posts: 674
Blog Entries: 3

Rep: Reputation: 90
This will extract the lines you're interested in from log_file:
tail -f log_file | sed 's/.*getPaymentGateway.*,\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/' > ip_log_file

You an then check out the counts of each IP with something like this:
sort ip_log_file | uniq -c | sort -r

Last edited by JulianTosh; 02-13-2009 at 08:59 AM. Reason: incorrect tail parameter


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
Script to monitor Different IP's in the live logs akhtar.bhat Linux - Software 1 02-02-2009 07:53 PM
iptables bash script to add offending ip's to temporary chain NinjaGuru Programming 1 01-08-2008 11:05 AM
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 05:19 AM
Bandwidth Monitor (That keeps logs) JDawg06 Linux - Desktop 17 09-07-2006 10:12 PM
A live log monitor script ? ifm Linux - Software 1 07-19-2002 03:54 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:15 AM.

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