LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-25-2010, 04:13 PM   #1
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Blog Entries: 1

Rep: Reputation: 72
Question Configuring Conky to read log file entries - apache + fail2ban


So I'm trying to get conky to output the last 3 different IP's that requested pages from my web server;

It all sounds rather simple doesn't it?

Well; if I used the tail command built into conky it appears I have no control over redirecting the output (at least I can't find anything to show me how to, and I've tried a few different ways)

In the end I came up with the idea of simply grepping the log file for the lines I wanted, sorting them to get only unique IP entries and then tailing the file to get the number of required lines (In my case I want 3 lines from both logs).

I've ended up with :

Code:
TEXT
${exec grep GET /var/log/apache2/access_log | awk '{print $1, $4"]",$7}' | sort -un | tail -n 3 }
$hr
${exec grep WARNING /var/log/fail2ban.log | tail -n 3 | awk '{print $2,$6,$7}'}
The code for the fail2ban works perfectly; as the IP only appears once when its banned, once when its unbanned so I didn't feel I needed to filter the information out any more than this. However the Apache log doesn't work nearly as well.

Depending if I use the -n option to sort the IPs I either get the same IP coming up 3 times (which is the last IP to access the server, but it will have requested /, /favicon.ico and other random pages also - I just want to know they hit the site, and the first thing they requested (normally just / )

I've learnt a lot so far but now it's getting late and I can't really see where to turn with this any more.

Code:
71.**.***.** - - [25/Apr/2010:21:44:57 +0100] "GET /images/tim.jpg HTTP/1.1" 200 20957
88.**.***.*** - - [25/Apr/2010:21:50:19 +0100] "GET / HTTP/1.1" 200 3386
88.**.***.*** - - [25/Apr/2010:21:50:19 +0100] "GET /default.css HTTP/1.1" 200 269
88.**.***.*** - - [25/Apr/2010:21:50:20 +0100] "GET /favicon.ico HTTP/1.1" 404 271
67.**.**.*** - - [25/Apr/2010:21:52:23 +0100] "GET /robots.txt HTTP/1.1" 404 271
If this is what appears in teh access_log, then I should just get 3 lines:

Code:
71.**.***.** - [25/Apr/2010:21:44:57] - /images/tim.jpg
88.**.***.*** - [25/Apr/2010:21:50:19] - / 
67.**.**.*** - [25/Apr/2010:21:52:23] - /robots.txt
HELP!
 
Old 04-26-2010, 04:29 AM   #2
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343

Original Poster
Blog Entries: 1

Rep: Reputation: 72
Infact I've given up with this as it seems to be using quite alot of resources for not much output - I might code something into my website on a simular theme so if anyone does want to help with the filtering then please do, but I'll mark this solved for now.
 
  


Reply



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
Strange log entries in apache log under debian... hacking tentative ? strelok Linux - Security 4 11-11-2009 06:55 AM
How to read the content of a file with conky Adso Linux - Newbie 5 05-17-2009 09:33 AM
anon svn read-only over apache: '.svn/entries': No such file hedpe Linux - Software 2 04-29-2009 05:31 AM
Apache log file - logging entries late kirtimaan_bkn Linux - Newbie 1 12-10-2006 05:28 PM
apache error log entries synaptical Linux - Security 3 01-26-2004 01:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 05:41 PM.

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
Open Source Consulting | Domain Registration