• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

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
0
ratnaprasad123
Asked:
ratnaprasad123
  • 5
  • 3
1 Solution
 
omarfaridCommented:
can you provide sample logs?
0
 
ratnaprasad123Author Commented:
Attaching the code here
0
 
ratnaprasad123Author Commented:
Attaching the log file
connection-ipdp01-0-63.log
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
ozoCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now