Softpanorama

Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
May the source be with you, but remember the KISS principle ;-)
Skepticism and critical thinking is not panacea, but can help to understand the world better

Logs Related Tips

News Enterprise Logs  Infrastructure

Recommended Links

Syslog Http logs analyzers logger utility

This is a collection of one-liners I have found useful. 

One frequent problem with logs is truncation.

This problem often arise with wtmpx

The easiest form of truncation would be

cat /dev/null/ > target.log

or just

:>target.log

 


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

Note: Most tips were borrowed from ktmatu - One-liners by Matti Tukiainen. Some are modified. We assume that the web server log files (access_log*) are in Combined Format.

LogTools 0.1.0 Released

December 13, 2011
I finally managed to do the initial public release of LogTools, a set of useful utilities for log data processing. Their current most important feature is the initial version of LogStore, a tamper-proof way to store textual log data especially designed for long-term archival. Note that LogTools perfectly process syslog messages, but can be used for anything that is text-based (like Apache or other application text logs).

I am very happy to finally have the initial release ready. Full details can be found in the release announcement. I initially thought it would become available early last week, but I wanted to create some packages. As I had never done this before, it turned out to become a bit of a problem for me. For the time being, I have settled to do an experimental Debian package via checkinstall. While this is obviously a quick and dirty solution, it enables folks to obtain LogTools via the easy way. Also, I don't think it is too problematic, because in essence only some user-tools are installed that do not affect anything else on the system. But, of course, I'll think about better packaging as the project continues.

At this point, I would be very interested in feedback both on the current tools as well on what would be considered a plus in the future. Please let me know!

How to view log files without line wrapping ?

Less has option -S or --chop-long-lines Causes lines longer than the screen width to be chopped rather than folded. That is, the portion of a long line that does not fit in the screen width is not shown. The default is to fold long lines; that is, display the remainder on the next line.
less -S access_log

How many lines (hits) there are in the log file?

grep 200 access_log | wc -l 

How many page views?

gzip -dc access_log.gz | egrep -vc '(\.gif |\.jpg |\.png )' 
2569

How many hits today?

grep -c `date '+%d/%b/%Y'` access_log
2569

How many unique visitors today?

grep `date '+%d/%b/%Y'` access_log | cut -d" " -f1 | sort -u | wc -l 
1196

How many hits in a particular day?

What period is covered covered in the log?

Are there missing dates?

How many corrupted log entries?

This is just a very quick and dirty way to check the log.

How does the line number 15927 or lines 15920 - 15929 look like?

How to figure out the bandwith consumption (in bytes)?



How to delete partial GET requests from the log?

Partial content requests are usually generated by download managers to speed the downloading of big files and Adobe Acrobat Reader to fetch PDF documents page by page. In this example 206 requests generated by Acrobat reader are deleted so that they don't infate the hit count.

grep -v '\.pdf .* 206 ' access_log > new_log

How to compress a selected portion from a log?

See in real-time how the log file grows?

Recommended Links

Web site logging and log management

CGI Scripts



Etc

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright 1996-2018 by Dr. Nikolai Bezroukov. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) in the author free time and without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: January 09, 2020