Solved

Need a script to search in the logs

Posted on 2009-04-13
11
260 Views
Last Modified: 2013-12-26
. Search in the logs for the IP.Adresses
2. if found take the 'connected' or ' disconnected' status
3. create output <IP- Adress> - <status>
Take care that the script is searcing in all logs available when it is started the first time, because only connection status changes only written in this logs.
The following time the script should take the new logs and the last information written by the script to create new status update.
The script should be stated via crontab each 5 minutes
0
Comment
Question by:ratnaprasad123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
11 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 24135075
can you provide sample logs?
0
 

Author Comment

by:ratnaprasad123
ID: 24135110
Attaching the code here
0
 

Author Comment

by:ratnaprasad123
ID: 24135124
Attaching the log file
connection-ipdp01-0-63.log
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:ratnaprasad123
ID: 24135252
Hi Do you need any more info let me know.
0
 
LVL 84

Expert Comment

by:ozo
ID: 24135279
Do you want the IP address from the LOCL, REM, or ID column?
0
 

Author Comment

by:ratnaprasad123
ID: 24135350
take it as LOCL
Thanks,
0
 
LVL 84

Expert Comment

by:ozo
ID: 24135455
perl -ane '$i{$F[4]}=[@F[0,2]] unless $i{$F[4]} && $i{$F[4]}[0] gt $F[0]; END{print "$_ - $i{$_}[1]\n" for keys %i}' *.log
0
 

Author Comment

by:ratnaprasad123
ID: 24135509
Do you have any other way than perl......Sorry  i am little weak in perl
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 24135618
awk '{if( !t[$5]|| t[$5] < $1 ){ t[$5] = $1; s[$5]=$3 }}END{ for( i in s){ print i,"-",s[i]; }}' *.log
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question