Need a script to search in the logs

. 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
ratnaprasad123Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ozoConnect With a Mentor Commented:
awk '{if( !t[$5]|| t[$5] < $1 ){ t[$5] = $1; s[$5]=$3 }}END{ for( i in s){ print i,"-",s[i]; }}' *.log
0
 
omarfaridCommented:
can you provide sample logs?
0
 
ratnaprasad123Author Commented:
Attaching the code here
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
ratnaprasad123Author Commented:
Attaching the log file
connection-ipdp01-0-63.log
0
 
ratnaprasad123Author Commented:
Hi Do you need any more info let me know.
0
 
ozoCommented:
Do you want the IP address from the LOCL, REM, or ID column?
0
 
ratnaprasad123Author Commented:
take it as LOCL
Thanks,
0
 
ozoCommented:
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
 
ratnaprasad123Author Commented:
Do you have any other way than perl......Sorry  i am little weak in perl
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.