LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-17-2009, 10:49 PM   #1
yah0m
Member
 
Registered: Jul 2008
Posts: 38

Rep: Reputation: 15
How do I loop this for monitoring?


files="`cat /usr/local/apache/domlogs/domain.com | grep '"-" "-"' | awk {'print $1'}`"
for f in $files; do
csf -d $f
done

I know I want to use tail -f but not sure how.
 
Old 03-18-2009, 04:07 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by yah0m View Post
files="`cat /usr/local/apache/domlogs/domain.com | grep '"-" "-"' | awk {'print $1'}`"
for f in $files; do
csf -d $f
done

I know I want to use tail -f but not sure how.
What is csf ?

Anyway, to monitor:
Code:
watch "cat /usr/local/apache/domlogs/domain.com | grep '\"-\" \"-\"' | awk {'print $1'}"
Note: escape the double quotes inside the grep command with a backslash.

BTW cat-ing into grep is not necessary, as grep can read from a file itself:
Code:
watch "grep '\"-\" \"-\"' /usr/local/apache/domlogs/domain.com | awk {'print $1'}"
Also, if you're already using awk, you might as well skip the grep too, leaving just one awk-command to do the job:
Code:
watch "awk '/\"-\" \"-\"/ {print $1}' /usr/local/apache/domlogs/domain.com"
BTW It would be very well possible also to do it with only one sed command instead of awk.

Last edited by Hko; 03-18-2009 at 04:08 PM.
 
Old 03-19-2009, 02:41 PM   #3
yah0m
Member
 
Registered: Jul 2008
Posts: 38

Original Poster
Rep: Reputation: 15
Thanks.

As for what CSF is, that's the firewall. I'm pulling the IPs from the access_logs to block a GET Flood.
 
Old 03-19-2009, 05:11 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110
Ah. Then my watch solution probasbly doesnt help..
Sorry for misreading your post.
 
  


Reply


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
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 9 07-28-2015 04:49 PM
bash loop within a loop for mysql ops br8kwall Programming 10 04-30-2008 04:50 AM
Monitoring free memory with enterprise monitoring application Steelb Linux - Enterprise 2 02-13-2008 11:10 AM
converting shell while loop to for loop farkus888 Programming 8 09-12-2007 03:30 AM
for loop only works properly on first loop symo0009 Programming 1 12-25-2005 06:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:20 AM.

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