fintop 0.0.1 → 0.0.2
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.
- data/CHANGELOG.md +7 -0
- data/README.md +8 -2
- data/bin/fintop +12 -5
- data/fintop.gemspec +2 -0
- data/lib/fintop/printer.rb +41 -14
- data/lib/fintop/probe.rb +16 -11
- data/lib/fintop/version.rb +1 -1
- metadata +21 -5
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.0.2 (4/6/2014)
|
2
|
+
|
3
|
+
- Add -a option for displaying info on other users' Finagle processes
|
4
|
+
- Fetch Java processes in Ruby rather than shelling out to `jps`
|
5
|
+
- Add -v/--version command-line options
|
6
|
+
- Add -h/--help command-line options
|
7
|
+
|
1
8
|
# 0.0.1 (4/1/2014)
|
2
9
|
|
3
10
|
- Initial version of Fintop. Probes stats and threads endpoints of Finagle
|
data/README.md
CHANGED
@@ -4,8 +4,14 @@ A top-like utility for monitoring [Finagle](http://github.com/twitter/finagle) s
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
### From RubyGems.org
|
8
|
+
|
9
|
+
`fintop` is distributed as [an executable Ruby gem](https://rubygems.org/gems/fintop).
|
10
|
+
To install it from the RubyGems.org, simply run `gem install fintop`.
|
11
|
+
|
12
|
+
### From source
|
13
|
+
|
14
|
+
To install `fintop` locally from source, clone this repository and run
|
9
15
|
`rake install` from within the repository's root directory.
|
10
16
|
|
11
17
|
## Usage
|
data/bin/fintop
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'fintop/printer'
|
4
|
-
require 'fintop/probe'
|
5
|
-
require 'fintop/threads'
|
6
|
-
|
7
|
-
finagle_procs = Fintop::Probe.apply
|
8
|
-
Fintop::Printer.apply(finagle_procs)
|
9
4
|
|
5
|
+
option = ARGV[0]
|
6
|
+
if option == '-v' or option == '--version'
|
7
|
+
Fintop::Printer.print_version
|
8
|
+
exit
|
9
|
+
elsif option == '-h' or option == '--help'
|
10
|
+
Fintop::Printer.print_help
|
11
|
+
exit
|
12
|
+
else
|
13
|
+
require 'fintop/probe'
|
14
|
+
finagle_procs = Fintop::Probe.apply(option == '-a')
|
15
|
+
Fintop::Printer.apply(finagle_procs)
|
16
|
+
end
|
data/fintop.gemspec
CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ['Evan Meagher']
|
10
10
|
s.email = ['evan.meagher@gmail.com']
|
11
11
|
s.summary = %q{A top-like utility for monitoring Finagle servers}
|
12
|
+
s.description = %q{Fintop is a top-like monitoring tool Finagle servers}
|
12
13
|
s.license = 'MIT'
|
13
14
|
|
14
15
|
s.files = `git ls-files -z`.split("\x0")
|
@@ -21,4 +22,5 @@ Gem::Specification.new do |s|
|
|
21
22
|
s.add_development_dependency 'test-unit', '~> 2.5'
|
22
23
|
|
23
24
|
s.add_dependency 'json'
|
25
|
+
s.add_dependency 'sys-proctable', '~> 0.9.4'
|
24
26
|
end
|
data/lib/fintop/printer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'fintop/metrics'
|
2
|
-
require '
|
2
|
+
require 'fintop/threads'
|
3
3
|
|
4
4
|
module Fintop
|
5
5
|
# Contains functions that gather and print operational data on local
|
@@ -63,10 +63,49 @@ module Fintop
|
|
63
63
|
}
|
64
64
|
end
|
65
65
|
|
66
|
+
# Print fintop version.
|
67
|
+
def print_version
|
68
|
+
require 'fintop/version'
|
69
|
+
puts "fintop version #{Fintop::VERSION}"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Print help output.
|
73
|
+
def print_help
|
74
|
+
puts 'usage: fintop [-v|--version] [-h|--help] [-a]'
|
75
|
+
puts
|
76
|
+
puts 'Options:'
|
77
|
+
printf(@@option_format_str, '-a', 'Display info about other users\' ' \
|
78
|
+
'Finagle processes as well as your own')
|
79
|
+
printf(@@option_format_str, '-v, --version',
|
80
|
+
'Print the version number of Fintop being run')
|
81
|
+
printf(@@option_format_str, '-h, --help', 'Print help output')
|
82
|
+
puts
|
83
|
+
puts 'Column Labels:'
|
84
|
+
@@columns.each { |label, description|
|
85
|
+
printf(@@column_label_format_str, label, description)
|
86
|
+
}
|
87
|
+
end
|
88
|
+
|
66
89
|
private
|
67
90
|
|
68
91
|
@@row_format_str = "%-7s %-6s %-5s %-5s %-6s %-6s %-7s %-8s %-10s %-10s\n"
|
69
92
|
|
93
|
+
# Help output format strings.
|
94
|
+
@@option_format_str = " %s\n %s\n"
|
95
|
+
@@column_label_format_str = " %-8s %s\n"
|
96
|
+
@@columns = [
|
97
|
+
['PID', 'The process identifier of the Finagle process'],
|
98
|
+
['PORT', 'The admin port opened by the process'],
|
99
|
+
['CPU', 'The number of CPUs allocated to the process'],
|
100
|
+
['#TH', 'The total number of threads within the process'],
|
101
|
+
['#NOND', 'The number of non-daemon threads within the process'],
|
102
|
+
['#RUN', 'The number of runnable threads within the process'],
|
103
|
+
['#WAIT', 'The number of waiting threads within the process'],
|
104
|
+
['#TWAIT','The number of threads within the process that are waiting on a timer'],
|
105
|
+
['TXKB', 'The sum of data (in KB) transmitted by the Finagle process'],
|
106
|
+
['RXKB', 'The sum of data (in KB) received by the Finagle process']
|
107
|
+
]
|
108
|
+
|
70
109
|
# Print a total process/thread synopsis and column headers.
|
71
110
|
#
|
72
111
|
# @param threads_data_hash [Hash<Fixnum, ThreadsData>] a hash of pids and
|
@@ -89,19 +128,7 @@ module Fintop
|
|
89
128
|
"#{runnable_threads} runnable, "\
|
90
129
|
"#{waiting_threads} waiting"
|
91
130
|
puts
|
92
|
-
printf(
|
93
|
-
@@row_format_str,
|
94
|
-
'PID',
|
95
|
-
'PORT',
|
96
|
-
'CPU',
|
97
|
-
'#TH',
|
98
|
-
'#NOND',
|
99
|
-
'#RUN',
|
100
|
-
'#WAIT',
|
101
|
-
'#TWAIT',
|
102
|
-
'TXKB',
|
103
|
-
'RXKB'
|
104
|
-
)
|
131
|
+
printf(@@row_format_str, *(@@columns.map { |label, desc| label }))
|
105
132
|
end
|
106
133
|
end
|
107
134
|
end
|
data/lib/fintop/probe.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'sys/proctable'
|
2
3
|
require 'timeout'
|
3
4
|
|
4
5
|
module Fintop
|
@@ -23,19 +24,23 @@ module Fintop
|
|
23
24
|
#
|
24
25
|
# Probing targets are Java processes listening on a TCP socket serving
|
25
26
|
# the path "/admin". Function returns an array of FinagleProcess objects
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
"awk '{print $1}'"
|
27
|
+
#
|
28
|
+
# @param include_other_users [Boolean] if true, other users' Java
|
29
|
+
# processes will be probed in addition to the current user's
|
30
|
+
def apply(include_other_users = false)
|
31
|
+
java_ps = Sys::ProcTable.ps.select { |s| s.comm == 'java' }
|
32
32
|
|
33
|
-
|
34
|
-
# Filter
|
35
|
-
|
33
|
+
listening_java_ps = java_ps.map { |s|
|
34
|
+
# Filter by user, pid, and existence of a listened-on TCP port.
|
35
|
+
user_filter_str = include_other_users ? "-u #{s.ruid}" : ''
|
36
|
+
lsof_cmd_str = "lsof -P #{user_filter_str} -i tcp -a -p #{s.pid} " \
|
37
|
+
"| grep LISTEN " \
|
38
|
+
"| awk '{print $9}'"
|
36
39
|
port_match = /\d+/.match(`#{lsof_cmd_str}`)
|
37
|
-
port_match && [pid, port_match[0]]
|
38
|
-
}.compact
|
40
|
+
port_match && [s.pid, port_match[0]]
|
41
|
+
}.compact
|
42
|
+
|
43
|
+
listening_java_ps.map { |pid, admin_port|
|
39
44
|
# Probe the possible ping endpoints to determine which (if any) stats
|
40
45
|
# library is in use.
|
41
46
|
begin
|
data/lib/fintop/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fintop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Evan Meagher
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2014-04-
|
18
|
+
date: 2014-04-06 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -76,7 +76,23 @@ dependencies:
|
|
76
76
|
version: "0"
|
77
77
|
type: :runtime
|
78
78
|
version_requirements: *id004
|
79
|
-
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: sys-proctable
|
81
|
+
prerelease: false
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 51
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
- 9
|
91
|
+
- 4
|
92
|
+
version: 0.9.4
|
93
|
+
type: :runtime
|
94
|
+
version_requirements: *id005
|
95
|
+
description: Fintop is a top-like monitoring tool Finagle servers
|
80
96
|
email:
|
81
97
|
- evan.meagher@gmail.com
|
82
98
|
executables:
|