Solved

Need a script to search in the logs

Posted on 2009-04-13
11
257 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

809 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