tailstrom 0.0.5 → 0.0.6
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/bin/tailstrom +1 -1
- data/example/dummylog +6 -2
- data/lib/tailstrom/command/stat.rb +12 -3
- data/lib/tailstrom/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fc9291b2a7850cedd5567f7c78a94073695a49b
|
4
|
+
data.tar.gz: ceb209f84de1c9c1104e0e5df763812eed71b894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0a0ce1ff435b17b851d51516a0bf0137ed2d866618e855d9a3d35b7f45843ea664d10d123e310ff2a09254175160771244530f6495b4f76c4ee8cb83759f367
|
7
|
+
data.tar.gz: fda93ef992bebf83c9c2828e4e09e91de049f07549de250b99c8836340a1166eb1978474d72b2d2c6b6b19c266b4aa08aeb2241c7442622a41f2c77d82554402
|
data/bin/tailstrom
CHANGED
@@ -49,6 +49,6 @@ if infile = ARGV.shift
|
|
49
49
|
end
|
50
50
|
|
51
51
|
require "tailstrom/command/#{options[:mode]}"
|
52
|
-
cls =
|
52
|
+
cls = Tailstrom::Command.const_get options[:mode].to_s.capitalize
|
53
53
|
cmd = cls.new options
|
54
54
|
cmd.run
|
data/example/dummylog
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'time'
|
3
3
|
|
4
|
+
def sample(arr)
|
5
|
+
arr[rand arr.length]
|
6
|
+
end
|
7
|
+
|
4
8
|
begin
|
5
9
|
loop do
|
6
|
-
url = "/#{%w(users products photos)
|
10
|
+
url = "/#{sample %w(users products photos)}/#{rand(1000)}"
|
7
11
|
time = Time.now.iso8601
|
8
12
|
rtime = rand(1_000_000)
|
9
|
-
status = [200, 302]
|
13
|
+
status = sample [200, 302]
|
10
14
|
puts [status, time, rtime, url].join("\t")
|
11
15
|
$stdout.flush
|
12
16
|
sleep rand(10).to_f / 100.0
|
@@ -29,7 +29,7 @@ module Tailstrom
|
|
29
29
|
@counters[line[:key]] << line[:value]
|
30
30
|
end
|
31
31
|
|
32
|
-
height =
|
32
|
+
height = terminal_height
|
33
33
|
i = 0
|
34
34
|
begin
|
35
35
|
sleep @options[:interval]
|
@@ -52,6 +52,15 @@ module Tailstrom
|
|
52
52
|
end
|
53
53
|
|
54
54
|
private
|
55
|
+
def terminal_height
|
56
|
+
system 'which tput 2>&1 >/dev/null'
|
57
|
+
if $? == 0
|
58
|
+
`tput lines`.to_i - 4
|
59
|
+
else
|
60
|
+
10
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
55
64
|
def print_counters
|
56
65
|
sorted_counters.each do |key, c|
|
57
66
|
key = (key == :nil ? nil : key)
|
@@ -68,13 +77,13 @@ module Tailstrom
|
|
68
77
|
def sorted_counters
|
69
78
|
counters = @counters.to_a
|
70
79
|
if sort = @options[:sort]
|
71
|
-
counters.sort_by
|
80
|
+
counters = counters.sort_by do |key, c|
|
72
81
|
sum, avg, min, max, count =
|
73
82
|
c.sum, c.avg, c.min, c.max, c.count
|
74
83
|
binding.eval sort
|
75
84
|
end
|
76
85
|
else
|
77
|
-
counters.sort_by
|
86
|
+
counters = counters.sort_by do |key, c|
|
78
87
|
c.sum
|
79
88
|
end
|
80
89
|
end
|
data/lib/tailstrom/version.rb
CHANGED