Howto: Tail Lighttpd Logs with Style using Sed

Posted 1011 days ago - Development, Security

Although extremely useful, http server access logs are a mess in their raw form. If you're interested in watching your http server logs in real time with formatting rules and pretty colors, this post is for you.

Teh Scr1pt

Create a new file to put the l33t code into:

rewt@bawnx ~# vim /usr/local/bin/httptail

Add this mess:

#!/bin/sh
GREENY=`echo -en '\e[32m'`
YELLOW=`echo -en '\e[93m'`
RESET=`echo -en '\e[00m'`
tail -f httpd_access.log |sed -e "s/^.*\]: //g;s/ www.somedomain.*\] \"/ \"/g;s/ HTTP\/.* \"/\" /g;s/\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)/$GREENY\1$RESET/g;s/\(\"[^\"]*\"\)/$YELLOW\1$RESET/g"

Stuff You Need to Change:

  • The access log filename
  • www.somedomain - if you're not sure what goes here ...

Now, save the file and make it executable.

rewt@bawnx ~# chmod +x /usr/local/bin/httptail

Run it and enjoy the show:

rewt@bawnx ~# httptail
...........

Real Time Lighttpd Access Log Watching

Word Count: 227

Tags: , , , , , ,

Click Here to Submit a Comment

Permalink / Last Modified:

Support Nullamatix.com:

See Also:

  • 04/11/2010 -- Howto: XCache in a Lighttpd Chroot on Debian
    Excerpt: "Whether you're pressed for resources on a virtual/dedicated server, or simply looking for ways to improve web application performance, XCache is guaranteed to produce the desired result. Within minutes of installing XCache: page load times were cut in half, ..."
  • 04/24/2009 -- New Page: Interesting Server Logs
    Excerpt: "This is a short post. A status update more than anything. Before posting Madlib Site PHP code examples demonstrating how to use the content you've obtained from: Free Data Sources for Blue Hat SEO's Madlib Technique, I thought of a potentially interesting ..."
  • 12/10/2009 -- 529 Attacks in 9 Days: id1.txt, RFI, & More
    Excerpt: "Long time Nullamatix readers know how much I love reviewing log files. Logs can provide detailed incite into not only the overall health of a system, but information one can use to mitigate the risks of automated attacks. In this post, I'll go over a couple ..."
  • 02/11/2008 -- Howto: Setup cron Jobs to Restart Lighttpd & MySQL
    Excerpt: "Over the past couple weeks MySQL crashed when spiked with large amounts of traffic. To remedy this, a cron job has been implemented to simply restart mysql and lighttpd every other day. Here's how it's done. First, if you haven't already, define a cron job ..."

Leave a Reply