Giter Site home page Giter Site logo

tenox7 / ttyplot Goto Github PK

View Code? Open in Web Editor NEW
948.0 16.0 42.0 430 KB

a realtime plotting utility for terminal/console with data input from stdin

License: Apache License 2.0

C 65.64% Makefile 1.58% Roff 17.61% Shell 3.75% Python 11.42%
plot stdin pipe pipeline chart graph realtime snmp sar ping

ttyplot's Issues

Ping example on mac

The ping example does not seem to work on mac terminal. Is it something related to buffered output ? also sed on mac does not have the option of -u .

Thanks in advance..

Add colors

add option for coloring charts, eg closer to max = more red

also potentially axes, labels, etc to have different colors

default line and reverse line could also have configurable colors

[master] Fails to compile with error: cannot find -lcurses: No such file or directory

# make
cc -Wall -Wextra    ttyplot.c  -lcurses -ltinfo -o ttyplot
/usr/lib/gcc/x86_64-pc-linux-gnu/11/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lcurses: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [<builtin>: ttyplot] Error 1

# pkg-config --libs ncurses
-lncurses -ltinfo
  ^

Pull request upcoming...

static ttyplot-amd64-linux aborts with error "Error opening terminal: xterm-256color."

ttyplot-amd64-linux aborts with "Error opening terminal: xterm-256color."

The system has xterm-256color only at /usr/lib/terminfo/x/xterm-256color (Lubuntu install).

A strings /usr/local/bin/ttyplot | grep terminfo shows that the static binary expects it to be at /etc/terminfo:/lib/terminfo:/usr/share/terminfo or ~/.terminfo.

Workaround is to copy it to one of these locations.

Proposed fix: Please add usr/lib/terminfo to the path where ncurses looks for the terminal definition.

question

hi, deb packages are not longer hosted here?

Regards,

better SIGWINCH handler

on modern systems resizeterm() should be called in sigwinch handler instead of endwin() && refresh()

on some systems getmaxyx doesn't work correctly, use TIOCGWINSZ instead see how old svr4 vi does it (ex_v.c)

Possibility of Arm64 build?

Seeing if it would be possible for a Arm64 debian package for support of smaller computers such as the RPI.

Running into:

$ sudo dpkg -i ttyplot_1.4-1.deb 
dpkg: error processing archive ttyplot_1.4-1.deb (--install):
 package architecture (amd64) does not match system (arm64)
Errors were encountered while processing:
 ttyplot_1.4-1.deb

Thanks!

License and Makefile

I so love this project and already pointed half a dozen friends to it. (I own a command-line tool for R called littler which can work as a filter; I also pointed John Kerl of mlr fame to it.)

Two things are missing, both pretty trivial:

  • you should a license; I am personally happy with GPL (>= 2), other like MIT/BSD style or Apache but not having anything is actually prohibiting use
  • maybe add a two-line Makefile? I know about -lcurses but then I am also one of those guys

Release 1.0 has no Makefile

I see the repo has a Makefile, but you may need to update with a new release, like 1.1, to include the Makefile.

-e arg isn't working in Homebrew version (but works fine when compiled from source)

Hey, first: amazing work on this tool! I'm using it to visualize memory pressure over time on my Mac.

v1.4 from Homebrew seems to have a problem with the -e option -- e.g. this will fail (just prints the helptext and then pauses for 1 second, then exits):

while [0]; do memory_pressure | awk 'END {print $5/1}'; sleep 1; done | ttyplot -e+ -cx -m100 -t%free_mem -u%

but, cloning master and compiling with make outputs a version where the exact same command works fine (also says 1.4 but obviously something's different).

macOS 10.15.5

Any idea?

Feature request: work with limited data

All uses cases where I would like to use ttyplot are with "limited" input. As it stands, ttyplot quits immediately on stdin EOF.

One simple solution that works is to replace the break statement in the if(r<0) codepath with a sleep(10); continue;.

I can open a PR, if this is desirable.

Program immediately quits

On macOS 12.5.1, plotting from stdin does not work:

 echo "1 2 3 4 5" | ttyplot

immediately exits. With longer input, one can see the plot flashing by, before the program quits and nothing is left.

option -e and -s/-m

It seems the options does not work properly. please correct me if i am wrong.

  • If the option -e is used there is only the Usage output so the preferred exceed character doesn't work.
  • If the option -m is used the -s option seems to be ignored. The graph limit at start is the given -m input. From my understanding the -s should be the first limit for the graph. If this is exceeded the last limit is the -m limit and the -e character is used to visualise this exception.

The tested version is compiled from today's source. 1.4

PS: despite that a cool piece of software ;)

poor man line drawin

for these old systems have define to compile with poor's man line drawing -|<>^L etc

Coinbase API Example is deprecated ...

Hi and thanks for this useful tool!

I noticed the the following example is not working anymore
{ while true; do curl -sL https://coinbase.com/api/v1/prices/historical | head -1 | cut -d, -f2 ; sleep 600; done } | ttyplot -t "bitcoin price" -u usd

I had a quick glance over the current API (https://developers.coinbase.com/api/v2) and it seems there are no "historical" prices anymore (actually, i could not find "historical" within the old api (https://developers.coinbase.com/api/v1).

Greetings,

Chris

Support negative values

This would be great to plot temperature, or other values that typically sometimes go negative.

non gawk examples

give examples with cut, (paste?), perl, python, etc in addition to bash

[1.5.1] Minimum window size assumptions can be violated?

Hi!

From a user point of view, resizing ttyplot's window to small sizes and back can get ttyplot into a broken state, e.g. see video below.

From a code point of view, there are multiple places where a certain minimum size is assumed…

  • plotheight=height-4;
  • (width/2)-14
  • (width/2)-(strlen(title)/2)

…but not checked for. So the assumptions can be violated in practice, e.g. during a resize.

python-prompt-toolkit addresses this problem by displaying something like "window too small" whenever that's the case (and the window is big enough for that text still). I think that would be great to have here for robustness, too.

What do you think?

PS: This may or may not be related to #77.

recording-2023-03-14_04.42.01.mp4

floats not working

float input still renders int lines, scales drawn correctly with decimal points

[master] "make deb" is broken

# make deb
mkdir -p ttyplot_1.4-1/usr/local/bin
cp ttyplot ttyplot_1.4-1/usr/local/bin
dpkg-deb --build ttyplot_1.4-1
dpkg-deb: error: failed to open package info file 'ttyplot_1.4-1/DEBIAN/control' for reading: No such file or directory

feature request: set minimum

Option to set vertical axis minimum.

Currently, the minimum on the vertical axis is 0. If the value plotted fluctuates around a high value, a lot of the resolution of the fluctuations is lost due to most of the graph representing the baseline.

This is a proposal to have a command-line parameter to set the minimum of the vertical scale (similar to the maximum value, I suppose)

Plans for a post-1.4 release off Git master?

Hi @tenox7,

thanks for sharing ttyplot as Software Libre! 👍 I noticed that there are 90+ commits on master since release 1.4 and that Debian-based distros have packaged post-1.4 Git snapshots:

XXXX

To my understanding both indicate, that there is lack for a more recent release.
Are there any plans to cut a release 1.5+ off master? I'm considering packaging ttyplot for Gentoo, and that would be a great match.

Thanks and best, Sebastian

Please add options softmin and hardmin

During real-life use, it turns out that having minimum options would be convenient. Could they be added?

For something exceeding the max and min values, I propose to have a full bar with some marker for max and not drawing anything at all for min, to distinguish them.

ttyplot does not read data

So while the examples work, the command output I want to plot doesn't. I have a line such as

find  minicrane-scans/mrs/2020/11/02/ -name "*.pcd" | sort | xargs ./bin/pcl_icp | grep Yaw --line-buffered | cut -d" " -f 2

which runs and continuously outputs to stdout

-0
-0.000116325
-0.000274716
-0.000444506
-0.000536768
-0.000640014
-0.000762741
-0.000762741
-0.000997292
-0.00122629
-0.00153955
-0.00172964
-0.00172996
-0.00172996
-0.00180447
-0.00180986
...

However, piping this to ttyplot only shows waiting for data from stdin .

Support for libncurses6

ttyplot needs libncurses5 and libtinfo5 to be installed. I am running Lubuntu 19.04, which already uses libncurses6 and libtinfo6, so ttyplotthrows errors:

ttyplot: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

After trying to fix by running
sudo ln -s /usr/lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
sudo ln -s /usr/lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5,

ttyplot is still not happy:

ttyplot: /lib/x86_64-linux-gnu/libtinfo.so.5: version NCURSES_TINFO_5.0.19991023' not found (required by ttyplot) ttyplot: /lib/x86_64-linux-gnu/libncurses.so.5: version NCURSES_5.0.19991023' not found (required by ttyplot)

Could the binary ttyplot version for linux (ttyplot-amd64-linux) please support the ncurses6 libraries as well? It should be enough to just compile it on a ncurses/tinfo6 system.

It was easy to compile ttyplot after installation of libncurses-dev and libtinfo-dev, but since you supply all these binaries, it would be very comfortable to have out-of-the-box support as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.