- Notifications
You must be signed in to change notification settings - Fork25
JulienPalard/logtop
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
apt install logtopxbps-install -S logtopCompile dependencies:libncursesw5-dev,uthash-dev.
So on a Debian:
$ sudo apt install libncursesw5-dev uthash-devReading package lists... Done[...skippedfor readability...]Processing triggersfor man-db (2.8.2-1) ...$ makegcc -c -O3 -DVERSION=0.7.0 -Wall -fPIC -Wextra -ansi -pedantic -Wstrict-prototypes -I. src/avl.c -o src/avl.o[...skippedfor readability...]$ make install
logtop displays a real-time count of strings received from stdin.It can be useful in 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
Dependencies:python-dev,swig.
$ sudo apt install python-dev swigReading package lists... Done[...]$ make python-module[...]$ python setup.py install
I use a hashtable to store strings and an AVL tree to store frequencies,so I can fetch by string or fetch ordered by frequency to display thetop-strings.
Logtop can be used by your C programs, you may to compile againstlogtop's sources (src/{avl.c,history.c,logtop.c,libavl/avl.c}) oragainstliblogtop, obtained usingmake liblogtop.
C API is described inlogtop.h, you need:
structlogtop*new_logtop(size_thistory_size);voiddelete_logtop(structlogtop*this);voidlogtop_feed(structlogtop*this,char*line);structlogtop_state*logtop_get(structlogtop*this,size_tqte);doublelogtop_timespan(structlogtop*this);unsignedintlogtop_qte_of_elements(structlogtop*this);
You can find an example of using the C API inexamples/example1.c.
logtop module exposes a logtop class containing:
logtop.__init__(history_size)# to build a new logtop keeping# at most history_size lines.logtop.feed(line)# to feed a new line in logtop.logtop.get(qte_of_elements)# to get the top qte_of_elements lines.logtop.qte_of_elements()# to get the current total number of lines.logtop.timespan()# to get the duration from the oldest line to now.
timespan may be less than the runtime, as logtop drop old lines,to keep, at most,history_size lines, given in the constructor ofthe logtop class.
The libavl used here is the Ben Pfaff's one, statically build with logtop, asBen want it to be (see INSTALL file and here:http://lists.debian.org/debian-devel/2001/07/msg01303.html)So this libavl is NOT packaged as a library for Debian, the libavl you'llfound in Debian repositories is the Wessel Dankers's one.
For copyright information, please see the file COPYRIGHT in thisdirectory or in the files of the source tree.
This project was initiated on 2010-06-29 by Palard JulienSeehttp://julien.palard.fr or ask me questions at :julien at palard dot fr.
About
Display real time statistics of whatever you want.
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.