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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e44e30011841535366e60fe122b1a1975614d2907db4b99fc5e78538ffc1cc8d
4
- data.tar.gz: b63812a1a1823e0126eec29b14072ac6a7ee4b95f52a02977ea5e35432e2a905
3
+ metadata.gz: af619edab0c7e963e4c03ba538d48ade05230afe5ef6e1572d39beffc4c56840
4
+ data.tar.gz: 1b138486f66e7db0423d27ffb25656486579cdf918d05d5744a24a14c42f7525
5
5
  SHA512:
6
- metadata.gz: 2a15e0921c87254909bfdb11f35c0c3ac5bc85b8bd06c023234ac6c735a73cde92a7bcc2423ad40e5c37ac2718338a502e92e9b85ff6865760bca56e8671cea1
7
- data.tar.gz: f4ba5aaea3ce9ef9870becafbfb7c58b79bebb76ab9d96161533f13c824a2e905964f39e99c7b4b1352df5d65b154e2d6b593099cc36ea43aafd25dc2b2d0366
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
  ![Sine Wave Plot](doc/sin.png)
71
73
 
72
- Total % memory usage:
74
+ #### Memory usage (%)
73
75
  ```
74
- termplot --command "free | awk 'NR==2 { print ($3/$2) * 100 }'" \
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
  ![Free Memory % Chart](doc/memory.png)
78
80
 
79
- % CPU usage of a "puma" process:
81
+ #### Real time stock ticker
82
+
83
+ (Using [ticker.sh](https://github.com/pstadler/ticker.sh)) 😉:
84
+
80
85
  ```
81
- termplot --command "ps au | grep puma | awk 'NR==1{ print $3 }'" \
82
- -t "Ruby CPU(%)" --color yellow --line-style dot -r10 -c 120
86
+ termplot --command 'NO_COLOR=1 ticker.sh MSFT | awk "{ print $2 }"' \
87
+ --interval 10000 -t "MSFT" --color light_green
83
88
  ```
84
- ![CPU % Chart](doc/cpu.png)
85
-
89
+ ![MSFT ticker chart](doc/MSFT.png)
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 "ss -s | head -n1 | cut -d' ' -f2" --interval 500 -t "TCP Connections"
114
+ termplot --command 'ss -s | head -n1 | cut -d" " -f2' --interval 500 -t "TCP Connections"
111
115
  ```
112
116
 
113
117
  ![TCP Connections](doc/tcp.png)
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 = `/bin/bash -c '#{options.command}'`.chomp
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
@@ -1,3 +1,3 @@
1
1
  module Termplot
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-09 00:00:00.000000000 Z
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