termplot 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +13 -9
- data/doc/MSFT.png +0 -0
- data/lib/termplot/producers/command_producer.rb +7 -1
- data/lib/termplot/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af619edab0c7e963e4c03ba538d48ade05230afe5ef6e1572d39beffc4c56840
|
4
|
+
data.tar.gz: 1b138486f66e7db0423d27ffb25656486579cdf918d05d5744a24a14c42f7525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4550da91464682e063918b5655e27f14fcebae4d17905c6bb7584eed545030fa4212e43ce32d659cd53b10795aa1c8ffded70bdde53eca5400413b6aa65702d8
|
7
|
+
data.tar.gz: e41b6eae186fb4ce0dc69a2fb2851b96addc211f7304512ea6139d9588dc2e305ba9dcb382d96389ebe1783d865719ee6bdfa54619a2b1fa9dd772bc70fc6aed
|
data/README.md
CHANGED
@@ -56,10 +56,12 @@ Usage: termplot [OPTIONS]
|
|
56
56
|
|
57
57
|
-h, --help Display this help message
|
58
58
|
```
|
59
|
+
Note: Make sure to wrap your command in single quotes when using `--command` if
|
60
|
+
you use shell variables (e.g. `$1`) in your command.
|
59
61
|
|
60
62
|
## Examples
|
61
63
|
|
62
|
-
Sine wave
|
64
|
+
#### Sine wave
|
63
65
|
|
64
66
|
```
|
65
67
|
for i in $(seq 500); do \
|
@@ -69,20 +71,22 @@ for i in $(seq 500); do \
|
|
69
71
|
```
|
70
72
|

|
71
73
|
|
72
|
-
|
74
|
+
#### Memory usage (%)
|
73
75
|
```
|
74
|
-
termplot --command
|
76
|
+
termplot --command 'free | awk "NR==2 { print ($3/$2) * 100 }"' \
|
75
77
|
-t "Memory (% used)" --color light_magenta --line-style heavy-line
|
76
78
|
```
|
77
79
|

|
78
80
|
|
79
|
-
|
81
|
+
#### Real time stock ticker
|
82
|
+
|
83
|
+
(Using [ticker.sh](https://github.com/pstadler/ticker.sh)) 😉:
|
84
|
+
|
80
85
|
```
|
81
|
-
termplot --command
|
82
|
-
-t "
|
86
|
+
termplot --command 'NO_COLOR=1 ticker.sh MSFT | awk "{ print $2 }"' \
|
87
|
+
--interval 10000 -t "MSFT" --color light_green
|
83
88
|
```
|
84
|
-

|
86
90
|
|
87
91
|
## Notes
|
88
92
|
|
@@ -107,7 +111,7 @@ ruby.
|
|
107
111
|
Now with termplot, it's as easy as:
|
108
112
|
|
109
113
|
```
|
110
|
-
termplot --command
|
114
|
+
termplot --command 'ss -s | head -n1 | cut -d" " -f2' --interval 500 -t "TCP Connections"
|
111
115
|
```
|
112
116
|
|
113
117
|

|
data/doc/MSFT.png
ADDED
Binary file
|
@@ -2,8 +2,9 @@ module Termplot
|
|
2
2
|
module Producers
|
3
3
|
class CommandProducer < BaseProducer
|
4
4
|
def run
|
5
|
+
command = sanitize_command("/bin/bash -c '#{options.command}'")
|
5
6
|
loop do
|
6
|
-
n =
|
7
|
+
n = `#{command}`
|
7
8
|
# TODO: Error handling...
|
8
9
|
|
9
10
|
if numeric?(n)
|
@@ -15,6 +16,11 @@ module Termplot
|
|
15
16
|
sleep(options.interval / 1000.0)
|
16
17
|
end
|
17
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def sanitize_command(command)
|
22
|
+
command.gsub(/\$/, '\\$')
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
end
|
data/lib/termplot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: termplot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Nyaga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-termios
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- bin/console
|
41
41
|
- bin/setup
|
42
42
|
- bin/termplot
|
43
|
+
- doc/MSFT.png
|
43
44
|
- doc/cpu.png
|
44
45
|
- doc/demo.cast
|
45
46
|
- doc/memory.png
|