Crates.io | lpl |
lib.rs | lpl |
version | 0.1.0 |
source | src |
created_at | 2024-01-07 11:04:52.438596 |
updated_at | 2024-01-07 11:04:52.438596 |
description | A command-line utility to plot charts from line-based inputs. |
homepage | |
repository | https://github.com/SOF3/lpl |
max_upload_size | |
id | 1091699 |
size | 151,871 |
A command-line utility to plot charts from line-based inputs.
A few simple use cases using Bash:
Linux exposes the device thermometers under /sys/class/thermal.
For example, on my laptop:
$ cat /sys/class/thermal/*/temp
47000
20000
39050
45000
47050
40000
47000
Therefore, we can pass each file as a separate --csv-poll
argument to lpl
:
$ lpl $(
> for file in /sys/class/thermal/*/temp; do
> echo "--csv-poll $(basename $(dirname $file))=$file"
> done
> )
When performing a rolling update
with a Kubernetes Deployment,
it scales down the old ReplicaSet and scales up the new ReplicaSet gradually.
We can monitor this progress by watching the ReplicaSet replica count
using <()
process substitution with kubectl get --watch
and some transformation with jq
:
lpl --json <(kubectl get replicaset --watch -ojson | \
jq --unbuffered -c '{
(.metadata.name + " total"): .status.replicas,
(.metadata.name + " ready"): .status.readyReplicas,
}')
Currently lpl
only supports JSONLines,
so make sure to pass -c
to print one JSON object per line.
Also use --unbuffered
to ensure jq
can emit new events immediately.
JSON comes in two modes — streaming and polling.
Streaming JSON is specified by --json PATH
,
where PATH
is a special file (typically from <()
process substitution)
that reads one JSON object per line.
A JSON object may contain arbitrary fields,
but only top-level fields with a single numeric value are processed,
where the numeric value is added to the time series
named with the corresponding key,
at the time the line is read.
Pipe your input to | jq -c --unbuffered .
if it was not already one line per object.
Polling JSON, on the other hand, is a (usually regular) file
that contains a single JSON object (either compact or formatted),
specified by --json-poll PATH
.
Similar to streaming JSON,
only top-level fields with a single numeric value are processed.
The file is reloaded when it is chnaged (where supported by inotify),
or every --poll-period
seconds.
Similar to JSON, CSV also supports streaming and polling modes
through --csv PATH
and --csv-poll [HEADER=]PATH
.
CSV files are separated with ,
by default,
but this may be customized with --csv-poll-delimiter
.
If the argument contains =
,
the part before =
is treated as the CSV header.
Otherwise, the first line read from PATH
(initial first line for streaming, first line from every reload for polling)
is treated as the CSV header.
Only numeric values that can be parsed as f64
are processed;
other values are silently ignored.
For polling mode, if there are multiple files in a single poll,
only the first numeric value is processed.
lpl
provides an interactive TUI to browse the data plot.
Type ?
for help.
Type q
to quit.
Download development builds:
Windows: x86_64 (64-bit), aarch64 (ARM 64-bit), i686 (Intel/AMD 32-bit)
Linux: