Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrading documentation and manpage.

Version is now 0.2.
  • Loading branch information...
commit d7ac287638cd86615b4724d80874f86309101422 1 parent 430fa92
Julien Palard authored
Showing with 118 additions and 43 deletions.
  1. +68 −2 CHANGELOG
  2. +13 −24 README
  3. +21 −6 doc/logtop.1
  4. +16 −11 src/logtop.c
View
70 CHANGELOG
@@ -1,4 +1,70 @@
-commit 8049a047c00ecce2d0883364d01f7900d46dadbe
+commit 430fa9273f1ea88379cff466a84ae926822bd8b7
+Author: Julien Palard <julien@eeple.fr>
+Date: Sun May 20 21:25:57 2012 +0200
+
+ Prit usage if stdin is a TTY.
+
+commit 4db20d36ad795940dfe94b4f4ef21de146e4cc3d
+Author: Julien Palard <julien@eeple.fr>
+Date: Sun May 20 21:22:16 2012 +0200
+
+ Renaming without_curses in quiet.
+
+ That's more expressive in the actual context.
+
+commit d77459913595a83e5f91ecd1137e8ff6118bec98
+Author: Julien Palard <julien@eeple.fr>
+Date: Sun May 20 21:09:23 2012 +0200
+
+ NEW: Line by line reporting.
+
+ Line by line reporting is for programs that want to parse logtop
+ output, a report is printed, entierly in one line, once per second, in
+ a machine friendly format.
+
+ Option parsing has been rewritted using getopt_long, and a new option
+ has appeard : --interval, permitting to change the default interface
+ update interval, for line-by-line and for curses.
+
+commit 18785a8ba180a4b8337ee2aec5c4e076d59330a1
+Author: Julien Palard <julien@eeple.fr>
+Date: Sun May 20 19:40:49 2012 +0200
+
+ NEW: -q option to disable curses
+
+ As the top 10 is print at exit, updating in real time with curses
+ become optional.
+
+commit 60f61bd32a137f3dd27c8069ae020f03a9426d20
+Author: Julien Palard <julien@eeple.fr>
+Date: Sun May 20 19:28:11 2012 +0200
+
+ Enhancing ccurses view.
+
+ Handling SIGWINCH, permitting resize or terminals.
+ Only repaint what was actually modified at each repaint.
+
+commit c2ec00a3c070abd306a4a8332055994f07fa2259
+Author: Julien Palard <julien@eeple.fr>
+Date: Sun May 20 17:56:02 2012 +0200
+
+ Code uniformisation and -Wstrict-prototypes
+
+commit 6198e912c23f5f93b14895204edd3dcebc66de9f
+Author: Julien Palard <julien@eeple.fr>
+Date: Sun May 20 17:51:38 2012 +0200
+
+ NEW: Only print the top 10 elements at exit.
+
+ Also print the top 10 elements when SIGINT is catched.
+
+commit ff777e8ebae0f304e6e4e227ebfddd9b9181f241
+Author: Julien Palard <julien@eeple.fr>
+Date: Sun May 20 16:33:48 2012 +0200
+
+ NEW: Handling SIGINT.
+
+commit 66aea8dba65b34ab5a552b2b1e163df35fd869d8
Author: Julien <github@mandark.fr>
Date: Tue May 31 18:43:43 2011 +0200
@@ -213,7 +279,7 @@ Author: Julien <github@mandark.fr>
Date: Sat Nov 13 21:45:03 2010 +0100
Improving a bit the UI adding the number of log lines read by second ...
-
+
On my box, a
$ strings /dev/urandom | ./logtop -s 100000
gaves me :
View
37 README
@@ -5,36 +5,28 @@ This project was initiated on 2010-06-29 by Palard Julien
See http://julien.palard.fr or ask me questions at :
julien at palard in fr
-Compile :
+Compile dependencies :
You will need :
+ Package: libncurses5-dev
+ Version: 5.7+20100313-1
$ aptitude install libncurses5-dev uthash-dev
+ Then, to compile just type :
+ $ make
+
Run :
You will need :
$ aptitude install libncurses5
+ $ ./logtop
Usage :
logtop displays real-time count of strings recieved in standard input.
- I's useful for some cases, like :
- tail -f /var/log/apache2/access.log \
- | sed -u -r 's/^([^ ]+) ([^ ]+) ([^ ]+) \[([^]]+)] "([^ ]+) ([^"]+) HTTP\/([^"]+)" ([^ ]+) ([^ ]+) "([^"]+)" "([^"]+)"$/\6/g' \
- | logtop
- to show the top pages requested on your apache
- I'd put parenthesis everywhere to allow you to switch the selection :
- 1: ip
- 2: date
- 5: method
- 6: url
- 7: version
- 8: status
- 9: length
- 10: referer
- 11: useragent
-)
-
-Compile (Dependencies) :
- Package: libncurses5-dev
- Version: 5.7+20100313-1
+ I's useful for some cases, like getting the IP flooding your server :
+ $ tail -f /var/log/apache2/access.log | cut -d' ' -f1 | logtop
+
+ Or the top buzzing article of your blog :
+ $ tail -f /var/log/apache2/access.log | cut -d' ' -f7 | grep article | logtop
+
Development :
I use a hashtable to store strings and an AVL tree to store frequencies,
@@ -47,6 +39,3 @@ About libavl:
http://lists.debian.org/debian-devel/2001/07/msg01303.html)
So this libavl is NOT packaged as a library for Debian, the libavl you'll
found in Debian repositories is the Wessel Dankers's one.
-
-TODO :
- Better integration with curses (resize...)
View
27 doc/logtop.1
@@ -9,10 +9,9 @@ logtop \- Realtime log line rate analyser
.SH "SYNOPSIS"
.B logtop
.RI [ OPTIONS ]
-.RI [ FILE ]
.SH "DESCRIPTION"
- \fBlogtop\fP is a System Administrator tool to analyze line rate taking log
- file as input. It reads on stdin and print a constantly updated result
+ \fBlogtop\fP is a System Administrator tool analyzing line rate on stdin.
+ It reads on stdin and print a constantly updated result
displaying, in columns:
Line number, count, frequency, and the actual line.
@@ -23,7 +22,22 @@ logtop \- Realtime log line rate analyser
.SH "OPTIONS"
.TP
.B \-s, \-\-size=K
-Set \fBlogtop\fP to work with the maximum of K lines instead of 10000
+Only keep K lines in memory, instead of 10000.
+.TP
+.B \-q, \-\-quiet
+Do not display a live view of the data, only display a top at exit.
+.TP
+.B \-l, \-\-line-by-line=K
+Print result line by line, in a machine friendly format, K is the
+number of result to print per line.
+
+ Line by line format is : [%d %f %s\\t]*\\n
+ %d : Number of occurences
+ %f : Frequency of apparition
+ %s : String (Control chars replaced by dots.
+.TP
+.B \-i, \-\-interval=K
+Interval between graphical updates, in seconds. Defaults to 1.
.TP
.B \-h, \-\-help
Show summary of options.
@@ -42,13 +56,14 @@ Realtime hit / miss ratio on some caching software log file.
.PP
\fBtail \-f access.log | cut \-d' ' \-f1 | logtop \-s 10000\fR
.PP
-Realtime most querying IPs on your server, as long as log lines in access.log starts with the client IP.
+Realtime most querying IPs on your server, as long as log lines in access.log
+starts with the client IP.
.PP
\fBtail \-f access.log | cut \-d' ' \-f7 | logtop \-s 10000\fR
.PP
Realtime most requested web pages in a NCSA like log file.
.PP
-\fBcat auth.log | grep \-v "CRON" | grep \-o ": .*" | logtop \-s 100000\fR
+\fBcat auth.log | grep \-v "CRON" | grep \-o ": .*" | logtop \-q \-s 100000\fR
.PP
Display a one\-shot simple analyse of your auth.log.
.SH "SEE ALSO"
View
27 src/logtop.c
@@ -103,9 +103,7 @@ static void usage_and_exit(int exit_code)
" Defaults to : "
STRINGIFY(DEFAULT_HISTORY_SIZE) "\n"
" -q, --quiet Quiet, only display a top 10 at exit.\n"
- " -l, --line-by-line=NUM Do not use curses,"
- " do not print a top 10 at exit.\n"
- " Display a line by line report\n"
+ " -l, --line-by-line=NUM Print result line by line\n"
" in a machine friendly format,\n"
" NUM: quantity of result by line.\n");
fprintf(exit_code == EXIT_SUCCESS ? stdout : stderr,
@@ -122,7 +120,7 @@ static void usage_and_exit(int exit_code)
static void version_and_exit(void)
{
- fprintf(stdout, "logtop v0.12\n");
+ fprintf(stdout, "logtop v0.2\n");
exit(EXIT_SUCCESS);
}
@@ -179,14 +177,24 @@ static void parse_args(int ac, char **av)
gl_env.history_size = DEFAULT_HISTORY_SIZE;
}
-static void on_sigint(int sig)
+static void at_exit(void)
{
if (!gl_env.quiet && !gl_env.line_by_line)
+ {
curses_release();
- setup_sighandler(SIGINT, 0, NULL);
- if (!gl_env.line_by_line)
+ puts("Curses release");
+ }
+ if (gl_env.line_by_line)
+ stdout_update(gl_env.line_by_line, 1);
+ else
stdout_update(10, 0);
fflush(NULL);
+}
+
+static void on_sigint(int sig)
+{
+ setup_sighandler(SIGINT, 0, NULL);
+ at_exit();
kill(getpid(), sig);
}
@@ -199,9 +207,6 @@ int main(int ac, char **av)
if (!gl_env.quiet && !gl_env.line_by_line)
curses_setup();
run();
- if (!gl_env.quiet && !gl_env.line_by_line)
- curses_release();
- if (!gl_env.line_by_line)
- stdout_update(10, 0);
+ at_exit();
return EXIT_SUCCESS;
}

0 comments on commit d7ac287

Please sign in to comment.
Something went wrong with that request. Please try again.